我想验证$username
长度超过5个字符且短于24个字符
{
"rules": {
"user": {
"$username": {
".write": "auth != null",
"uid": {},
"created": {},
"lastlogin": {}
}
}
}
}
(如果可能的话)我该怎么做?
答案 0 :(得分:1)
是的,有可能:
{
"rules": {
"user": {
"$username": {
".write": "auth != null",
".validate":"newData.hasChildren(['validate_username'])",
"validate_username":{
".validate":"
newData.val() == $username
&& newData.val().length > 5
&& newData.val().length < 24
"
},
"uid": {},
"created": {},
"lastlogin": {}
}
}
}
}
答案 1 :(得分:0)
您可以使用正则表达式验证$ username
<dist:module dist:instant="true" />