vld
Simple validator. Useful for function arguments and functions that take an object for options. Looks like this:
var vld = ; { vldobjectoptions; vld;} // throws InvalidPropertyError: Expected property 'foo' of `options` to be // string, but instead got 39 (number); // throws InvalidPropertyError: Expected property 'bar' of `options` to be // string (required), but instead got undefined // throws InvalidPropertyError: Expected property 'baz' of `options` to be 34 // (number) or true or string, but instead got 1000 (number); // throws InvalidPropertyError: Expected property 'port' of `options.server` // to be number, but instead got '80' (string);
Can also be used to validate individual things or arguments.
var vld = ; { vldtype 'argument 0 (type)'; vld name 'argument 1 (name or callback)' ; vld;} // does not throw; // also does not throw; // throws ValidationError: Expected argument 1 (name or callback) to be // function or string, but instead got true (boolean);