Skip to content

[roadmap] JSON Schema (draft 2020-12) bridge for the validator #2

Description

@Cryptoteep

Goal

The built-in validate() uses a lightweight custom schema format. Many users already have JSON Schema files. We should provide a bridge that converts a (subset of) JSON Schema draft 2020-12 into our internal SchemaNode tree.

Proposed API

import { validate, fromJsonSchema } from 'jsoncraft';
const schema = fromJsonSchema(jsonSchemaDraft2020);
validate(data, schema);

Scope

Support the common keywords: type, required, properties, items, enum, minimum, maximum, minLength, maxLength, pattern, default.

Complex keywords ($ref, oneOf, allOf, conditional subschemas) can come later.

Acceptance

  • fromJsonSchema() converts a draft-2020-12 schema into SchemaNode
  • Round-trip validation matches the behavior of Ajv for the supported subset

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions