Schema validator for objects. Best used as a sanity check for devs, and not to
validate user input (e.g. we're using throw).
$ npm i --save miller
var miller = require('miller');
var schema = miller({
code: 'number',
message: 'string'
});
schema({
code: 302,
message 'foo-bar'
});
// => {code: 302, message: 'foo-bar'}
Create a validator based on a provided schema object. Input types can be JavaScript primitives only.
var schema = miller({
foo: 'string',
bar: 'number'
});
Check an object against the provided schema. If the schema doesn't match the
input throws a TypeError.
schema({
foo: 'bin',
bar: 123
});