1.0.2 • Published 9 years ago

miller v1.0.2

Weekly downloads
1
License
MIT
Repository
github
Last release
9 years ago

miller

NPM version build status Test coverage

Schema validator for objects. Best used as a sanity check for devs, and not to validate user input (e.g. we're using throw).

Installation

$ npm i --save miller

Overview

var miller = require('miller');

var schema = miller({
  code: 'number',
  message: 'string'
});

schema({
  code: 302,
  message 'foo-bar'
});
// => {code: 302, message: 'foo-bar'}

API

miller(schema)

Create a validator based on a provided schema object. Input types can be JavaScript primitives only.

var schema = miller({
  foo: 'string',
  bar: 'number'
});

miller()(input)

Check an object against the provided schema. If the schema doesn't match the input throws a TypeError.

schema({
  foo: 'bin',
  bar: 123
});

License

MIT © Yoshua Wuyts