is-my-json-valid
Installation
npm install --save is-my-json-validUsage
var validator = require('is-my-json-valid')
var validate = validator({
required: true,
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 list of errors by checking validate.errors
// the following will print [{field: 'data.hello', message: 'is required'}]
console.log(validate.errors)Custom formats
External schemas
Filtering away additional properties
Verbose mode shows more information about the source of the error
Greedy mode tries to validate as much as possible
Error messages
Performance
TypeScript support
License
Last updated