Validation-helpers
Validation helpers makes you validate your body of request or any value you want with a simple set of rules with the help of Validator and other simple packages.
Usage
const errors isValid = ;
rules
need to be like
value;
Example
const errors isValid = ;
This will throw an error for isMember rule with a simple message 'Not a valid member'
.
Or the old way rules can be written with array of objects.
type: RulesREQUIRED type: RulesIS_MEMBER array: "foo" "bla" "hi" ;
type
must be a valid type from validationHelpers.Types every type may have a second property must be passed like
{ type: Rules.IS_MEMBER, array: ['foo', 'bla', 'hi']
TODO
- Write readable usage example.
- Write Unit test for all cases.
- Integrate with CI.