Skip to content
/ oproba Public

⛔️ [DEPRECATED] Key-value object validator based on aproba

Notifications You must be signed in to change notification settings

dsheiko/oproba

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

oproba

NPM Build Status

⚠️ This project is no longer maintained. Please see one of these libraries instead:


Extension of aproba - argument validator for key-value object validation

const validate = require( "oproba" );
// 'validate' is instance of aproba

// Check that `options` object properties comply specified aproba constraints
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`

Aproba constraints:

type description
* matches any type
A Array.isArray OR an arguments object
S typeof == string
N typeof == number
F typeof == function
O typeof == object and not type A and not type E
B typeof == boolean
E instanceof Error OR null
Z == null

See more about aproba syntax

About

⛔️ [DEPRECATED] Key-value object validator based on aproba

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published