gladiator
v0.3.1
Published
JSON Schema v4 Validator
Downloads
3
Readme
Gladiator v0.3.1
JSON Schema v4 Validator
Example
// load gladiator
var gladiator = require('gladiator');
// create a validator using schema
var validator = new gladiator({
type: 'object',
properties: {
name: {
type: 'string'
}
}
});
// how to determine if validator is valid
if (validator.valid) {
console.log('Gladiator is ready.');
} else {
// how to access validator errors
console.dir(validator.errors);
}
// validate data
var validated = validator.validate(data);
// how to determine if validated data is valid
if (validated.valid) {
console.log('Data shall pass.');
} else {
// how to access validated errors
console.dir(validated.errors);
}