Valod
A simple NodeJS server side form validator
INSTALLATION:
npm install valod
Very easy to use:
Usage Example:
var valod = ; var norms = email: 'email'"email not Valid" name: 'required''alphanum' 'Invalid Name'var validation = norms; // json object representing form data received in post requestvar form = name: '1sd' var res = validationifresvalid consoleelse console; // output: Success form = email: 'mohmail.com' var res = validationifresvalid consoleelse console; // output: [ 'email not Valid', 'Invalid Name' ]
Norms
- 'required': Field is required
- 'email': Field is a valid email
- 'numeric': Field is a numeric value
- 'alphanum': Field is an alphanumeric value
- 'maxln': Max length of field. Ex:// for max length of 4 charactersvar norms =name: 'maxln4'"name is too long"
- 'minln': Min length of field
- 'max': Max value (For numeric fields only). Ex:// for max value 4var norms =age: 'max4'"age is too big"
- 'min': Min value (For numeric fields only)