Created
May 25, 2015 05:01
-
-
Save stefanhayden/565082dd80fea1cd8819 to your computer and use it in GitHub Desktop.
SimpleSchema for Meteor JS users collection
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Schemas.UserProfile = new SimpleSchema({ | |
firstName: { | |
type: String, | |
regEx: /^[a-zA-Z-]{2,25}$/, | |
optional: true | |
}, | |
lastName: { | |
type: String, | |
regEx: /^[a-zA-Z]{2,25}$/, | |
optional: true | |
}, | |
birthday: { | |
type: Date, | |
optional: true | |
}, | |
website: { | |
type: String, | |
regEx: SimpleSchema.RegEx.Url, | |
optional: true | |
}, | |
bio: { | |
type: String, | |
optional: true | |
} | |
}); | |
Schemas.User = new SimpleSchema({ | |
username: { | |
type: String, | |
regEx: /^[a-z0-9A-Z_]{3,15}$/ | |
}, | |
emails: { | |
type: [Object], | |
optional: true | |
}, | |
"emails.$.address": { | |
type: String, | |
regEx: SimpleSchema.RegEx.Email | |
}, | |
"emails.$.verified": { | |
type: Boolean | |
}, | |
createdAt: { | |
type: Date | |
}, | |
profile: { | |
type: Schemas.UserProfile, | |
optional: true | |
}, | |
services: { | |
type: Object, | |
optional: true, | |
blackbox: true | |
} | |
}); | |
Meteor.users.attachSchema(Schemas.User); | |
Meteor.users.allow({ | |
insert: function () { return true; }, | |
update: function () { return true; }, | |
remove: function () { return true; } | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment