The message can also be a function which will be called to retrieve the message, besides this it is treated like a normal message (the attribute name is prepended etc).If the message is not a function and not a string it is simply returned as is.If an is thrown from an async validator the argument passed to the rejection handler will be that error.This allows you to differentiate from coding errors and validation errors.The validation constraints can be declared in JSON and shared between clients and the server. One thing that is a bit unorthodox is that most validators will consider undefined values (,) valid values.So for example adding a constraint of at least 6 characters will be like saying If the attribute is given it must be at least 6 characters.This differs from example Ruby on Rails where validators instead have the option.I find it quite common that you want to have constraints on an optional attribute.

There are no required external dependencies at all!

supports async validations through the returns a Promise that is resolved if the validation passes and is rejected if the validation failed, passing the errors as the first argument.



Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>