npm stats
  • Search
  • About
  • Repo
  • Sponsor
  • more
    • Search
    • About
    • Repo
    • Sponsor

Made by Antonio Ramirez

miller

1.0.2

@yoshuawuyts

npmHomeRepoSnykSocket
Downloads:269
$ npm install miller
DailyWeeklyMonthlyYearly

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