objoi

1.0.4 • Public • Published

objoi

Build Status Coverage Status Dependencies

Using ES2015's new Proxy object and the power of joi, validate input to native JS objects, arrays and functions.

// Load dem modules
var objoi = require('objoi')
var joi = objoi.joi
 
// Make `foo` an object with a schema
var foo = objoi({}, joi.object().keys({
    bar: joi.boolean()
}))
 
// Throws error: "bar" must be a boolean
foo.bar = 'baz'
 
// Lets it happen
foo.bar = true

Why did you do this?

I don't know yet. I mean, it's gotta be useful for something, right?

Anything else?

objoi also exposes objoi.joi which you can use to create schemas with in case you don't want to add two dependencies for a single module.

I want a slowly-typed, animated example

asciicast

Package Sidebar

Install

npm i objoi

Weekly Downloads

0

Version

1.0.4

License

ISC

Last publish

Collaborators

  • jpwilliams