Plugin for AJV (v1.6.1) adding draft2019 JSON Schema string formats: iri, iri-reference, idn-email, idn-hostname, and duration. Released regularly, supports cherry-picking formats for smaller bundles. Key differentiator: fills formats AJV core omits; provides internationalized formats for email and hostnames with RFC compliance (RFC 1123 vs older RFC 1034). Supports both patching an AJV instance or passing formats directly to constructor. Lightweight with minimal dependencies.
npm install ajv-formats-draft2019No compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Patches an AJV instance with all draft2019 formats, then validates an international email.
Upgrade AJV to v8 or later, or use an older version of the package if on AJV v6/v7.
Use correct import: import apply from 'ajv-formats-draft2019' and call apply(ajv).
Switch to ESM import syntax: import { formats } from 'ajv-formats-draft2019/formats'.Be aware of the RFC difference; adjust test expectations accordingly.
Import the complete formats object or use the default apply function with options: { formats: ['idn-email'] }.Use const apply = require('ajv-formats-draft2019'); (no destructuring).Ensure apply(ajv) is called before validation, or add format explicitly via options: { formats: ['idn-email'] }.Upgrade to v1.3.0 or later; or use the default export directly.
Verify email conforms to RFC 5321/5322 with international characters; e.g., 'user@domain' is invalid, must have TLD.