validator-object
v1.0.0
Published
validator-object is simple object validator with validator module.
Downloads
2
Maintainers
Readme
validator-object
Simple object validator with validator module.
Usage
```javascript
const validatorObj = require('./');
const validator = validatorObj.validator;
let formData = {
email: '[email protected]',
age: 'hi'
};
const rules = {
email: validator.isEmail,
age: validator.isNumeric
};
let validateResults = validatorObj.check(formData, rules);
console.log('Validate-obj results:', validateResults);
// Validate-obj results: [ { email: true }, { age: true } ]
```
API
array passedFields()
Returns only passed fields
array failedFields()
Returns only passed fields
Returning array
[ { fieldName1: true/false }, { fieldName2: true/false } ]
License
MIT.