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.Unless otherwise specified you can always specify the message option to customize the message returned if the validator doesn't pass.

javascript for validating email with regular expression-70

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.

You can tell to use any A compatible promise implemention like this: There are already many validation libraries out there today but most of them are very tightly coupled to a language or framework.

The goal of is to provide a cross framework and cross language way of validating data.

provides a declarative way of validating javascript objects.

It is unit tested with 100% code coverage and can be considered fit for production.

Besides accepting all options as the non async validation function it also accepts two additional options; clean Attributes which, unless before resolving the promise and wrap Errors which can be a function or constructor that will be called with the errors, options, attributes and constraints if an error occurs.

This allows you to define a better way of catching validation errors.

is an open source component of Wrapp and is licensed under the MIT license.

There are no required external dependencies at all!

One core value of this library is that nothing should be private or inaccessable.