dotfiles/.vscode/extensions/saviorisdead.RustyCode-0.18.0/node_modules/is-my-json-valid/example.js
Cyryl Płotnicki 2f946d6200 Add .vscode
2016-09-11 10:29:13 +02:00

18 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)