@json-schema-engine/formats
v0.0.3
Published
Format implementations for @json-schema-engine/core's format-assertion vocabulary and assertFormats configuration (DESIGN.md M7)
Readme
@json-schema-engine/formats
Format implementations for @json-schema-engine/core's format-assertion vocabulary and assertFormats configuration — date, date-time, time, duration, email, hostname, ipv4, ipv6, uri, uri-reference, uri-template, iri, iri-reference, json-pointer, relative-json-pointer, regex, uuid, and their per-dialect tables. Add this package when a schema needs format to actually reject bad values rather than only annotate them. Needs @json-schema-engine/core installed alongside.
Install
npm install @json-schema-engine/formats @json-schema-engine/coreExample
import assert from "node:assert";
import { createEngine } from "@json-schema-engine/core";
import { FORMATS_2020_12 } from "@json-schema-engine/formats";
const engine = createEngine({
formats: FORMATS_2020_12,
assertFormats: true,
});
const uri = engine.registerSchema(
{ type: "string", format: "date" },
"https://example.com/date",
);
assert.equal(engine.evaluate(uri, "2024-01-15").valid, true);
assert.equal(engine.evaluate(uri, "not-a-date").valid, false);Status
Version 0.0.1 is published for initial public feedback on both the functionality and the documentation. APIs may change before 1.0. STATUS.md is the authoritative statement of what is built and what is staged.
Documentation
License
MIT
