In the upcoming Meteor Guide, we're working to have a standardized format for validation errors, which contain information about the type of error and the relevant field. This PR will allow me to use code like the below to validate new users:
// Ensuring every user has an email address, should be in server-side code
Accounts.validateNewUser((user) => {
new SimpleSchema({
_id: { type: String },
emails: { type: Array },
'emails.$': { type: Object },
'emails.$.address': { type: String },
'emails.$.verified': { type: Boolean },
createdAt: { type: Date },
services: { type: Object, blackbox: true }
}).validate(user);
// Return true to allow user creation to proceed
return true;
});
This is just a first pass to display something, we can do more passes to make the output nicer. It would be good to integrate with tap:i18n somehow to convert the error codes into readable text.
In the upcoming Meteor Guide, we're working to have a standardized format for validation errors, which contain information about the type of error and the relevant field. This PR will allow me to use code like the below to validate new users: