jslib-validator
v0.0.1
Published
Simple data validator
Downloads
4
Readme
Validator
Simple data validator
Usage
Register a function
var validator = require('jslib-validator');
validator.register('==', function(a, b, cb){
cb(a === b);
});
Call a function
var validator = require('jslib-validator');
validator.register('==', function(a, b, cb){
cb(a === b ? null : 'not equal');
});
validator('==', 1, 1, function(err){
if (err) {
console.error(err);
} else {
console.log("valid");
}
});
Get a registered function
var validator = require('jslib-validator');
validator.register('==', function(a, b, cb){
cb(a === b ? null : 'not equal');
});
var eqValidator = validator('==');