Chai plugin for JSON Schema validation using Ajv. Current stable version is 5.2.4, released in mid-2020 with support for Ajv >=4 and JSON Schema drafts 4, 6, and 7. It provides fluent chai assertions (jsonSchema, validJsonSchema) for both data validation and schema validation. Unlike chai-json-schema (which uses tv4), this plugin uses Ajv for better performance and compliance. The library exposes a .create() method for custom Ajv options. Maintenance mode since v5, with no active development.
npm install chai-json-schema-ajvNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates basic usage of jsonSchema and validJsonSchema chai assertions for data and schema validation.
Update test assertions to match new default error messages from Ajv.errorsText().
Install Ajv v7: npm install ajv@7 --save-dev
Ensure Ajv is installed: npm install ajv --save-dev
Always provide an options object, even if empty: chai.use(require('chai-json-schema-ajv').create({}))Use it without parentheses: expect(schema).to.be.validJsonSchema;
Install Ajv v7: npm install ajv@7. If using ESM, use import Ajv from 'ajv'.
Validate the schema against JSON Schema meta-schema, or use .validJsonSchema assertion to check it first.
Ensure chai is installed: npm install chai. Use chai.use(require('chai-json-schema-ajv')) exactly.Install Ajv: npm install ajv --save-dev