objoi
v1.0.4
Published
Validate object input using JOI.
Downloads
18
Maintainers
Readme
objoi
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.