Create schemas to validate data.
const vda = require('vda-schema');
const validatePerson = vda.validator({
name: vda.str(3, 20), // must be a string between 3-20 chars long
age: vda.optional.int(1, 100) // must be a whole number between 1-100
});
validatePerson({name: "trevor", age: -3}); // false
validatePerson({name: "max"}); // true
// check if not undefined
vda.any()
// check if string length is within some range
vda.str(min=0, max=Infinity)
// check if string matches regex or check if the number of matches are within some range
vda.regex(expr, min=1, max=Infinity)
// check if a real number is within some range
vda.num(min=-Infinity, max=Infinity)
// check if an integer is within some range
vda.int(min=-Infinity, max=Infinity)
// check if an object matches a schema
// default handler is for additional properties that weren't defined in the schema
vda.validator(schema, defaultHandler = () => true);
// operators
vda.not(function)
vda.and(...functions)
vda.or(...functions)