assert-my-json-valid
v1.0.2
Published
Use is-my-json-valid to validate, throw if error
Maintainers
Readme
assert-my-json-valid 
Use is-my-json-valid to validate, throw if error
Install
$ npm install --save assert-my-json-validUsage
var assertMyJsonValid = require('assert-my-json-valid')
var schema = {
type: 'string'
}
try {
assertMyJsonValid(schema, 1)
} catch (e) {
console.log(e) // => 'string data is the wrong type (value: 1)'
}
assertMyJsonValid(schema, 'foo') // no errorAPI
assertMyJsonValid(schema, value) -> output
Validates value against schema and throws a ValidationError if not valid.
It will only create a JSON validator once for each schema reference.
License
MIT © Andrew Joslin
