This is a maintained and JSON specification-compliant fork of the original ajv package.
The fastest JSON validator for Node.js and browser.
Supports JSON Schema draft-04/06/07/2019-09/2020-12 (draft-04 support requires ajv-draft-04 package).
- Ajv-Plus wants to be actively maintained. Support the upcoming JSON Schema specification version too.
- Ajv-Plus wants to be 100% compliant with the standard JSON Specification.
- Benchmarks are available at https://theflashlabs.github.io/ajv-plus/dev/bench/
Thanks to the original author Evgeny Poberezkin and all the contributors of AJV.
Please review Contributing guidelines.
Please sponsor Ajv-Plus development
Your support is very important - the funds will be used to develop and maintain Ajv-Plus.
Please sponsor Ajv-Plus via:
Thank you.
- Ajv implements JSON Schema draft-06/07/2019-09/2020-12 standards (draft-04 is supported in v6):
- all validation keywords (see JSON Schema validation keywords)
- OpenAPI extensions:
- NEW: keyword discriminator.
- keyword nullable.
- full support of remote references (remote schemas have to be added with
addSchemaor compiled to be available) - support of recursive references between schemas
- correct string lengths for strings with unicode pairs
- JSON Schema formats (with ajv-formats plugin).
- validates schemas against meta-schema
- supports browsers and Node.js 10.x - current
- asynchronous loading of referenced schemas during compilation
- "All errors" validation mode with option allErrors
- error messages with parameters describing error reasons to allow error message generation
- i18n error messages support with ajv-i18n package
- removing-additional-properties
- assigning defaults to missing properties and items
- coercing data to the types specified in
typekeywords - user-defined keywords
- additional extension keywords with ajv-keywords package
- $data reference to use values from the validated data as values for the schema keywords
- asynchronous validation of user-defined formats and keywords
To install latest version :
npm install @theflashlabs/ajv-plus
In JavaScript:
// or ESM/TypeScript import
import Ajv from "@theflashlabs/ajv-plus"
// Node.js require:
const Ajv = require("@theflashlabs/ajv-plus")
const ajv = new Ajv() // options can be passed, e.g. {allErrors: true}
const schema = {
type: "object",
properties: {
foo: {type: "integer"},
bar: {type: "string"},
},
required: ["foo"],
additionalProperties: false,
}
const data = {
foo: 2,
bar: "abc",
}
const validate = ajv.compile(schema)
const valid = validate(data)
if (!valid) console.log(validate.errors)See https://github.com/theflashlabs/ajv-plus/releases
Please review and follow the Code of conduct.
