$ npm install ajv
Super fast JSON validator for Node.js and browser.
Supports JSON Schema draft-06/07/2019-09/2020-12 (draft-04 is supported in version 6) and JSON Type Definition RFC8927.
Ajv version 7 has these new features:
unevaluatedProperties
and unevaluatedItems
, dynamic recursive references and other additional keywords.Please note:
See release notes for the details.
To install the new version:
npm install ajv
See Getting started for code example.
More than 100 people contributed to Ajv, and we would love to have you join the development. We welcome implementing new features that will benefit many users and ideas to improve our documentation.
At Ajv, we are committed to creating more equitable and inclusive spaces for our community and team members to contribute to discussions that affect both this project and our ongoing work in the open source ecosystem.
We strive to create an environment of respect and healthy discourse by setting standards for our interactions and we expect it from all members of our community - from long term project member to first time visitor. For more information, review our code of conduct and values.
<Contributors />We value conscious curation of our library size, and balancing performance and functionality. To that end, we cannot accept every suggestion. When evaluating pull requests we consider:
To help us evaluate and understand, when you submit an issue and pull request:
Please include documentation and test coverage with any new feature implementations.
To run tests:
npm install
git submodule update --init
npm test
npm run build
- compiles typescript to dist
folder.
Please also review Contributing guidelines and Code components.
Ajv has been awarded a grant from Mozilla’s Open Source Support (MOSS) program in the “Foundational Technology” track! It will sponsor the development of Ajv support of JSON Schema version 2019-09 and of JSON Type Definition (RFC8927).
Ajv also joined OpenJS Foundation – having this support will help ensure the longevity and stability of Ajv for all its users.
This blog post has more details.
I am looking for the long term maintainers of Ajv – working with ReadySet, also sponsored by Mozilla, to establish clear guidelines for the role of a "maintainer" and the contribution standards, and to encourage a wider, more inclusive, contribution from the community.
Since I asked to support Ajv development 40 people and 6 organizations contributed via GitHub and OpenCollective - this support helped receiving the MOSS grant!
Your continuing support is very important - the funds will be used to develop and maintain Ajv once the next major version is released.
Please sponsor Ajv via:
Thank you.
Ajv generates code to turn JSON Schemas into super-fast validation functions that are efficient for v8 optimization.
Currently Ajv is the fastest and the most standard compliant validator according to these benchmarks:
Performance of different validators by json-schema-benchmark:
addSchema
or compiled to be available)type
keywordsconst
, contains
, propertyNames
and if/then/else
true
/false
as a schema to always pass/fail).To install version 7:
npm install ajv
Try it in the Node.js REPL: https://runkit.com/npm/ajv
In JavaScript:
// or ESM/TypeScript import
import Ajv from "ajv"
// Node.js require:
const Ajv = require("ajv")
const ajv = new Ajv() // options can be passed, e.g. {allErrors: true}
const validate = ajv.compile(schema)
const valid = validate(data)
if (!valid) console.log(validate.errors)
See more examples in Guide: getting started
See section in data validation and the detailed guide.
Ajv can be extended with plugins that add keywords, formats or functions to process generated code. When such plugin is published as npm package it is recommended that it follows these conventions:
You can import Plugin
interface from ajv if you use Typescript.
If you have published a useful plugin please submit a PR to add it to the next section.
idn-hostname
, idn-email
, iri
, iri-reference
and duration
)See https://github.com/ajv-validator/ajv/releases
Please note: Changes in version 7.0.0
Please review and follow the Code of conduct.
Please report any unacceptable behaviour to ajv.validator@gmail.com - it will be reviewed by the project team.
To report a security vulnerability, please use the Tidelift security contact. Tidelift will coordinate the fix and disclosure. Please do NOT report security vulnerabilities via GitHub issues.
Ajv is a part of Tidelift subscription - it provides a centralised support to open-source software users, in addition to the support provided by software maintainers.
© 2010 - cnpmjs.org x YWFE | Home | YWFE