Closed daslicht closed 11 years ago
Hi Marc - try: validate({ message: 'This is not an eMail' }, 'isEmail' })
Thanks that works ! Is there also a convenient way to check if a user already exists , unique ?
On 17.08.2013, at 13:09, leepowellcouk notifications@github.com wrote:
Hi Marc - try: validate({ message: 'This is not an eMail' }, 'isEmail' })
— Reply to this email directly or view it on GitHub.
I found this here: https://npmjs.org/package/mongoose-unique-validator But I don't see how to change the default Error Message :/ Cheers Marc
On 17.08.2013, at 13:09, leepowellcouk notifications@github.com wrote:
Hi Marc - try: validate({ message: 'This is not an eMail' }, 'isEmail' })
— Reply to this email directly or view it on GitHub.
It doesn't look like you can set the error message in that plugin. You could either contact the author and ask him if he has plans to provide that functionality, or fork the repository, add it yourself and offer a pull request.
Thanks I am on it :)
How do you solve such things ?
Sole?
"solve" sorry :) [fixed]
Essentially that plugin is a wrapper around a query to the database to see if the unique item has already been used - this allows for the model to report an error at the validation level rather than at the save level (which is where mongoose does it for it's 'unique' property on a path).
Hello, I tried to ass the isEmail validation like this: var emailValidator = [validate({message: "This is not an eMail"}), validate('isEmail')];
What is the correct Syntax ?
Cheers Marc