You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In my Schema, I'm adding multiple validations for a user registration field. Here's an example:
, email : {type: String,index: true,lowercase: true,validate: [{'validator' : validator.isRequired,'msg' : 'This field is required.'},{'validator' : validator.isEmail,'msg' : 'This field must contain an Email Address.'}]}
I've noticed that it seems to execute the validations starting fromt the last. So if the field is both empty and not an email address upon submission, the validator records the 'Email' validation error and not the 'isRequired' error.
{message: 'Validation failed',name: 'ValidationError',errors:
{password:
{message: 'Validator "This field is required" failed for path password',name: 'ValidatorError',path: 'password',type: 'This field is required'},email:
{message: 'Validator "This field must contain an Email Address." failed for path email',name: 'ValidatorError',path: 'email',type: 'This field must contain an Email Address.'},name:
{message: 'Validator "This field is required" failed for path name',name: 'ValidatorError',path: 'name',type: 'This field is required'}},body: {name: '',email: '',password: ''}}
I'm wondering if there would be any way to go through all of the validations, regardless if one fails, so that multiple validation error messages could be recorded and sent back to the user. I realize this probably isn't optimal default behaviour, but the option might be nice.
The text was updated successfully, but these errors were encountered:
In my Schema, I'm adding multiple validations for a user registration field. Here's an example:
I've noticed that it seems to execute the validations starting fromt the last. So if the field is both empty and not an email address upon submission, the validator records the 'Email' validation error and not the 'isRequired' error.
I'm wondering if there would be any way to go through all of the validations, regardless if one fails, so that multiple validation error messages could be recorded and sent back to the user. I realize this probably isn't optimal default behaviour, but the option might be nice.
The text was updated successfully, but these errors were encountered: