custom validator message
GenaANTG opened this issue · 1 comments
GenaANTG commented
Hi!
I have a next message after validation:
{ ...
name: 'ValidationError',
message: 'Value for [email] must be a valid email.'
}
How i can change a validator message for specific field? e.g. Email.
I was not found any solutions for that in documentation.
Thanks!
cur3n4 commented
I don't think there is a way to change the validator message for a specific field.
However you should be able to specify your own validation function in your schema and throw the error with your preferred message.
const Model = thinky.createModel('Model',
{
email: type.string().email().validator(function() {
throw new Errors.ValidationError("Boo")
})
},
{init: false})