Extends Ajv (v8.5+) to support JSON Schema draft-04 validation. Version 1.0.0 is the first stable release. Maintained by the Ajv team, it is the recommended way to validate draft-04 schemas with Ajv v8. It seamlessly integrates with Ajv's API and options, enabling strict mode, custom keywords, and formats. Unlike the older ajv v6, which natively supported draft-04, this package allows using the latest Ajv with legacy schemas. Ships TypeScript definitions.
npm install ajv-draft-04No compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows how to create an Ajv instance for draft-04, add format support, compile a schema, and validate data.
Use dynamic import() or set type: 'module' in package.json if using Node <12.22.
Ensure enum values exactly match the data; draft-04 does not coerce.
Use 'id' as the schema identifier; '$id' is for draft-06+.
Use exclusiveMinimum: true combined with minimum: 5, not exclusiveMinimum: 5.
Use 'import Ajv from "ajv-draft-04"' (default import).
Add '"type": "module"' to package.json or use require('ajv-draft-04').Replace '$id' with 'id' in your schema.
Remove additionalProperties or explicitly define properties.