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.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.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.
allows the validators object and validator options to be a function that should return the constraints/options: Validates the attributes object against the constraints.
It is unit tested with 100% code coverage and can be considered fit for production.
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.
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.