super-valid
Validation-framework for NodeJS
Installation
$ npm install super-valid
Usage
var SuperValid = ; var errors = SuperValid ;iferrors console; /* Will produce { name : { value : '[the value supplied]', error : 'Name too long', // The most recent error errors : ['Name too short', 'Name too long'] // All the errors }, age : { value : '[the value supplied]', errors : 'Age too little', errors : ['Not a number', 'Age too little'] } } */
Method | Description |
---|---|
notEmpty(errorMessage) | Ensures that the string is not empty |
longerThan(len, errorMessage) | Ensures that the string is longer than len |
shorterThan(len, errorMessage) | Ensures that the string is shorter than len |
isEmail(errorMessage) | Ensures that the string is an email-address |
regex(regex, errorMessage) | Ensures that the string matches the supplied regular expression |
isInt(errorMessage) | Ensures that the string is a valid integer |
isFloat(errorMessage) | Ensures that the string is a valid float |
greaterThan(min, errorMessage) | Ensures that the string is a number greater than min |
lessThan(max, errorMessage) | Ensures that the string is a number less than min |