Fork of ajv
 
 
 
 
Go to file
Evgeny Poberezkin 46cf5f9930 optimized required keyword 2015-05-31 02:01:30 +01:00
JSON-Schema-Test-Suite@d319afab25 "type" rule passes all tests 2015-05-26 02:11:55 +01:00
lib optimized required keyword 2015-05-31 02:01:30 +01:00
spec refactored rules iteration to optimize code 2015-05-30 23:04:46 +01:00
.gitignore inline simple rules 2015-05-30 09:53:04 +01:00
.gitmodules "type" rule passes all tests 2015-05-26 02:11:55 +01:00
LICENSE Initial commit 2015-05-20 00:23:32 +01:00
README.md optimized required keyword 2015-05-31 02:01:30 +01:00
package.json optimized required keyword 2015-05-31 02:01:30 +01:00
try.js inline simple rules 2015-05-30 09:53:04 +01:00

README.md

ajv - Another JSON schema Validator

TODO

  • remote refs
  • custom formats (via options)
  • schema validation before compilation
  • bundle compiled templates (doT will be dev dependency)
  • unicode option

Install

npm install ajv

Usage

var ajv = require('ajv')(options);
var validate = ajv.compile(schema);
var valid = validate(data);
if (!valid) console.log(validate.errors);

or

// ...
var valid = ajv.validate(schema, data);
// ...

ajv compiles schemas to functions and caches them in both cases (using stringified schema as a key - using json-stable-stringify), so that the next time the same schema is used (not necessarily the same object instance) it won't be compiled again.

Options

  • allErrors: if true, jv will continue validating all rules collecting all errors (false by default)
  • verbose: include the reference to the validated data in the errors (false by default)
  • format: if false, the formats won't be validated (true by default)
  • uniqueItems: if false, uniqueItems keyword will be ignored (true by default)
  • unicode: if true, the lengths of strings with unicode pairs will be correct (false by default) - not implemented yet.