Skip to content

Expose JSON Schema validation as a public API #62937

@mertcanaltin

Description

@mertcanaltin

What is the problem this feature will solve?

PR #62603 is vendoring ata-validator into Node.js core for node.config.json validation. During that review, @TheOneTheOnlyJJ and @H4ad both asked whether ata could be exposed to user code once it's vendored in.

Every project that needs JSON Schema validation today pulls in a third-party dependency. If Node is already shipping a validator internally, it feels odd not to let user code reach it.

Opening this to check if the direction is something the project wants to pursue, and to collect thoughts on naming and scope before anyone writes a prototype PR.

What is the feature you are proposing to solve the problem?

Expose ata as a built-in node: module, using the same runtime that #62603 is vendoring.

Three names came up in discussion:

  • node:schema, focused on JSON Schema
  • node:jsonschema, more specific
  • node:json, wider, covering parse and validate together (ata already vendors simdjson)

Rough sketch:

import { Validator } from 'node:schema'

const v = new Validator({
  type: 'object',
  properties: { id: { type: 'integer' } },
  required: ['id'],
})

v.validate({ id: 1 }) // { valid: true, errors: [] }

Would probably land this behind an experimental flag first, the way node:test started. Happy to put together a prototype PR if the direction is one the project wants to pursue.

What alternatives have you considered?

  1. Keep the vendor scoped to node.config.json only (current deps: add ata JSON Schema validator for node.config.json #62603 plan). Downside: Node ships a validator user code can't reach.

  2. Schema-only module (node:schema / node:jsonschema). Narrow scope, leaves simdjson for another issue.

  3. Combined node:json module. Covers parse and validate together, bigger API surface.

  4. Third-party package that depends on Node internals. Ruled out, defeats the point of vendoring.

No strong preference between 2 and 3. Would rather hear from the Node collaborators and folks who already commented on #62603 before picking.

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature requestIssues that request new features to be added to Node.js.

    Type

    No type

    Projects

    Status

    Awaiting Triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions