ajv/README.md

41 lines
968 B
Markdown
Raw Normal View History

2015-05-30 01:32:47 +03:00
# ajv - Another JSON schema Validator
2015-05-20 03:55:53 +03:00
2015-05-30 01:22:11 +03:00
## TODO
- refs (internal, remote with addSchema)
- custom formats (via options)
- schema validation before compilation
- bundle compiled templates (doT will be dev dependency)
## Install
```
2015-05-30 01:32:47 +03:00
npm install ajv
2015-05-30 01:22:11 +03:00
```
## Usage
```
2015-05-30 01:32:47 +03:00
var ajv = require('ajv')(options);
var validate = ajv.compile(schema);
2015-05-30 01:22:11 +03:00
var result = validate(data);
```
or
```
2015-05-30 01:32:47 +03:00
var result = ajv.validate(schema, data);
2015-05-30 01:22:11 +03:00
```
Compiles and caches in both cases, 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)
- __unicode__: if false, the lengths of strings with unicode pairs will be incorrect (true by default)