I get the following error when trying to create a user :
Exception while invoking method 'createUser' Error: When the modifier option
is true, validation object must have at least one operator
Here is how I am calling the createUser
method :
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
has the following value :
And here is how I define the users
schema :
// 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);
I can't find what is not right. Any suggestion is most welcomed!
Adding my comment as an answer for visibility
You need to add the services object to your user schema as follows
services: {
type: Object,
blackbox: true
}
You need to add this even though you are not using any oAuth because Meteor adds a "service" for email login. You should always have it.