1.0.2 • Published 5 years ago

oproba v1.0.2

Weekly downloads
1
License
MIT
Repository
-
Last release
5 years ago

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`