oproba

1.0.2 • Public • Published

oproba

NPM

Build Status

A 'rediculously light-weight' extension of aproba for key-value object validation

const validate = require( "oproba" );
// 'validate' is instance of aproba
 
// Check that `options` object properties comply specified aproba schemas
validate.obj({ foo: "N", bar: "S|N" }, options );
 
 
// Validate a nested object
validate.obj({
  foo: {
    baz: {
      quiz: "S"
    }
  },
  bar: "S|N" }, options );

Optional properties (? directive)

validate.obj({ foo: "N?", bar: "S|N?" }, options );

Explanatory error messages

  validate.obj({
    foo: { bar: "S|Z" }
  }, {
    foo: { bar: 1 }
  });
// throws `Error: Invalid type in property #foo.bar: Expected string or null but got number`

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.2
    0
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.0.2
    0
  • 1.0.1
    0
  • 1.0.0
    0

Package Sidebar

Install

npm i oproba

Weekly Downloads

0

Version

1.0.2

License

MIT

Unpacked Size

7.34 kB

Total Files

5

Last publish

Collaborators

  • dsheiko