Javascript 当修饰符选项为true时,验证对象必须至少有一个运算符-Collection 2 package-Meteor

Javascript 当修饰符选项为true时,验证对象必须至少有一个运算符-Collection 2 package-Meteor,javascript,meteor,meteor-collection2,Javascript,Meteor,Meteor Collection2,尝试创建用户时出现以下错误: Exception while invoking method 'createUser' Error: When the modifier option is true, validation object must have at least one operator 下面是我如何调用createUser方法: Template.register.events({ "submit #register_form": function(event) {

尝试创建用户时出现以下错误:

Exception while invoking method 'createUser' Error: When the modifier option 
is true, validation object must have at least one operator
下面是我如何调用
createUser
方法:

Template.register.events({
  "submit #register_form": function(event) {
    event.preventDefault();

    var $form   = $("#register_form");
    var attr    = {};
    var profile = {};


    // We gather form values, selecting all named inputs
    $("input[name]", $form).each(function(idx) {
      var $input = $(this);
      var name   = $input.attr("name");


      if (name == "email" || name == "password") {
        attr[ name ] = $input.val();
      }
      else if (name != "repeat_password") {
        profile[ name ] = $input.val();
      }
    });
    attr.profile = profile;


    // Creating user account (Cf Accounts module)
    Accounts.createUser(attr, function(error) {
      console.log(error);
    }); 
  },
});
attr
具有以下值:

下面是我如何定义
用户
模式:

// Setting up Simple Schema (cf module)
var profile_schema = new SimpleSchema({
  firstname: {
    type:   String,
    regEx:  /^[a-z0-9A-Z_]{3,15}$/
  },
  lastname: {
    type:   String,
    regEx:  /^[a-z0-9A-Z_]{3,15}$/
  },
  celular: {
    type:     String,
    optional: true,
  },
});


var schema = new SimpleSchema({
  emails: {
    type:   [Object],
  },
  "emails.$.address": {
    type:   String,
    regEx:  SimpleSchema.RegEx.Email
  },
  "emails.$.verified": {
    type:   Boolean
  },
  profile: {
    type:     profile_schema,
    optional: true,
  },
  createdAt: {
    type:   Date
  },
});


// Attaching Simple Schema to the users collection (Cf collection2 module)
Meteor.users.attachSchema(schema);

我找不到不对的地方。欢迎任何建议

添加我的评论作为可见性的答案

您需要将服务对象添加到您的用户模式中,如下所示

services: { 
    type: Object,
    blackbox: true 
}

即使您没有使用任何oAuth,您也需要添加此项,因为Meteor为电子邮件登录添加了“服务”。您应该始终拥有它。

尝试将它添加到您的模式
服务:{type:Object,blackbox:true}
这是可行的。非常感谢。我是否应该始终将
服务
对象包含到我的用户架构中,或者这是我的给定配置所必需的。我没有使用任何
账户-#服务#
插件(即Twitter、Facebook、谷歌)。再次感谢!没问题。我把我的建议变成了答案,因为它解决了你的问题。如果你还没有看过的话,你也可能对它感兴趣。这使得在meteor中制作表单变得非常简单。