为什么什么都没有通过 Firebase 验证?为什么没有返回错误消息?
Why does nothing pass Firebase validation? Why are no error messages returned?
我正在使用以下安全规则:
{
"rules": {
".read": true,
".write": true,
"chat": {
".read": true,
".write": true,
".validate": "newData.hasChildren(['author', 'message'])"
}
}
}
我正在使用 $add
以这种格式将对象保存到我的 chat
$firebaseArray:
{message: "hello there", author: {emailAddress: "javier@test.com"}}
但是如果定义了.validate
,它总是会失败。如果未定义 .validate
,它会正确保存。所以我尝试像这样扩展 $firebaseArray:
var myFarr = $firebaseArray.$extend({
$$error: (err) {
console.log(err)
}
})
this.messages = myFarr( $scope.firebaseData.$ref().child('chat') )
this.sendEmail = (function(_this) {
return function(email) {
_this.messages.$loaded().then(function(data) {
data.$add(email);
})["catch"](function(err) {
console.error(err);
});
};
})(this);
但是 $$error
方法似乎永远不会触发。
为什么我的有效数据没有得到验证,我怎样才能得到适当的错误消息?
您的规则中似乎缺少特定聊天消息的级别:
{
"rules": {
".read": true,
".write": true,
"chat": {
"$chatid": {
".read": true,
".write": true,
".validate": "newData.hasChildren(['author', 'message'])"
}
}
}
}
您的规则将验证应用于所有聊天消息的组合,而您希望将它们应用于每个单独的聊天消息。
我正在使用以下安全规则:
{
"rules": {
".read": true,
".write": true,
"chat": {
".read": true,
".write": true,
".validate": "newData.hasChildren(['author', 'message'])"
}
}
}
我正在使用 $add
以这种格式将对象保存到我的 chat
$firebaseArray:
{message: "hello there", author: {emailAddress: "javier@test.com"}}
但是如果定义了.validate
,它总是会失败。如果未定义 .validate
,它会正确保存。所以我尝试像这样扩展 $firebaseArray:
var myFarr = $firebaseArray.$extend({
$$error: (err) {
console.log(err)
}
})
this.messages = myFarr( $scope.firebaseData.$ref().child('chat') )
this.sendEmail = (function(_this) {
return function(email) {
_this.messages.$loaded().then(function(data) {
data.$add(email);
})["catch"](function(err) {
console.error(err);
});
};
})(this);
但是 $$error
方法似乎永远不会触发。
为什么我的有效数据没有得到验证,我怎样才能得到适当的错误消息?
您的规则中似乎缺少特定聊天消息的级别:
{
"rules": {
".read": true,
".write": true,
"chat": {
"$chatid": {
".read": true,
".write": true,
".validate": "newData.hasChildren(['author', 'message'])"
}
}
}
}
您的规则将验证应用于所有聊天消息的组合,而您希望将它们应用于每个单独的聊天消息。