piggy-proof
v0.0.22
Published
Validate an object of properties meets given validation rules
Downloads
34
Readme
piggy-proof
Validation library for PiggyPot. Validation rules are held in a central 'models' directory - this reduces duplication of rules across the codebase.
Installation
npm install --save piggy-proof
Usage
var PiggyProof = require('piggy-proof');
var data = {
username: '',
password: 'ab'
};
var validationResults = PiggyProof.validate(data, 'users');
// => {
// username: [ 'is not present' ],
// password: [ 'is below the minimum length' ]
// }
PiggyProof.isValid(validationResults)
// => false
Running Tests
npm test