User accounts sheme (problem with email)


#1

hi, i tried add custom profile scheme to my users, but while i create account i have error: Email is required
why?
my scheme:

Schema = {};

Schema.UserProfile = new SimpleSchema({
    name: {
        type: String
    },
    birthday: {
        type: Date
    },
    gender: {
        type: String,
        allowedValues: ['Male', 'Female']
    },
});

Schema.User = new SimpleSchema({
    _id: {
        type: String,
        regEx: SimpleSchema.RegEx.Id
    },
    email: {
        type: String,
        regEx: SimpleSchema.RegEx.Email
    },
    createdAt: {
        type: Date
    },
    profile: {
        type: Schema.UserProfile,
    },
    services: {
        type: Object,
        optional: true,
        blackbox: true
    }
});

Meteor.users.attachSchema(Schema.User);

also i tried replace profile to

type: Object,
optional: true,
blackbox: true

but it dosnt help


#2

I dont see

optional: true

there, so it is mandatory or required


#3

Hi,

I had the same issue, obviously I enter an email on user registration. When the mail is not valid, it handle error correctly, but when it is valid, it says “Email is required”. The problem was that like you I used a singular “email” field, to solve it uses a plural “emails” like into the documentation, https://github.com/aldeed/meteor-collection2/blob/master/README.md#attaching-a-schema-to-a-collection :

emails: { type: Array, // For accounts-password, either emails or username is required, but not both. It is OK to make this // optional here because the accounts-password package does its own validation. // Third-party login packages may not require either. Adjust this schema as necessary for your usage. optional: true }, "emails.$": { type: Object }, "emails.$.address": { type: String, regEx: SimpleSchema.RegEx.Email }, "emails.$.verified": { type: Boolean },