1 var Ajv = require('ajv');
2 var ajv = new Ajv({allErrors: true});
6 "foo": { "type": "string" },
7 "bar": { "type": "number", "maximum": 3 }
11 var validate = ajv.compile(schema);
13 test({"foo": "abc", "bar": 2});
14 test({"foo": 2, "bar": 4});
17 var valid = validate(data);
18 if (valid) console.log('Valid!');
19 else console.log('Invalid: ' + ajv.errorsText(validate.errors));