Socket
Book a DemoInstallSign in
Socket

miller

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

miller

Schema validator for objects

latest
Source
npmnpm
Version
1.0.2
Version published
Maintainers
1
Created
Source

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

FAQs

Package last updated on 01 Aug 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts