One core value of this library is that nothing should be private or inaccessable.If you want to modify which values are considered empty for example you can simply overwrite You can find some basic examples included in the project.

validating phone number in javascript-72validating phone number in javascript-68

Any A type promise can be used, just override function success(attributes) function error(errors) var constraints = ; var attributes = ; // Will call the success function and log validate.async(attributes, constraints).then(success, error); // Will call the error function validate.async(, constraints).then(success, error); function Validation Errors(errors, options, attributes, constraints) Validation Errors.prototype = new Error(); // This isn't supported by the ES6 promises validate.async(, constraints, ) .then(success) .catch(Validation Errors, function(error) ) .catch(function(error) ); // Supporting another promise implementation (RSVP in this case) validate. Promise; Sometimes you only want to validate a single value against some constraints and using the normal validate function is quite verbose so there is a shorthand for this.

It does little more than proxying the call do the main validation function but with the value wrapped in an object and the options full Messages and format set to also has limited support for nested objects (objects within objects) using the dot notation.

The implementation is fairly basic and doesn't do anything clever with the messages.

It doesn't support things like only validating a sub key if the parent key is present so for more advanced validations multiple validation schemas are recommended. Most validators allow you to specify default messages in addition to default options, refer to the documentation for the individual validators for information on how to do this.

The project can be found on Git Hub where you can also find our issue tracker.

There is also a Travis project used for testing, a Coveralls project used to code coverage as well as the annotated source.

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.

Though for the datetime and date validator to you need to specify a parse and format function and for that you most likely will want to use a library, is highly recommended.

If you want to use async validation you need to use a runtime that supports Promises.

This differs from example Ruby on Rails where validators instead have the option.