当修饰符选项为 true 时,验证对象必须至少有一个运算符 - 集合 2 包 - Meteor
When the modifier option is true, validation object must have at least one operator - Collection 2 package - Meteor
我在尝试创建用户时遇到以下错误:
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
具有以下值:
下面是我如何定义 users
模式:
// 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 添加了一个 "service" 用于电子邮件登录。你应该永远拥有它。
我在尝试创建用户时遇到以下错误:
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
具有以下值:
下面是我如何定义 users
模式:
// 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 添加了一个 "service" 用于电子邮件登录。你应该永远拥有它。