Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

oproba

dsheiko8MIT1.0.2

NPM

aproba, validate, validator, object, map, key-value

readme

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`