Bones/node_modules/is-my-json-valid/example.js
SOUTHERNCO\x2mjbyrn 7efe7605b8 Template Upload
2017-05-17 13:45:25 -04:00

19 lines
430 B
JavaScript

var validator = require('./')
var validate = validator({
type: 'object',
properties: {
hello: {
required: true,
type: 'string'
}
}
})
console.log('should be valid', validate({hello: 'world'}))
console.log('should not be valid', validate({}))
// get the last error message by checking validate.error
// the following will print "data.hello is required"
console.log('the errors were:', validate.errors)