Javascript 为什么没有通过Firebase验证?为什么没有返回错误消息?

Javascript 为什么没有通过Firebase验证?为什么没有返回错误消息?,javascript,database,validation,firebase,angularfire,Javascript,Database,Validation,Firebase,Angularfire,我使用以下安全规则: { "rules": { ".read": true, ".write": true, "chat": { ".read": true, ".write": true, ".validate": "newData.hasChildren(['author', 'message'])" } } } 我使用$add将对象以以下格式保存到我

我使用以下安全规则:

{
    "rules": {
        ".read": true,
        ".write": true,
        "chat": {
          ".read": true,
          ".write": true,
          ".validate": "newData.hasChildren(['author', 'message'])"
        }
    }
}
我使用
$add
将对象以以下格式保存到我的
聊天
$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'])"
      }
    }
  }
}

您的规则将验证应用于所有组合的聊天信息,而您希望将它们应用于每个单独的聊天信息。

请编辑您的问题,以包括失败的
$add()
操作。@FrankvanPuffelen完成!此信息也在中。我看了好几遍这些文件,但是这些信息没有注册到我这里,因为我很笨。