JSON Schema validation in Node.js core
まだ誰も着手していません。
- 主要言語
- JavaScript
- スター
- 122k
- フォーク
- 37.3k
- 平均マージ
- 4日 2時間
- マージ済み PR(30日)
- 283
説明
What is the problem this feature will solve?
Hi all,
I wanted to open a discussion about whether JSON Schema validation could be a useful addition to Node.js core.
Current state
- Node.js currently has no built-in JSON Schema validation
node.config.json(experimental) uses hand-written type checking against a JSON Schema 2020-12 definition generated from C++ option metadatapackage.jsonparsing uses simdjson but has no schema validation, fields are extracted structurally- The only schema validation in the Node.js tree lives inside
deps/npm(Ajv)
Potential use cases
- Validate
node.config.jsonagainst its own schema properly - Future validation for
package.jsonfields (opt-in, non-breaking) - Expose as a built-in module (
node:jsonschema) so userland doesn't need to pull in external validators
Context
I've been working on a project in this area, ata-validator, a JSON Schema validator built on simdjson and RE2. It currently passes 96.9% of the official JSON Schema Test Suite (Draft 2020-12) and falls back to a pure JS engine when native bindings aren't available.
I'm not proposing to land it as-is, I'd love to hear from the group first:
- Is there interest in having JSON Schema validation available in core?
- What would be the most useful entry point? (config validation, public API, both?)
- Any concerns about the dependency story? (RE2/abseil weight, simdjson already in core)
Happy to share benchmarks or more details if this sounds worth exploring.
fyi @Qard
What is the feature you are proposing to solve the problem?
A built-in JSON Schema validator, potentially exposed as node:jsonschema, that could also be used internally for validating node.config.json and other configuration files.
This would provide Node.js users with a fast, native JSON Schema (Draft 2020-12) validation capability without needing external dependencies.
What alternatives have you considered?
-
Continuing with hand-written validation for each config format individually,
doesn't scale as more config formats are added -
Bundling an existing JS-based validator like Ajv into core, lacks native performance benefits
-
Leaving JSON Schema validation entirely to userland
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、node.config.json の検証パス、C++ オプションメタデータから作成される JSON Schema 2020-12 の定義、そして deps/npm 内のスキーマ検証コードを読みます。提案されている node:jsonschema、config-validation、package.json のエントリポイントを、既存の Ajv の使用方法と比較します。実装を定義できる状態になる前に、合意されたスコープと依存関係戦略が決まっていることを完了条件とします。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- javascript, node.js
- 領域
- backend
- issue の種類
- 機能追加
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 活発さ
- 静か
- 明瞭さ
- 説明が足りない
- 初心者へのやさしさ
- 25/100