@alexify/metaschema 3.0.0 → 3.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/CHANGELOG.md +312 -1
  2. package/README.md +463 -17
  3. package/SECURITY.md +26 -7
  4. package/index.d.ts +338 -3
  5. package/package.json +42 -5
  6. package/src/codec.js +161 -73
  7. package/src/compile/code.js +1 -1
  8. package/src/compile/emit.js +60 -7
  9. package/src/compile/index.d.ts +6 -0
  10. package/src/compile/index.js +14 -3
  11. package/src/context.js +8 -9
  12. package/src/errors.js +18 -1
  13. package/src/formats/index.d.ts +19 -0
  14. package/src/formats/index.js +146 -0
  15. package/src/generators/fromjsonschema.js +517 -0
  16. package/src/generators/index.d.ts +19 -2
  17. package/src/generators/index.js +16 -10
  18. package/src/generators/jsonschema.js +2 -0
  19. package/src/issues.js +37 -20
  20. package/src/lint.js +12 -3
  21. package/src/locales/en.js +11 -2
  22. package/src/locales/uk.js +10 -2
  23. package/src/metadata.js +3 -2
  24. package/src/model/data.js +122 -0
  25. package/src/model/diff.js +439 -0
  26. package/src/model/index.d.ts +68 -0
  27. package/src/model/index.js +45 -0
  28. package/src/model/infer.js +483 -0
  29. package/src/model/merge.js +255 -0
  30. package/src/model/pattern.js +322 -0
  31. package/src/model/restore.js +226 -0
  32. package/src/model/sample.js +398 -0
  33. package/src/model.js +13 -1
  34. package/src/preprocessor.js +5 -1
  35. package/src/prototypes/collections.js +4 -3
  36. package/src/prototypes/scalars.js +4 -4
  37. package/src/prototypes/schema.js +6 -5
  38. package/src/prototypes/union.js +2 -2
  39. package/src/result.js +6 -0
  40. package/src/rules.js +53 -4
  41. package/src/schema.js +28 -7
  42. package/src/snapshot.js +111 -0
  43. package/src/stream/index.d.ts +68 -0
  44. package/src/stream/index.js +247 -0
  45. package/src/struct.js +64 -18
  46. package/src/types.js +14 -1
  47. package/src/util.js +18 -0
package/README.md CHANGED
@@ -7,9 +7,10 @@
7
7
  [![docs](https://img.shields.io/badge/docs-online-blue)](https://metaschema.vercel.app/)
8
8
  [![license](https://img.shields.io/npm/l/%40alexify%2Fmetaschema)](./LICENSE)
9
9
 
10
- **Metadata schema and interface definition language for JavaScript.** Declare data structures and
11
- domain models once as plain objects, validate data against them, and generate TypeScript
12
- interfaces. Zero dependencies, Node.js and browsers.
10
+ **Fast, zero-dependency metadata schema and interface definition language for JavaScript.**
11
+ Declare data structures and domain models once as plain objects; validate and parse data against
12
+ them at tens of millions of checks a second, with every problem returned as data; and generate
13
+ TypeScript types and JSON Schema from the same definitions. Node.js and browsers.
13
14
 
14
15
  ```js
15
16
  const { Schema } = require('@alexify/metaschema');
@@ -61,6 +62,15 @@ event.parse({ name: 'deploy', when: '2026-10-10T12:00:00.000Z' }).value;
61
62
  defaults filled in, unknown keys stripped on request, a field's `parse` function decoding its
62
63
  value (a date-time string into a `Date`) and `serialize` the way back; `checkAsync` and
63
64
  `parseAsync` await validators and decoders that return promises.
65
+ - **String formats.** `{ type: 'string', format: 'email' }` is a rule beside `length` and
66
+ `pattern`; `@alexify/metaschema/formats` registers `uuid`, `email`, `date-time`, `date`,
67
+ `time`, `ipv4`, `ipv6`, `uri`, `hostname` and your own, and the name travels into JSON Schema,
68
+ samples and inference.
69
+ - **Records and streams.** `checkEach` and `parseEach` of `@alexify/metaschema/stream` run a
70
+ schema over an iterable of records, lazily and in order, yielding `{ index, record, result }`
71
+ for each; the async pair keeps `concurrency` records in flight over a sync or async source,
72
+ and `transform` is a `TransformStream` that lets the valid records through and reports the
73
+ others.
64
74
  - **Domain models.** Entities, registries, dictionaries and projections, with references,
65
75
  relations and indexes, ordered by dependency and checked for missing references.
66
76
  - **TypeScript.** `InferSchema<typeof schema>` is the type of a value the schema accepts,
@@ -77,11 +87,367 @@ event.parse({ name: 'deploy', when: '2026-10-10T12:00:00.000Z' }).value;
77
87
  - **Fast.** Every check is compiled into a closure when the schema is built and runs in a context
78
88
  of its own: about 10 million validations a second of a flat struct on Node 24, and about 30
79
89
  million through the JIT backend of `@alexify/metaschema/compile`, which generates the same
80
- check where `new Function` is allowed and keeps the closures where it is not (`pnpm bench`,
81
- see [Performance](https://metaschema.vercel.app/guide/performance)).
82
- - **Zero dependencies, 16.1 KB min+gzip.** CommonJS with ESM named imports, no build step,
83
- one package for Node.js and browsers; the generators add 4.5 KB and the JIT backend 3.9 KB
84
- where they are imported.
90
+ check where `new Function` is allowed and keeps the closures where it is not. Against ten other
91
+ validators see [Benchmarks](#benchmarks); how the core gets there is on the
92
+ [Performance](https://metaschema.vercel.app/guide/performance) page.
93
+ - **The model as data.** `model.toJSON()` is a snapshot other programs read the model through
94
+ (a migration tool, an introspecting service, a committed baseline), and
95
+ `@alexify/metaschema/model` tells two versions apart (`diff`), classifies the change by the
96
+ Confluent rules (`compatibility`), draws a value every schema accepts (`sample`), unifies two
97
+ schemas (`merge`) and infers a definition from the values that exist (`infer`); `aliases` and
98
+ `deprecated` let a model carry its history, and `fromJSONSchema` of the generators reads a
99
+ JSON Schema document back.
100
+ - **Zero dependencies, 17.7 KB min+gzip.** CommonJS with ESM named imports, no build step,
101
+ one package for Node.js and browsers; the generators add 7.1 KB, the JIT backend 4.2 KB, the
102
+ model tools 12.0 KB, the record tools 1.0 KB and the string formats 1.3 KB where they are
103
+ imported.
104
+
105
+ ## Benchmarks
106
+
107
+ metaschema on its two backends beside Metarhia's metaschema, Zod, Valibot, ArkType, Effect
108
+ Schema, TypeBox, Ajv, Yup, Joi and Superstruct: the object of the moltar suite in its four modes,
109
+ every issue of an invalid value and building a schema, each library in a fresh process and
110
+ checked for the right verdicts before it is timed. On the JIT metaschema validates 30 to 48
111
+ million objects a second, and in the strict modes (unknown keys rejected) only TypeBox's compiler
112
+ is faster; on its closures, with no `eval` at all, 4.6 to 9.8 million, ahead of every
113
+ interpreter in the set. Asked for every issue of an invalid value with its path, it is second
114
+ only to Ajv, and 6 to 100 times faster than the other TypeScript-first validators; a cold start
115
+ (load, build, first check) takes 5.7 ms.
116
+
117
+ <!-- bench:compare:start -->
118
+ <!-- generated by `pnpm bench:report` from bench/results — edit the results, not this block -->
119
+
120
+ <img src="https://metaschema.vercel.app/benchmarks/compare-nested-parseStrict.svg" alt="Nested object, parseStrict: A valid object of 6 fields and a nested object of 3. parseStrict: unknown keys rejected, the value returned. ops/s, log scale, higher is better." width="760" />
121
+
122
+ <details>
123
+ <summary>9 more scenarios</summary>
124
+
125
+ <img src="https://metaschema.vercel.app/benchmarks/compare-flat-parseSafe.svg" alt="Flat object, parseSafe: A valid object of 6 fields. parseSafe: unknown keys allowed, the value returned. ops/s, log scale, higher is better. Not shown, the mode cannot be expressed: Metarhia metaschema." width="760" />
126
+
127
+ <img src="https://metaschema.vercel.app/benchmarks/compare-flat-parseStrict.svg" alt="Flat object, parseStrict: A valid object of 6 fields. parseStrict: unknown keys rejected, the value returned. ops/s, log scale, higher is better." width="760" />
128
+
129
+ <img src="https://metaschema.vercel.app/benchmarks/compare-flat-assertLoose.svg" alt="Flat object, assertLoose: A valid object of 6 fields. assertLoose: unknown keys allowed, the verdict only. ops/s, log scale, higher is better. Not shown, the mode cannot be expressed: Metarhia metaschema." width="760" />
130
+
131
+ <img src="https://metaschema.vercel.app/benchmarks/compare-flat-assertStrict.svg" alt="Flat object, assertStrict: A valid object of 6 fields. assertStrict: unknown keys rejected, the verdict only. ops/s, log scale, higher is better." width="760" />
132
+
133
+ <img src="https://metaschema.vercel.app/benchmarks/compare-nested-parseSafe.svg" alt="Nested object, parseSafe: A valid object of 6 fields and a nested object of 3. parseSafe: unknown keys allowed, the value returned. ops/s, log scale, higher is better. Not shown, the mode cannot be expressed: Metarhia metaschema." width="760" />
134
+
135
+ <img src="https://metaschema.vercel.app/benchmarks/compare-nested-assertLoose.svg" alt="Nested object, assertLoose: A valid object of 6 fields and a nested object of 3. assertLoose: unknown keys allowed, the verdict only. ops/s, log scale, higher is better. Not shown, the mode cannot be expressed: Metarhia metaschema." width="760" />
136
+
137
+ <img src="https://metaschema.vercel.app/benchmarks/compare-nested-assertStrict.svg" alt="Nested object, assertStrict: A valid object of 6 fields and a nested object of 3. assertStrict: unknown keys rejected, the verdict only. ops/s, log scale, higher is better." width="760" />
138
+
139
+ <img src="https://metaschema.vercel.app/benchmarks/compare-invalid.svg" alt="Every issue of an invalid value: The nested object with four wrong fields, unknown keys rejected; every issue collected with its path. ops/s, log scale, higher is better." width="760" />
140
+
141
+ <img src="https://metaschema.vercel.app/benchmarks/compare-build.svg" alt="Build a schema: The strict nested schema built from its definition, ready to check. schemas/s, log scale, higher is better." width="760" />
142
+
143
+ </details>
144
+
145
+ | Library | Flat object, parseSafe<br><sub>ops/s</sub> | Flat object, parseStrict<br><sub>ops/s</sub> | Flat object, assertLoose<br><sub>ops/s</sub> | Flat object, assertStrict<br><sub>ops/s</sub> | Nested object, parseSafe<br><sub>ops/s</sub> | Nested object, parseStrict<br><sub>ops/s</sub> | Nested object, assertLoose<br><sub>ops/s</sub> | Nested object, assertStrict<br><sub>ops/s</sub> | Every issue of an invalid value<br><sub>ops/s</sub> | Build a schema<br><sub>schemas/s</sub> |
146
+ | --- | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: |
147
+ | **metaschema**<br><sub>check() · compile(), JIT · v3.2.0</sub> | 47,400,000 | 38,800,000 | 48,400,000 | 40,200,000 | 41,500,000 | 29,500,000 | 43,700,000 | 30,200,000 | 6,600,000 | 32,300 |
148
+ | **metaschema**<br><sub>check() · closures · v3.2.0</sub> | 9,690,000 | 8,670,000 | 9,820,000 | 8,980,000 | 4,950,000 | 4,660,000 | 4,980,000 | 4,640,000 | 3,120,000 | 201,000 |
149
+ | Metarhia metaschema<br><sub>check() · strict only · v2.2.2</sub> | — | 925,000 | — | 931,000 | — | 534,000 | — | 538,000 | 420,000 | 283,000 |
150
+ | Zod<br><sub>safeParse() · v4.6.6</sub> | 26,800,000 | 12,300,000 | 27,100,000 | 12,800,000 | 16,700,000 | 7,200,000 | 16,600,000 | 7,170,000 | 447,000 | 80,600 |
151
+ | Valibot<br><sub>safeParse() · is() · v1.5.0</sub> | 3,440,000 | 2,940,000 | 3,570,000 | 2,910,000 | 2,070,000 | 1,740,000 | 2,030,000 | 1,770,000 | 1,130,000 | 2,070,000 |
152
+ | ArkType<br><sub>type(value) · allows() · v2.2.8</sub> | 49,700,000 | 7,270,000 | 169,000,000 | 8,560,000 | 37,600,000 | 4,220,000 | 131,000,000 | 4,730,000 | 67,100 | 14,700 |
153
+ | Effect Schema<br><sub>decodeUnknownResult() · is() · v4.0.3</sub> | 4,040,000 | 1,930,000 | 4,080,000 | 1,910,000 | 2,270,000 | 993,000 | 2,240,000 | 1,000,000 | 367,000 | 675,000 |
154
+ | TypeBox<br><sub>Compile(…).Check() · v1.3.36</sub> | 164,000,000 | 78,200,000 | 186,000,000 | 81,700,000 | 119,000,000 | 42,700,000 | 136,000,000 | 43,600,000 | 90,900 | 36,300 |
155
+ | TypeBox<br><sub>Value.Check() · v1.3.36</sub> | 258,000 | 190,000 | 261,000 | 188,000 | 166,000 | 116,000 | 166,000 | 117,000 | 90,600 | 429,000 |
156
+ | Ajv<br><sub>compile(…)(value), draft 2020-12 · v8.20.0</sub> | 64,600,000 | 34,100,000 | 69,900,000 | 35,100,000 | 50,700,000 | 23,200,000 | 54,800,000 | 23,900,000 | 14,800,000 | 1,820 |
157
+ | Yup<br><sub>validateSync() · isValidSync(), strict · v1.7.1</sub> | 301,000 | 291,000 | 305,000 | 291,000 | 181,000 | 172,000 | 182,000 | 173,000 | 11,500 | 54,600 |
158
+ | Joi<br><sub>validate(), convert: false · v18.2.9</sub> | 819,000 | 834,000 | 796,000 | 830,000 | 528,000 | 529,000 | 520,000 | 532,000 | 258,000 | 38,600 |
159
+ | Superstruct<br><sub>validate() · is() · v2.0.2</sub> | 480,000 | 436,000 | 486,000 | 431,000 | 293,000 | 260,000 | 298,000 | 260,000 | 102,000 | 1,810,000 |
160
+
161
+ _Apple M3 Max · 16 cores · Node v24.14.1 · median of 5 × 1 s samples, each library in a fresh process · 2026-10-11. Medians, rounded to three significant figures; — where the library cannot express the mode._
162
+
163
+ <!-- bench:compare:end -->
164
+
165
+ How to read these numbers and the method behind them are on the
166
+ [Benchmarks](https://metaschema.vercel.app/guide/benchmarks) page, where the charts are
167
+ interactive.
168
+
169
+ ### Cold start
170
+
171
+ <!-- bench:coldstart:start -->
172
+ <!-- generated by `pnpm bench:report` from bench/results — edit the results, not this block -->
173
+
174
+ <img src="https://metaschema.vercel.app/benchmarks/coldstart.svg" alt="Cold start: Load the library, build the strict nested schema, check one value: a fresh process, median of 20 runs. Lower is better." width="760" />
175
+
176
+ | Library | Load | Build | First check | Total |
177
+ | --- | ---: | ---: | ---: | ---: |
178
+ | Superstruct<br><sub>validate() · is() · v2.0.2</sub> | 0.8 ms | 0.2 ms | 0.3 ms | 1.3 ms |
179
+ | Valibot<br><sub>safeParse() · is() · v1.5.0</sub> | 3.7 ms | 0.1 ms | 0.1 ms | 4.0 ms |
180
+ | Yup<br><sub>validateSync() · isValidSync(), strict · v1.7.1</sub> | 2.5 ms | 1.1 ms | 0.7 ms | 4.2 ms |
181
+ | **metaschema**<br><sub>check() · closures · v3.2.0</sub> | 4.7 ms | 0.9 ms | 0.1 ms | 5.7 ms |
182
+ | **metaschema**<br><sub>check() · compile(), JIT · v3.2.0</sub> | 5.7 ms | 1.6 ms | 0.2 ms | 7.6 ms |
183
+ | Metarhia metaschema<br><sub>check() · strict only · v2.2.2</sub> | 20.7 ms | 0.6 ms | 0.2 ms | 21.5 ms |
184
+ | Joi<br><sub>validate(), convert: false · v18.2.9</sub> | 23.3 ms | 1.2 ms | 0.6 ms | 25.1 ms |
185
+ | Zod<br><sub>safeParse() · v4.6.6</sub> | 27.7 ms | 1.4 ms | 1.2 ms | 30.3 ms |
186
+ | Ajv<br><sub>compile(…)(value), draft 2020-12 · v8.20.0</sub> | 14.7 ms | 23.9 ms | 0.2 ms | 38.7 ms |
187
+ | Effect Schema<br><sub>decodeUnknownResult() · is() · v4.0.3</sub> | 71.0 ms | 0.2 ms | 0.8 ms | 72.0 ms |
188
+ | TypeBox<br><sub>Value.Check() · v1.3.36</sub> | 94.7 ms | 0.1 ms | 1.0 ms | 95.9 ms |
189
+ | TypeBox<br><sub>Compile(…).Check() · v1.3.36</sub> | 94.8 ms | 1.9 ms | 0.0 ms | 96.7 ms |
190
+ | ArkType<br><sub>type(value) · allows() · v2.2.8</sub> | 105.9 ms | 1.4 ms | 0.1 ms | 107.3 ms |
191
+
192
+ <!-- bench:coldstart:end -->
193
+
194
+ ### Bundle size
195
+
196
+ <!-- bench:size:start -->
197
+ <!-- generated by `pnpm bench:report` from bench/results — edit the results, not this block -->
198
+
199
+ <img src="https://metaschema.vercel.app/benchmarks/size.svg" alt="Bundle size: A browser bundle that builds the strict nested schema and checks a value (esbuild, minified, tree-shaken), min+gzip. Lower is better." width="760" />
200
+
201
+ | Library | min | min+gzip | |
202
+ | --- | ---: | ---: | --- |
203
+ | Valibot<br><sub>safeParse() · is() · v1.5.0</sub> | 3.3 KB | 1.2 KB | |
204
+ | Superstruct<br><sub>validate() · is() · v2.0.2</sub> | 3.5 KB | 1.5 KB | |
205
+ | Metarhia metaschema<br><sub>check() · strict only · v2.2.2</sub> | 30.0 KB | 11.0 KB | minified with keepNames: its checks compare constructor names |
206
+ | Yup<br><sub>validateSync() · isValidSync(), strict · v1.7.1</sub> | 41.4 KB | 13.2 KB | |
207
+ | **metaschema**<br><sub>check() · closures · v3.2.0</sub> | 49.9 KB | 18.0 KB | |
208
+ | **metaschema**<br><sub>check() · compile(), JIT · v3.2.0</sub> | 62.5 KB | 22.2 KB | |
209
+ | Effect Schema<br><sub>decodeUnknownResult() · is() · v4.0.3</sub> | 72.9 KB | 24.4 KB | |
210
+ | Zod<br><sub>safeParse() · v4.6.6</sub> | 88.4 KB | 25.7 KB | |
211
+ | TypeBox<br><sub>Value.Check() · v1.3.36</sub> | 146.7 KB | 37.5 KB | |
212
+ | Ajv<br><sub>compile(…)(value), draft 2020-12 · v8.20.0</sub> | 130.9 KB | 39.5 KB | |
213
+ | TypeBox<br><sub>Compile(…).Check() · v1.3.36</sub> | 161.5 KB | 40.8 KB | |
214
+ | ArkType<br><sub>type(value) · allows() · v2.2.8</sub> | 151.9 KB | 46.4 KB | |
215
+ | Joi<br><sub>validate(), convert: false · v18.2.9</sub> | 169.5 KB | 53.3 KB | |
216
+
217
+ <!-- bench:size:end -->
218
+
219
+ ### Release over release
220
+
221
+ <!-- bench:releases:start -->
222
+ <!-- generated by `pnpm bench:report` from bench/results — edit the results, not this block -->
223
+
224
+ <img src="https://metaschema.vercel.app/benchmarks/speedup.svg" alt="metaschema 3.2.0 against Metarhia's metaschema 2.2.2: How many times faster, scenario by scenario (1 = as fast). Higher is better." width="760" />
225
+
226
+ <details>
227
+ <summary>Every release, scenario by scenario</summary>
228
+
229
+ <img src="https://metaschema.vercel.app/benchmarks/releases-nested-valid.svg" alt="check — nested struct, valid, release over release: ops/s, linear scale, higher is better. The same harness and machine for every release." width="760" />
230
+
231
+ <img src="https://metaschema.vercel.app/benchmarks/releases-from-flat.svg" alt="Schema.from — flat struct, release over release: schemas/s, linear scale, higher is better. The same harness and machine for every release." width="760" />
232
+
233
+ <img src="https://metaschema.vercel.app/benchmarks/releases-from-nested.svg" alt="Schema.from — nested struct, release over release: schemas/s, linear scale, higher is better. The same harness and machine for every release." width="760" />
234
+
235
+ <img src="https://metaschema.vercel.app/benchmarks/releases-flat-valid.svg" alt="check — flat struct, valid, release over release: ops/s, linear scale, higher is better. The same harness and machine for every release." width="760" />
236
+
237
+ <img src="https://metaschema.vercel.app/benchmarks/releases-flat-invalid.svg" alt="check — flat struct, invalid, release over release: ops/s, linear scale, higher is better. The same harness and machine for every release." width="760" />
238
+
239
+ <img src="https://metaschema.vercel.app/benchmarks/releases-nested-invalid.svg" alt="check — nested struct, invalid, release over release: ops/s, linear scale, higher is better. The same harness and machine for every release." width="760" />
240
+
241
+ </details>
242
+
243
+ | Scenario | Metarhia 2.2.2 | 1.0.0 | 2.0.0 | 3.0.0 | 3.0.0<br><sub>JIT</sub> | 3.1.0 | 3.1.0<br><sub>JIT</sub> | 3.2.0 | 3.2.0<br><sub>JIT</sub> |
244
+ | --- | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: |
245
+ | Schema.from — flat struct | 581,000 | 321,000 | 362,000 | 372,000 | — | 367,000 | — | 356,000 | — |
246
+ | Schema.from — nested struct | 156,000 | 95,600 | 104,000 | 99,000 | — | 98,400 | — | 98,600 | — |
247
+ | check — flat struct, valid | 1,440,000 | 2,180,000 | 10,800,000 | 10,700,000 | 38,600,000 | 11,700,000 | 37,900,000 | 11,600,000 | 37,900,000 |
248
+ | check — flat struct, invalid | 1,010,000 | 1,110,000 | 4,020,000 | 3,940,000 | 6,130,000 | 3,880,000 | 6,170,000 | 3,900,000 | 6,160,000 |
249
+ | check — nested struct, valid | 238,000 | 368,000 | 2,950,000 | 2,930,000 | 19,700,000 | 2,920,000 | 19,600,000 | 2,910,000 | 19,700,000 |
250
+ | check — nested struct, invalid | 222,000 | 300,000 | 1,570,000 | 1,580,000 | 2,140,000 | 1,570,000 | 2,110,000 | 1,570,000 | 2,110,000 |
251
+
252
+ _Apple M3 Max · 16 cores · Node v24.14.1 · median of 5 × 1 s samples, each release in a fresh process · 2026-10-11. ops/s (schemas/s for `Schema.from`), medians._
253
+
254
+ <!-- bench:releases:end -->
255
+
256
+ ### metaschema on its two backends
257
+
258
+ <!-- bench:engine:start -->
259
+ <!-- generated by `pnpm bench:report` from bench/results — edit the results, not this block -->
260
+
261
+ <img src="https://metaschema.vercel.app/benchmarks/engine.svg" alt="metaschema on its two backends: pnpm bench: ops/s, log scale, higher is better." width="760" />
262
+
263
+ <!-- bench:engine:end -->
264
+
265
+ ## Compared with alternatives
266
+
267
+ metaschema against twenty alternatives in four directions: TypeScript-first validators, JSON
268
+ Schema validators and compilers, interface definition languages built for schema evolution, and
269
+ an ODM. Every cell was checked against the source of the published package (October 2026), not
270
+ its README; the [comparison page](https://metaschema.vercel.app/guide/comparison) has the method,
271
+ what the table shows and where each library fits, in a table you can scroll with the features
272
+ pinned.
273
+
274
+ <!-- comparison:start -->
275
+ <!-- generated by `pnpm docs:comparison` from docs/comparison.json — edit the data, not this block -->
276
+
277
+ <div class="ms-matrix">
278
+
279
+ <table>
280
+ <thead>
281
+ <tr>
282
+ <th>Feature</th>
283
+ <th><a href="https://github.com/Alexis-Technologies/metaschema">metaschema</a><br><sub>schemas + IDL</sub></th>
284
+ <th><a href="https://github.com/metarhia/metaschema">Metarhia metaschema</a><br><sub>IDL, the original</sub></th>
285
+ <th><a href="https://github.com/colinhacks/zod">Zod</a><br><sub>TS-first</sub></th>
286
+ <th><a href="https://github.com/open-circle/valibot">Valibot</a><br><sub>TS-first</sub></th>
287
+ <th><a href="https://github.com/arktypeio/arktype">ArkType</a><br><sub>TS-first</sub></th>
288
+ <th><a href="https://github.com/Effect-TS/effect">Effect Schema</a><br><sub>TS-first</sub></th>
289
+ <th><a href="https://github.com/ianstormtaylor/superstruct">Superstruct</a><br><sub>TS-first</sub></th>
290
+ <th><a href="https://github.com/gcanti/io-ts">io-ts</a><br><sub>TS-first</sub></th>
291
+ <th><a href="https://github.com/runtypes/runtypes">Runtypes</a><br><sub>TS-first</sub></th>
292
+ <th><a href="https://github.com/davidmdm/myzod">myzod</a><br><sub>TS-first</sub></th>
293
+ <th><a href="https://github.com/badrap/valita">Valita</a><br><sub>TS-first</sub></th>
294
+ <th><a href="https://github.com/jquense/yup">Yup</a><br><sub>validator</sub></th>
295
+ <th><a href="https://github.com/hapijs/joi">Joi</a><br><sub>validator</sub></th>
296
+ <th><a href="https://github.com/vinejs/vine">VineJS</a><br><sub>validator</sub></th>
297
+ <th><a href="https://github.com/typestack/class-validator">class-validator</a><br><sub>decorators</sub></th>
298
+ <th><a href="https://github.com/ajv-validator/ajv">Ajv</a><br><sub>JSON Schema</sub></th>
299
+ <th><a href="https://github.com/sinclairzx81/typebox">TypeBox</a><br><sub>JSON Schema</sub></th>
300
+ <th><a href="https://github.com/samchon/typia">typia</a><br><sub>AOT compiler</sub></th>
301
+ <th><a href="https://github.com/mtth/avsc">avsc</a><br><sub>IDL · Avro</sub></th>
302
+ <th><a href="https://github.com/protobufjs/protobuf.js">protobuf.js</a><br><sub>IDL · Protobuf</sub></th>
303
+ <th><a href="https://github.com/Automattic/mongoose">Mongoose</a><br><sub>ODM</sub></th>
304
+ </tr>
305
+ </thead>
306
+ <tbody>
307
+ <tr class="ms-matrix-group"><td colspan="22"><strong>Package</strong></td></tr>
308
+ <tr><td>Version compared</td><td>3.2.0</td><td>2.2.2</td><td>4.6.6</td><td>1.5.0</td><td>2.2.8</td><td>4.0.3</td><td>2.0.2<sup>1</sup></td><td>2.2.22</td><td>7.0.5</td><td>1.12.1<sup>2</sup></td><td>0.5.5</td><td>1.7.1</td><td>18.2.9</td><td>4.4.0</td><td>0.15.1</td><td>8.20.0</td><td>1.3.36<sup>3</sup></td><td>15.1.0</td><td>5.7.9</td><td>8.8.1</td><td>9.11.1</td></tr>
309
+ <tr><td>Latest release</td><td>2026-10 (this release)</td><td>2025-05</td><td>2026-10</td><td>2026-09</td><td>2026-10</td><td>2026-10</td><td>2024-07</td><td>2024-12</td><td>2026-08</td><td>2025-02</td><td>2026-10</td><td>2025-09</td><td>2026-09</td><td>2026-04</td><td>2026-02</td><td>2026-04</td><td>2026-10</td><td>2026-10</td><td>2025-07</td><td>2026-10</td><td>2026-10</td></tr>
310
+ <tr><td>Runtime dependencies</td><td>✅ 0</td><td>2: metautil, metavm</td><td>✅ 0</td><td>✅ 0</td><td>3: @ark/schema, @ark/util, arkregex</td><td>✅ 0</td><td>✅ 0</td><td>0 + peer fp-ts</td><td>✅ 0</td><td>✅ 0</td><td>✅ 0</td><td>4: property-expr, tiny-case, toposort, type-fest</td><td>7 (@hapi/*, …)</td><td>10 (validator.js, dayjs, …)</td><td>3 (validator.js, libphonenumber-js, …)</td><td>4</td><td>✅ 0</td><td>3: randexp, @typia/interface, @typia/utils</td><td>✅ 0</td><td>1: long</td><td>7, incl. mongodb driver</td></tr>
311
+ <tr><td>License</td><td>MIT</td><td>MIT</td><td>MIT</td><td>MIT</td><td>MIT</td><td>MIT</td><td>MIT</td><td>MIT</td><td>MIT</td><td>MIT</td><td>MIT</td><td>MIT</td><td>BSD-3-Clause</td><td>MIT</td><td>MIT</td><td>MIT</td><td>MIT</td><td>MIT</td><td>MIT</td><td>BSD-3-Clause</td><td>MIT</td></tr>
312
+ <tr class="ms-matrix-group"><td colspan="22"><strong>Runtime</strong></td></tr>
313
+ <tr><td>Runs on</td><td>✅ Node 18+, browsers, edge</td><td>⚠️ Node; browsers via bundler<sup>4</sup></td><td>✅ Node, browsers, Deno, Bun, edge</td><td>✅ Node, browsers, Deno, Bun, edge</td><td>✅ Node, browsers, Deno, Bun, edge</td><td>✅ Node, browsers, Deno, Bun, edge</td><td>✅ Node ≥14, browsers, edge</td><td>✅ Node, browsers, edge</td><td>✅ Node, Deno (JSR), browsers, edge</td><td>⚠️ Node; browsers/edge via a bundler</td><td>✅ Node ≥22, Deno (JSR), browsers, edge</td><td>✅ Node, browsers, Deno, Bun, edge</td><td>⚠️ Node ≥ 20; browsers via a separate bundle<sup>5</sup></td><td>⚠️ Node, Bun, Deno; browsers if eval is allowed<sup>6</sup></td><td>✅ Node, browsers, Deno, Bun, edge</td><td>⚠️ Node, browsers; CSP/edge need standalone<sup>7</sup></td><td>✅ Node, browsers, Deno, Bun, edge</td><td>✅ generated JS runs anywhere</td><td>⚠️ Node; browsers need polyfills<sup>8</sup></td><td>⚠️ Node, browsers, Deno, Bun</td><td>⚠️ Node ≥ 20.19; browser: @mongoosejs/browser<sup>9</sup></td></tr>
314
+ <tr><td>Module format</td><td>CJS, ESM named imports</td><td>CJS</td><td>ESM + CJS</td><td>ESM + CJS</td><td>ESM</td><td>ESM</td><td>ESM + CJS</td><td>CJS + ESM (module field)</td><td>ESM + CJS</td><td>CJS</td><td>ESM</td><td>ESM + CJS</td><td>CJS</td><td>ESM</td><td>ESM + CJS</td><td>CJS</td><td>ESM</td><td>ESM + CJS</td><td>CJS</td><td>CJS (+ UMD dist)</td><td>CJS</td></tr>
315
+ <tr><td>Works without eval (strict CSP, edge)</td><td>✅ closures; JIT opt-in, falls back</td><td>✅ never (validation)</td><td>⚠️ object JIT by default; auto fallback<sup>10</sup></td><td>✅ never</td><td>⚠️ JIT by default; auto jitless under CSP</td><td>✅ never by default (JIT opt-in)</td><td>✅ never</td><td>✅ never</td><td>✅ never</td><td>✅ never</td><td>✅ never</td><td>✅ never</td><td>✅ never</td><td>❌ new AsyncFunction per schema</td><td>✅ never</td><td>⚠️ new Function; standalone precompile</td><td>⚠️ Compile evals, falls back; Value never</td><td>✅ code is generated at build time</td><td>❌ needs new Function</td><td>⚠️ reflection evals; static code not</td><td>✅ never (validation)</td></tr>
316
+ <tr><td>Works without a build step</td><td>✅ plain JS</td><td>✅ plain JS</td><td>✅ plain JS</td><td>✅ plain JS</td><td>✅ plain JS</td><td>✅ plain JS</td><td>✅ plain JS</td><td>✅ plain JS</td><td>✅ plain JS</td><td>✅ plain JS</td><td>✅ plain JS</td><td>✅ plain JS</td><td>✅ plain JS</td><td>✅ plain JS</td><td>⚠️ legacy TS decorators, or by hand<sup>11</sup></td><td>✅ plain JS; standalone optional</td><td>✅ plain JS</td><td>❌ requires ttsc transform (TypeScript 7)<sup>12</sup></td><td>✅ plain JS</td><td>⚠️ optional pbjs codegen</td><td>✅ plain JS</td></tr>
317
+ <tr class="ms-matrix-group"><td colspan="22"><strong>Defining schemas</strong></td></tr>
318
+ <tr><td>How a schema is written</td><td>plain object: <code>'?string'</code>, <code>{ array: 'number' }</code></td><td>plain object literal ('?string', kind key)</td><td>builder / method chain (zod/mini: functional)</td><td>functions + pipe()</td><td>TS-syntax strings in object literals + chaining</td><td>builder values: Schema.Struct({...}).pipe/.check</td><td>function combinators: object({ a: string() })</td><td>codec combinators: t.type({ a: t.string })</td><td>runtype values: Object({ a: String })</td><td>builder chain: myzod.object({ a: myzod.string() })</td><td>builder chain: v.object({ a: v.string() })</td><td>builder / method chain</td><td>builder / method chain</td><td>builder / method chain (mutable)</td><td>decorators on classes</td><td>JSON Schema or JTD document</td><td>builder (Type.Object…); TS-syntax strings via Type.Script</td><td>TS types + transformer; type tags</td><td>Avro schema JSON (.avsc) or IDL</td><td>.proto IDL or JSON descriptor</td><td>Mongoose Schema (SchemaType options)</td></tr>
319
+ <tr><td>The definition is data (store, send, rebuild)</td><td>✅ plain objects (functions aside)</td><td>✅ plain objects (functions aside)</td><td>⚠️ via toJSONSchema / fromJSONSchema</td><td>❌ export only (@valibot/to-json-schema)</td><td>✅ string/object defs; .json IR</td><td>✅ SchemaRepresentation.toJson / fromJson</td><td>❌ no</td><td>❌ no</td><td>❌ no</td><td>❌ no</td><td>❌ no</td><td>❌ describe() is one-way</td><td>✅ describe() ↔ Joi.build()</td><td>❌ toJSON() holds functions</td><td>❌ registerSchema() is broken<sup>13</sup></td><td>✅ JSON Schema / JTD documents</td><td>✅ types are JSON Schema objects</td><td>⚠️ only via json.schema + @typia/utils</td><td>✅ Avro JSON schema</td><td>✅ JSON descriptors</td><td>⚠️ via toJSONSchema() only</td></tr>
320
+ <tr><td>Optional vs nullable</td><td>✅ <code>'?x'</code>, <code>'key?'</code>, <code>nullable: true</code></td><td>⚠️ '?type' = absent/undefined/null</td><td>✅ optional, exactOptional, nullable, nullish</td><td>✅ optional, exactOptional, nullable, nullish, undefinedable</td><td>✅ 'key?' (no undefined), '| null', '| undefined'</td><td>✅ optionalKey, optional, NullOr, UndefinedOr, NullishOr</td><td>✅ optional(), nullable()</td><td>✅ t.partial vs t.union([X, t.null])</td><td>✅ optional(), nullable(), undefinedable()</td><td>✅ optional(), nullable()</td><td>✅ optional(), nullable()</td><td>✅ optional() / nullable() / defined()</td><td>✅ optional default; allow(null); required()</td><td>⚠️ optional() also accepts null<sup>14</sup></td><td>⚠️ IsOptional() skips null and undefined</td><td>✅ <code>required</code> vs type null / <code>nullable</code></td><td>✅ Optional, Union with Null, Undefined</td><td>✅ TS <code>?:</code>, <code>| null</code>, <code>| undefined</code></td><td>⚠️ ['null', T] union; absent needs default</td><td>⚠️ presence only; null = unset</td><td>⚠️ optional = absent/undefined/null</td></tr>
321
+ <tr><td>Unions, discriminated</td><td>✅ <code>union</code>, <code>discriminator</code></td><td>❌ none</td><td>✅ union, discriminatedUnion, xor</td><td>✅ union, variant (discriminated)</td><td>✅ 'a | b', .or(); auto-discriminated</td><td>✅ Union, Literals, TaggedUnion</td><td>⚠️ union(); no discriminated union</td><td>✅ union(), tag detected automatically</td><td>⚠️ Union(...); no discriminator</td><td>⚠️ union([..]) / or(); no discriminator</td><td>✅ union(), auto-discriminated</td><td>❌ no union type</td><td>✅ alternatives(); conditional() switch</td><td>✅ union() with if(), unionOfTypes()</td><td>⚠️ class-transformer discriminator</td><td>✅ anyOf / oneOf; <code>discriminator</code> opt-in</td><td>✅ Type.Union (anyOf); no discriminator</td><td>✅ TS unions; discriminant detected</td><td>✅ unions; wrapped = tagged by name</td><td>✅ oneof (virtual discriminator)</td><td>✅ Schema.Types.Union; discriminators</td></tr>
322
+ <tr><td>Tuples</td><td>✅ <code>['number', 'string']</code></td><td>⚠️ array shorthand, scalars only</td><td>✅ z.tuple with rest</td><td>✅ tuple, strictTuple, tupleWithRest</td><td>✅ ['string', 'number'], variadic '...'</td><td>✅ Tuple, TupleWithRest</td><td>✅ tuple([..])</td><td>⚠️ tuple([..]) strips extra items<sup>15</sup></td><td>✅ Tuple(...), with Spread rest</td><td>✅ tuple([..])</td><td>✅ tuple([..]), variadic via concat<sup>16</sup></td><td>✅ tuple()</td><td>✅ array().ordered()</td><td>✅ vine.tuple()</td><td>❌ none</td><td>✅ prefixItems + items: false</td><td>✅ Type.Tuple</td><td>✅ TS tuples</td><td>❌ none</td><td>❌ none</td><td>❌ none</td></tr>
323
+ <tr><td>Recursive schemas</td><td>✅ by name, cycles tracked</td><td>✅ by entity name in a Model</td><td>✅ getters or z.lazy</td><td>✅ v.lazy</td><td>✅ scope names, 'this'</td><td>✅ Schema.suspend</td><td>✅ lazy(() =&gt; S)</td><td>✅ t.recursion(name, f)</td><td>✅ Lazy(() =&gt; R)</td><td>✅ lazy(() =&gt; S)</td><td>✅ lazy(() =&gt; T)</td><td>✅ lazy()</td><td>✅ link('#id')</td><td>❌ none</td><td>✅ @ValidateNested + @Type(() =&gt; Self)</td><td>✅ $ref, $dynamicRef</td><td>✅ Type.Cyclic, Type.Module</td><td>✅ recursive TS types</td><td>✅ named types</td><td>✅ self-referencing messages</td><td>✅ schema.add({ self: schema })</td></tr>
324
+ <tr><td>Schemas referenced by name</td><td>✅ capitalized names in a <code>Model</code></td><td>✅ capitalized names via Model</td><td>❌ JS variables only</td><td>❌ JS variables only</td><td>✅ scope({ User, Group }) by name</td><td>❌ JS variables only</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none (ref() is a value ref)</td><td>✅ id() + link('#id'), shared()</td><td>❌ none</td><td>❌ none</td><td>✅ $ref by $id; ajv.addSchema</td><td>✅ Type.Ref + context, Module, $id</td><td>✅ TS type names</td><td>✅ names + namespaces, registry</td><td>✅ full names via Root</td><td>⚠️ ref: 'Model' for populate</td></tr>
325
+ <tr><td>Custom types registered by name</td><td>✅ registered by name</td><td>✅ Model types: js alias or checkType</td><td>❌ z.custom() values, no name registry</td><td>❌ v.custom() values, no name registry</td><td>✅ scope aliases, generics, keywords</td><td>⚠️ Schema.declare; reviver ids for restore</td><td>⚠️ define(name, fn); no registry</td><td>⚠️ new t.Type(name, is, validate, encode); no registry</td><td>⚠️ withBrand/withConstraint; no registry</td><td>⚠️ withPredicate/map on a base type; no registry</td><td>⚠️ unknown().assert()/chain(); no registry</td><td>⚠️ addMethod(), mixed(check)</td><td>✅ Joi.extend({ type })</td><td>⚠️ createRule(), macro() methods</td><td>✅ registerDecorator(), @ValidatorConstraint</td><td>⚠️ addKeyword / addSchema, not types</td><td>⚠️ Unsafe + Refine; Script/Module names</td><td>✅ custom tags (tags.TagBase)</td><td>✅ logicalTypes classes, typeHook</td><td>❌ messages and enums only</td><td>✅ Schema.Types.Name = class</td></tr>
326
+ <tr><td>String formats</td><td>✅ 9 + your own (<code>./formats</code>)</td><td>❌ none</td><td>✅ 30+ (email, uuid, url, ip, iso.datetime…)</td><td>✅ ~37 actions (email, uuid, url, isoDateTime…)</td><td>✅ ~18 string.* (email, uuid, url, ip…)</td><td>✅ uuid, ulid, base64, URL, IP; no email</td><td>❌ none (pattern() only)</td><td>⚠️ io-ts-types: UUID, ISO dates</td><td>❌ none (Template literals)</td><td>❌ none (pattern() only)</td><td>❌ none</td><td>✅ 4: email, url, uuid, datetime<sup>17</sup></td><td>✅ 14: email, uri, uuid, ip, isoDate...</td><td>✅ 18: email, url, uuid, ulid, ip, iban, jwt...</td><td>✅ 50+ via validator.js (IsEmail, IsUUID, IsUrl...)</td><td>✅ ajv-formats: 26<sup>18</sup></td><td>✅ 21 built in<sup>19</sup></td><td>✅ 22 via tags.Format</td><td>❌ none</td><td>❌ none</td><td>❌ none (match: RegExp)</td></tr>
327
+ <tr><td>Date, BigInt, Map, Set</td><td>✅ Date, BigInt, Map, Set</td><td>⚠️ BigInt, Map, Set; no Date</td><td>✅ Date, BigInt, Map, Set, Symbol, File</td><td>✅ Date, BigInt, Map, Set, Blob, File</td><td>✅ Date, bigint, Map, Set, symbol, Blob, File…</td><td>✅ Date, BigInt, ReadonlyMap, ReadonlySet, Symbol…</td><td>✅ Date, BigInt, Map, Set</td><td>⚠️ BigInt; Date/Map/Set via io-ts-types</td><td>⚠️ BigInt, Symbol; Date/Map/Set via InstanceOf</td><td>⚠️ Date, BigInt</td><td>⚠️ BigInt only</td><td>⚠️ Date</td><td>⚠️ Date, Buffer, symbol, function</td><td>⚠️ Date (output), File</td><td>⚠️ Date; Set/Map via each</td><td>⚠️ Date via ajv-keywords or JTD</td><td>⚠️ BigInt, Symbol, Undefined; no Date/Map/Set<sup>20</sup></td><td>✅ Date, bigint, Map, Set, typed arrays<sup>21</sup></td><td>⚠️ Buffer; Date, BigInt via custom types<sup>22</sup></td><td>⚠️ Uint8Array, Long; BigInt via fromObject<sup>23</sup></td><td>✅ Date, BigInt, Map, Buffer</td></tr>
328
+ <tr><td>Custom validators</td><td>✅ <code>validate</code> on a field and a schema</td><td>✅ field and schema validate<sup>24</sup></td><td>✅ .refine / .superRefine / .check</td><td>✅ check (field), forward+partialCheck (object)</td><td>✅ .narrow() on fields and objects</td><td>✅ .check(makeFilter), refine</td><td>✅ refine(struct, name, fn)</td><td>✅ refinement(), brand()</td><td>✅ withConstraint, withGuard, withAssertion</td><td>✅ withPredicate(fn, msg)</td><td>✅ assert(fn, msg), chain()</td><td>✅ test() on fields and objects</td><td>✅ custom() on any schema</td><td>✅ createRule() + use(), any level</td><td>⚠️ custom decorators per property</td><td>✅ custom keywords (addKeyword)</td><td>✅ Type.Refine on any type</td><td>⚠️ TagBase validate expressions (strings)</td><td>⚠️ only via a LogicalType</td><td>❌ none</td><td>✅ validate; pre('validate') + invalidate</td></tr>
329
+ <tr><td>Async validators</td><td>✅ <code>checkAsync</code>, run concurrently</td><td>❌ none</td><td>✅ parseAsync; concurrent</td><td>✅ *Async schemas; concurrent<sup>25</sup></td><td>❌ not supported (by design)<sup>26</sup></td><td>✅ Effect getters; concurrency option</td><td>❌ none</td><td>⚠️ experimental TaskDecoder, concurrent<sup>27</sup></td><td>❌ none</td><td>❌ none<sup>28</sup></td><td>❌ none (non-goal)<sup>29</sup></td><td>✅ async test(), concurrent</td><td>⚠️ external(): sequential, after sync rules<sup>30</sup></td><td>⚠️ async rules, in sequence</td><td>✅ async constraints, concurrent<sup>31</sup></td><td>⚠️ $async schemas; awaited one by one</td><td>❌ sync only<sup>32</sup></td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>✅ async validators, concurrent</td></tr>
330
+ <tr class="ms-matrix-group"><td colspan="22"><strong>Validation results</strong></td></tr>
331
+ <tr><td>Every issue in one run</td><td>✅ all, by default</td><td>✅ all by default</td><td>✅ all by default</td><td>✅ all by default; abortEarly</td><td>✅ all by default</td><td>⚠️ first by default; errors: 'all'</td><td>⚠️ first; all via <code>failures()</code></td><td>✅ all by default</td><td>✅ all by default</td><td>⚠️ first; collectErrors() per object</td><td>✅ all by default</td><td>⚠️ first by default; abortEarly: false</td><td>⚠️ first by default; abortEarly: false</td><td>✅ all fields; first per field</td><td>✅ all by default; stopAtFirstError</td><td>⚠️ first by default; <code>allErrors: true</code><sup>33</sup></td><td>⚠️ <code>Errors()</code>: up to 8 by default</td><td>✅ validate: all; assert: first</td><td>⚠️ first; all via <code>errorHook</code></td><td>❌ first error only</td><td>✅ all paths, one per path</td></tr>
332
+ <tr><td>A cap on the number of issues</td><td>✅ <code>maxErrors</code></td><td>❌ none</td><td>❌ first (validate) or all</td><td>❌ first or all</td><td>❌ all only</td><td>❌ first or all</td><td>❌ first or all only</td><td>❌ all only</td><td>❌ all only</td><td>❌ first or all only</td><td>❌ all only</td><td>❌ first or all</td><td>❌ first or all</td><td>❌ none</td><td>❌ none</td><td>❌ first or all</td><td>⚠️ <code>maxErrors</code> (8), process-wide</td><td>❌ first (assert) or all (validate)</td><td>❌ first or all only</td><td>❌ first only</td><td>❌ none</td></tr>
333
+ <tr><td>Issues as data: code, path, params</td><td>✅ code, path array, params</td><td>❌ message strings<sup>34</sup></td><td>✅ code, path[], expected/minimum…</td><td>✅ type, path[], expected/received/requirement</td><td>✅ code, path[], expected/actual/rule</td><td>✅ tagged issue tree; paths; check params</td><td>⚠️ path array, type/refinement; no params</td><td>⚠️ context path, expected codec, value; no codes</td><td>⚠️ code, expected, received; nested details</td><td>⚠️ path array + message; no codes</td><td>✅ code, path array, expected/keys/bounds</td><td>⚠️ type, params; path is a string</td><td>✅ type, path array, context</td><td>⚠️ rule, meta; path is a dot string</td><td>⚠️ constraint names; nested error tree</td><td>⚠️ keyword, params; path as JSON Pointer</td><td>⚠️ keyword, params; path as JSON Pointer</td><td>⚠️ path string, expected, value; no code</td><td>⚠️ errorHook(path[], value, type)</td><td>❌ string with dotted path</td><td>⚠️ kind, path string, properties</td></tr>
334
+ <tr><td>Localized messages</td><td>✅ en, uk; a locale per call</td><td>❌ none</td><td>✅ 62 locales; per-call error fn</td><td>✅ @valibot/i18n (34 locales); per-call message fn<sup>35</sup></td><td>⚠️ per-kind message config; no locales</td><td>⚠️ message annotations, formatter hooks; no locales</td><td>❌ none (per-call message string)</td><td>❌ none</td><td>❌ none</td><td>❌ none (per-schema messages)</td><td>❌ none</td><td>⚠️ global setLocale(); English only</td><td>✅ messages + errors.language per call</td><td>✅ messagesProvider per call; English only</td><td>⚠️ message functions; none built in</td><td>✅ ajv-i18n: 23 locales</td><td>✅ 38 locales; global Locale.Set</td><td>❌ no messages</td><td>❌ none</td><td>❌ none</td><td>⚠️ global mongoose.Error.messages</td></tr>
335
+ <tr><td>Unknown keys</td><td>✅ reject (default), ignore, strip</td><td>⚠️ reject only (no option)<sup>36</sup></td><td>✅ strip (default), strict, loose</td><td>✅ strip (default), strict, loose, rest</td><td>✅ ignore (default), reject, delete</td><td>✅ strip (default), error; keep via StructWithRest</td><td>✅ object() rejects; type() ignores; mask() strips</td><td>⚠️ ignore (t.type), strip (t.exact/t.strict); no reject</td><td>✅ check ignores, parse strips, exact() rejects<sup>37</sup></td><td>✅ reject (default), strip</td><td>✅ strict (default), strip, passthrough per call</td><td>✅ keep default; exact() rejects, stripUnknown<sup>38</sup></td><td>✅ reject default; allowUnknown, stripUnknown</td><td>⚠️ strip default; allowUnknownProperties()<sup>39</sup></td><td>✅ keep default; whitelist strips, forbidNonWhitelisted<sup>40</sup></td><td>✅ ignore default; reject, strip (removeAdditional)</td><td>✅ ignore default; reject, Value.Clean strips</td><td>✅ ignore default; equals rejects, prune strips<sup>41</sup></td><td>✅ ignore (default), reject, strip</td><td>✅ ignore, strip, reject<sup>42</sup></td><td>✅ strip (default), keep, throw</td></tr>
336
+ <tr><td>A result instead of an exception</td><td>✅ <code>check</code>, <code>parse</code> return a result</td><td>⚠️ check() returns a result<sup>43</sup></td><td>✅ safeParse</td><td>✅ safeParse, is</td><td>✅ T(data) returns data | ArkErrors</td><td>✅ decodeUnknownResult / Exit / Option</td><td>✅ validate() → [error, value]; is()</td><td>✅ decode() → Either</td><td>✅ inspect() → result; guard()</td><td>✅ try() → value | ValidationError</td><td>✅ try() → { ok, value | issues }</td><td>⚠️ isValid(), ~standard.validate</td><td>✅ validate() → { value, error }</td><td>✅ tryValidate() → [error, value]</td><td>✅ validate() → ValidationError[]</td><td>✅ validate() → boolean + .errors</td><td>✅ Check + Errors; Parse throws</td><td>✅ is / validate</td><td>✅ isValid() -&gt; boolean</td><td>✅ verify() -&gt; null | string</td><td>✅ validateSync() returns the error<sup>44</sup></td></tr>
337
+ <tr><td>Cyclic and very deep input</td><td>✅ tracked at references, <code>maxDepth</code></td><td>❌ no detection; stack overflow</td><td>⚠️ cycle-safe; no depth limit<sup>45</sup></td><td>❌ stack overflow, no depth limit</td><td>⚠️ cycle-safe; no depth limit</td><td>❌ stack overflow, no depth limit<sup>46</sup></td><td>❌ stack overflow</td><td>❌ stack overflow</td><td>⚠️ cycles accepted; deep input overflows</td><td>⚠️ the overflow caught as an issue<sup>47</sup></td><td>❌ stack overflow</td><td>❌ stack overflow</td><td>✅ link.depth issue; maxRecursion(n)</td><td>⚠️ finite schemas; the unknown-key copy overflows</td><td>❌ stack overflow</td><td>❌ RangeError; no detection or depth limit</td><td>❌ RangeError; no detection or depth limit</td><td>⚠️ WeakSet guard; deep input overflows<sup>48</sup></td><td>❌ stack overflow</td><td>✅ depth limit 100</td><td>❌ throws (circular JSON, RangeError)</td></tr>
338
+ <tr class="ms-matrix-group"><td colspan="22"><strong>Parsing</strong></td></tr>
339
+ <tr><td>Defaults</td><td>✅ <code>default</code>, a value or a factory</td><td>❌ kept as metadata only</td><td>✅ .default(), .prefault(), .catch()</td><td>✅ optional(schema, default), fallback</td><td>✅ 'string = "x"', .default()</td><td>✅ withDecodingDefault(Key), withConstructorDefault</td><td>✅ defaulted(), via create()/mask()<sup>49</sup></td><td>⚠️ io-ts-types fromNullable/withFallback</td><td>✅ default(value), parse only<sup>50</sup></td><td>✅ default(value | fn)</td><td>✅ optional(() =&gt; v), nullable(() =&gt; v)</td><td>✅ default(), factories</td><td>✅ default(), factories</td><td>❌ none (parse() can fill)</td><td>✅ field initializers (class-transformer)</td><td>✅ useDefaults: true (in place)<sup>51</sup></td><td>⚠️ Value.Default; Decode pipeline<sup>52</sup></td><td>❌ Default&lt;V&gt; is metadata only</td><td>✅ field default (clone, decode)</td><td>✅ proto defaults, toObject({ defaults })</td><td>✅ default values and functions</td></tr>
340
+ <tr><td>Transforms and decoders</td><td>✅ a field's <code>parse</code> (decoder)</td><td>❌ none</td><td>✅ .transform, z.pipe, z.preprocess</td><td>✅ transform, rawTransform in pipe</td><td>✅ morphs: .pipe(), .to(), '=&gt;'</td><td>✅ decodeTo + SchemaTransformation</td><td>✅ coerce(struct, from, fn) via create()</td><td>✅ custom Type with validate/encode</td><td>✅ withParser(fn), parse only</td><td>✅ map(fn)</td><td>✅ map(fn), chain(fn)</td><td>✅ transform()</td><td>✅ custom() return value, rename(), trim()...</td><td>✅ transform(), parse()</td><td>✅ @Transform (class-transformer)</td><td>⚠️ ajv-keywords transform (strings only)</td><td>✅ Type.Codec / Decode / Encode</td><td>⚠️ built-in only: http, notations, llm</td><td>✅ logical types (_fromValue)</td><td>⚠️ conversion options only</td><td>✅ set/get, trim, lowercase</td></tr>
341
+ <tr><td>Coercion of input types</td><td>❌ a decoder on a string field</td><td>❌ none</td><td>✅ z.coerce.*, z.stringbool</td><td>✅ toNumber, toDate, toBoolean… actions</td><td>✅ string.numeric.parse, string.date.parse…</td><td>✅ NumberFromString, DateFromString…</td><td>❌ none (trimmed() only)</td><td>⚠️ io-ts-types NumberFromString etc.</td><td>❌ none</td><td>✅ number coerce, date, bigint, enum case<sup>53</sup></td><td>❌ none</td><td>✅ on by default; strict() off</td><td>✅ convert: true by default<sup>54</sup></td><td>✅ form semantics by default; { strict: true }</td><td>✅ @Type / implicit (class-transformer)</td><td>✅ coerceTypes: true | "array"</td><td>✅ Value.Convert (also inside Decode)</td><td>⚠️ http.query/headers, llm.coerce</td><td>⚠️ coerceBuffers only</td><td>✅ fromObject casts<sup>55</sup></td><td>✅ casting on by default</td></tr>
342
+ <tr><td>Encode back (bidirectional codecs)</td><td>✅ <code>serialize</code></td><td>❌ none</td><td>✅ z.codec + z.encode</td><td>🔜 planned for v2 (#658)</td><td>❌ none</td><td>✅ encodeSync / encodeUnknown*</td><td>❌ none</td><td>✅ codec.encode()</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>✅ instanceToPlain (class-transformer)</td><td>⚠️ JTD compileSerializer (to JSON)</td><td>✅ Codec + Value.Encode</td><td>⚠️ protobuf.encode/decode, json.stringify</td><td>✅ toBuffer/fromBuffer; logical _toValue</td><td>✅ binary, toObject, ProtoJSON</td><td>⚠️ getters, toJSON transform</td></tr>
343
+ <tr class="ms-matrix-group"><td colspan="22"><strong>TypeScript</strong></td></tr>
344
+ <tr><td>Static type inferred from the schema</td><td>✅ <code>Infer</code>, <code>InferSchema</code></td><td>❌ none</td><td>✅ z.infer</td><td>✅ InferOutput</td><td>✅ typeof T.infer</td><td>✅ typeof S.Type</td><td>✅ Infer&lt;typeof S&gt;</td><td>✅ t.TypeOf&lt;typeof C&gt;</td><td>✅ Static&lt;typeof R&gt;</td><td>✅ Infer&lt;typeof S&gt;</td><td>✅ v.Infer&lt;typeof T&gt;</td><td>✅ InferType</td><td>❌ none</td><td>✅ Infer&lt;typeof schema&gt;</td><td>⚠️ the class is the type</td><td>⚠️ JTDDataType (JTD only)</td><td>✅ Static&lt;T&gt;, also from plain JSON Schema</td><td>✅ the TS type is the schema</td><td>❌ none</td><td>⚠️ via pbjs --dts codegen</td><td>✅ InferSchemaType</td></tr>
345
+ <tr><td>Separate input and output types</td><td>✅ <code>Infer</code> / <code>InferOutput</code></td><td>❌ none</td><td>✅ z.input / z.output</td><td>✅ InferInput / InferOutput</td><td>✅ T.inferIn / T.inferOut</td><td>✅ S.Type / S.Encoded</td><td>❌ none</td><td>✅ TypeOf, InputOf, OutputOf</td><td>✅ Static vs Parsed</td><td>❌ none</td><td>❌ output only</td><td>⚠️ defaults only, in ~standard types</td><td>❌ none</td><td>✅ InferInput / Infer</td><td>❌ none</td><td>— no transforms</td><td>✅ StaticDecode / StaticEncode</td><td>— no transforms or defaults</td><td>❌ none</td><td>⚠️ $Properties vs class (pbts)</td><td>⚠️ InferRawDocType vs hydrated</td></tr>
346
+ <tr><td>Generates TypeScript source</td><td>✅ <code>toTypeScript</code>, <code>saveTypes</code></td><td>⚠️ model.dts, flat scalars only<sup>56</sup></td><td>⚠️ zod-to-ts (third-party)</td><td>❌ none</td><td>❌ .expression is ArkType syntax, not TS</td><td>✅ SchemaRepresentation.toCodeDocument</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>⚠️ joi-to-typescript (3rd party)</td><td>❌ none</td><td>— schemas are TS classes</td><td>⚠️ json-schema-to-typescript (third-party)</td><td>⚠️ json-schema-to-typescript (third-party)</td><td>— the source is TypeScript</td><td>⚠️ third-party: @ovotech/avro-ts</td><td>✅ pbjs --dts / pbts (protobufjs-cli)</td><td>⚠️ third-party: mongoose-tsgen</td></tr>
347
+ <tr class="ms-matrix-group"><td colspan="22"><strong>Interoperability</strong></td></tr>
348
+ <tr><td>Standard Schema</td><td>✅ v1 + JSON Schema converter</td><td>❌ no</td><td>✅ v1 + ~standard.jsonSchema</td><td>✅ v1 on every schema</td><td>✅ v1 + ~standard.jsonSchema</td><td>✅ v1 via toStandardSchemaV1()<sup>57</sup></td><td>❌ no</td><td>❌ no</td><td>❌ no</td><td>❌ no</td><td>✅ v1 (~standard), libraryOptions.mode</td><td>✅ v1, always async<sup>58</sup></td><td>✅ v1, + Standard JSON Schema</td><td>⚠️ v1 on validators; path is a string<sup>59</sup></td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>✅ createValidate&lt;T&gt;() (v1)</td><td>❌ no</td><td>❌ no</td><td>✅ Model['~standard'] v1 (9.7+)<sup>60</sup></td></tr>
349
+ <tr><td>JSON Schema export</td><td>✅ 2020-12, draft-07, OpenAPI 3.0, MongoDB</td><td>❌ none</td><td>✅ 2020-12, draft-07, draft-04, OpenAPI 3.0</td><td>✅ draft-07, 2020-12, OpenAPI 3.0 (@valibot/to-json-schema)</td><td>✅ draft 2020-12, draft-07</td><td>✅ 2020-12, draft-07, draft-04, OpenAPI 3.1</td><td>❌ none</td><td>⚠️ io-ts-to-json-schema (third-party)</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>⚠️ @sodaru/yup-to-json-schema (3rd party)</td><td>✅ 2020-12 via ~standard.jsonSchema</td><td>✅ draft-07 via toJSONSchema()</td><td>⚠️ class-validator-jsonschema (3rd party)</td><td>✅ the schema is JSON Schema</td><td>✅ types are JSON Schema (2020-12)</td><td>✅ json.schema(s): OpenAPI 3.0, 3.1</td><td>❌ none</td><td>❌ none</td><td>✅ toJSONSchema(): JSON Schema, $jsonSchema</td></tr>
350
+ <tr><td>JSON Schema import</td><td>✅ <code>fromJSONSchema</code> (a subset)</td><td>❌ none</td><td>✅ z.fromJSONSchema<sup>61</sup></td><td>⚠️ json-schema-to-valibot (third-party, codegen)</td><td>⚠️ @ark/json-schema 0.0.12 (no $ref)</td><td>✅ SchemaRepresentation.fromJsonSchemaDocument</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>⚠️ json-schema-to-yup (3rd party)</td><td>⚠️ enjoi (3rd party)</td><td>❌ none</td><td>❌ none</td><td>✅ draft-07, 2019-09, 2020-12, JTD</td><td>✅ Compile/Value accept drafts 3–2020-12</td><td>⚠️ @typia/utils OpenApiValidator (untyped)</td><td>❌ none</td><td>❌ none</td><td>❌ none</td></tr>
351
+ <tr><td>LLM structured-output profile</td><td>✅ the strict profile</td><td>❌ none</td><td>⚠️ openai/helpers/zod (third-party)</td><td>⚠️ @ai-sdk/valibot (third-party)</td><td>❌ none</td><td>✅ effect/ai toCodecOpenAI, toCodecAnthropic<sup>62</sup></td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>✅ llm.application/parameters; strict mode</td><td>❌ none</td><td>❌ none</td><td>❌ none</td></tr>
352
+ <tr class="ms-matrix-group"><td colspan="22"><strong>Domain models</strong></td></tr>
353
+ <tr><td>Entities with storage metadata</td><td>✅ kinds: Entity, Registry, …</td><td>✅ 11 kinds: scope, store, id field</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>⚠️ schema/Model variants + SqlModel</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>✅ model(name), collection option</td></tr>
354
+ <tr><td>References: an id or the record</td><td>✅ an id or the record, by kind or per call</td><td>⚠️ embedded record only<sup>63</sup></td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none (named types embed)</td><td>❌ none (messages embed)</td><td>⚠️ ref: id or populated doc<sup>64</sup></td></tr>
355
+ <tr><td>Indexes and unique keys</td><td>✅ <code>index</code>, <code>primary</code>, <code>unique</code></td><td>✅ index/primary/unique arrays</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>✅ index/unique/sparse, schema.index()</td></tr>
356
+ <tr><td>Relation metadata</td><td>✅ <code>schema.relations</code></td><td>⚠️ schema.relations { to, type }<sup>65</sup></td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>⚠️ ref, virtual populate (justOne)</td></tr>
357
+ <tr><td>Derive a schema: pick, omit, partial, extend</td><td>⚠️ <code>Projection</code>, <code>merge</code>; no partial</td><td>⚠️ Projection kind (pick fields)</td><td>✅ pick, omit, partial, required, extend, deepPartial</td><td>✅ pick, omit, partial, required</td><td>✅ pick, omit, partial, required, merge</td><td>✅ mapFields + Struct.pick/omit/map</td><td>✅ pick, omit, partial, assign</td><td>⚠️ partial, exact, intersection; no pick/omit</td><td>✅ pick, omit, extend, asPartial</td><td>✅ pick, omit, partial (deep), required</td><td>✅ pick, omit, partial, extend, rest</td><td>✅ pick, omit, partial, shape, concat</td><td>✅ keys, append, fork, tailor, concat</td><td>✅ pick, omit, partial, merge(group)</td><td>⚠️ class extends; @nestjs/mapped-types</td><td>⚠️ allOf; ajv-merge-patch $merge/$patch</td><td>✅ Pick, Omit, Partial, Required, Mapped</td><td>✅ TS Pick, Omit, Partial</td><td>❌ none</td><td>❌ none</td><td>✅ pick, omit, add, clone, discriminator</td></tr>
358
+ <tr><td>A model of many schemas</td><td>✅ <code>Model</code>: order, missing references</td><td>✅ Model: order, missing refs</td><td>❌ none</td><td>❌ none</td><td>⚠️ scope(): resolves names, errors on missing</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>⚠️ Ajv instance as $ref registry</td><td>⚠️ Type.Module (named types)</td><td>❌ none</td><td>⚠️ protocols, shared registry</td><td>⚠️ Root: lookup, resolveAll()</td><td>⚠️ mongoose.model() registry</td></tr>
359
+ <tr class="ms-matrix-group"><td colspan="22"><strong>Evolution</strong></td></tr>
360
+ <tr><td>Snapshot of a schema or model</td><td>✅ <code>model.toJSON()</code>, <code>fromJSON</code></td><td>⚠️ schema.toJSON(), fields only</td><td>⚠️ via JSON Schema round trip</td><td>❌ export only, no restore</td><td>✅ .json → type.schema()</td><td>✅ SchemaRepresentation toJson / fromJson</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>⚠️ describe(), no restore</td><td>✅ describe() / Joi.build()</td><td>⚠️ toJSON(), no restore</td><td>❌ none</td><td>✅ schemas are JSON</td><td>✅ JSON.stringify; Compile reads it back</td><td>⚠️ export only (json.schema, reflect.schema)</td><td>✅ schema(), JSON.stringify(type)</td><td>✅ root.toJSON() / Root.fromJSON()</td><td>❌ none</td></tr>
361
+ <tr><td>Diff of two versions</td><td>✅ <code>diff</code></td><td>🔜 issue #251 (migrations)</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>⚠️ Value.Diff (generic JSON edits)</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td></tr>
362
+ <tr><td>Compatibility of a change</td><td>✅ backward / forward / full</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>⚠️ via .extends() / .equals()</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>⚠️ Type.Extends (assignability)</td><td>❌ none</td><td>✅ reader/writer resolution<sup>66</sup></td><td>❌ none</td><td>❌ none</td></tr>
363
+ <tr><td>Field aliases (renames)</td><td>✅ <code>aliases</code>, renamed by <code>parse</code></td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>⚠️ Schema.encodeKeys (one encoded name)</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>✅ object.from(old, new, alias)</td><td>✅ rename(old, new, { alias })</td><td>❌ none</td><td>⚠️ @Expose({ name }) (class-transformer)</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>✅ type and field aliases</td><td>⚠️ renames free on the wire</td><td>✅ alias option (virtual)</td></tr>
364
+ <tr><td>Deprecation markers</td><td>✅ <code>deprecated</code></td><td>❌ none</td><td>✅ .meta({ deprecated: true })</td><td>❌ free-form metadata() only</td><td>✅ .configure({ deprecated: true })</td><td>❌ none</td><td>✅ deprecated(struct, log)</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none (meta() is free-form)</td><td>❌ none (meta(), notes free-form)</td><td>❌ none</td><td>❌ none</td><td>✅ deprecated keyword (annotation)</td><td>⚠️ deprecated: true passes through</td><td>✅ JSDoc @deprecated → schema</td><td>❌ none</td><td>⚠️ [deprecated] kept in options</td><td>❌ none</td></tr>
365
+ <tr class="ms-matrix-group"><td colspan="22"><strong>Tooling</strong></td></tr>
366
+ <tr><td>Sample values from a schema</td><td>✅ <code>sample</code>, seeded</td><td>❌ none</td><td>⚠️ zod-schema-faker (third-party)</td><td>⚠️ valimock (third-party)</td><td>✅ @ark/fast-check (arkToArbitrary)</td><td>✅ Arbitrary.schema (own engine)</td><td>❌ none</td><td>⚠️ fast-check-io-ts (third-party)</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none (example() is an annotation)</td><td>❌ none</td><td>❌ none</td><td>⚠️ json-schema-faker (third-party)</td><td>⚠️ Value.Create (zero values)</td><td>✅ typia.random&lt;T&gt;() (randexp)</td><td>✅ type.random()</td><td>❌ none</td><td>❌ none</td></tr>
367
+ <tr><td>A schema inferred from data</td><td>✅ <code>infer</code></td><td>❌ none</td><td>⚠️ json-to-zod (third-party, 2022)</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>✅ Type.forValue, Type.forTypes<sup>67</sup></td><td>❌ none</td><td>❌ none</td></tr>
368
+ <tr><td>Merge or intersect two schemas</td><td>✅ <code>merge</code></td><td>❌ none</td><td>✅ z.intersection, .extend</td><td>✅ intersect</td><td>✅ .merge(), .and()</td><td>⚠️ fieldsAssign (struct fields only)</td><td>✅ assign(), intersection()</td><td>✅ intersection()</td><td>✅ Intersect(...), and()</td><td>✅ and() / intersection()</td><td>⚠️ extend(other.shape); no intersection</td><td>✅ concat()</td><td>✅ concat()</td><td>❌ none</td><td>❌ none</td><td>⚠️ allOf; ajv-merge-patch $merge</td><td>✅ Intersect + Evaluate</td><td>✅ TS intersection (A &amp; B)</td><td>⚠️ Type.forTypes (widening)</td><td>❌ none</td><td>✅ schema.add(other), new Schema([a, b])</td></tr>
369
+ <tr><td>Warnings about a definition</td><td>✅ <code>schema.warnings</code></td><td>⚠️ model.warnings: refs, recursion</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>✅ strict mode; strictTypes logs</td><td>❌ none</td><td>❌ compile errors only</td><td>❌ none</td><td>❌ none</td><td>⚠️ reserved-key, duplicate-index warnings</td></tr>
370
+ <tr><td>Streams and iterables of records</td><td>✅ <code>checkEach</code>, <code>transform</code></td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>✅ ChannelSchema.decode/encode<sup>68</sup></td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>❌ none</td><td>⚠️ Node stream codecs</td><td>❌ none (delimited framing only)</td><td>❌ none</td></tr>
371
+ <tr><td>Compiled to code, with a fallback</td><td>✅ <code>compile()</code>, closures fallback</td><td>❌ interpreter only</td><td>✅ z.compile / zod/compile; runtime fallback</td><td>🔜 compiler PR by the author (#1441)</td><td>✅ JIT by default; jitless fallback</td><td>✅ opt-in JIT + AOT; interpreter fallback<sup>69</sup></td><td>❌ interpreter only</td><td>❌ interpreter only</td><td>❌ interpreter only</td><td>❌ interpreter only</td><td>❌ interpreter only</td><td>❌ interpreter only</td><td>❌ interpreter only</td><td>✅ always; no interpreter fallback</td><td>❌ interpreter only</td><td>✅ always compiles; no interpreter</td><td>✅ Compile; interpreter fallback</td><td>✅ AOT at build time; no fallback</td><td>✅ new Function; no fallback</td><td>✅ runtime codegen; static AOT</td><td>❌ interpreter only</td></tr>
372
+ <tr><td>Readable at runtime</td><td>✅ <code>fields</code>, <code>toJSON()</code></td><td>✅ fields, kind, indexes, relations</td><td>✅ .def, .shape, .meta()</td><td>✅ plain schema objects (type, entries, pipe)</td><td>✅ .json, .props, .expression, .select()</td><td>✅ .ast, .fields, annotations</td><td>⚠️ struct.type, struct.schema</td><td>✅ _tag, props, types, name</td><td>✅ tag, fields, alternatives, element</td><td>⚠️ shape(); other parts private</td><td>⚠️ name, shape, options; transforms opaque</td><td>✅ describe(), fields, spec</td><td>✅ describe(), $_terms, _rules</td><td>✅ toJSON() tree, getProperties()</td><td>✅ getMetadataStorage()</td><td>✅ the schema is a plain object</td><td>✅ JSON Schema objects; Type.Is* guards</td><td>✅ reflect.schema / json.schema</td><td>✅ fields, typeName, schema()</td><td>✅ reflection: fields, options</td><td>✅ schema.paths, path(), eachPath</td></tr>
373
+ </tbody>
374
+ </table>
375
+
376
+ </div>
377
+
378
+ ✅ built in, or in an official package of the same project (named) · ⚠️ partial, opt-in, with a caveat, or through a third-party package (named) · ❌ not built in · 🔜 planned by the maintainers, no code yet · — does not apply. Every cell was checked against the source of the published package in October 2026.
379
+
380
+ 1. No release since 2024-07; MetaMask publishes a maintained fork, <code>@metamask/superstruct</code>.
381
+ 2. No commits since the 2025-02 release.
382
+ 3. The legacy @sinclair/typebox 0.34.52 differs materially: CJS + ESM, Type.Date / Uint8Array and a TypeRegistry for custom kinds, and a Value.Parse that cleans, defaults and converts by default (research/typebox-legacy/node_modules/@sinclair/typebox/build/cjs/value/parse/parse.js:60-66).
383
+ 4. A minified bundle validates nothing but unknown keys: identity is checked by constructor.name === 'Type' (lib/util.js:42, lib/struct.js:34), which minifiers rename. esbuild minify without keepNames: { a: 1 } against { a: 'string' } is valid.
384
+ 5. The browser bundle has no describe()/build() ('Manifest functionality disabled'), binary() or trace(); the main entry needs Node's url and util modules.
385
+ 6. The compiled validator needs code generation, so it does not run on Cloudflare Workers or under a CSP without unsafe-eval.
386
+ 7. Runtimes that forbid eval (Cloudflare Workers, strict CSP) can only run validation code pre-generated with ajv/dist/standalone at build time.
387
+ 8. Built for browserify-era Node polyfills; and since every type is created with new Function, eval-free edge runtimes (Cloudflare Workers) cannot load it.
388
+ 9. @mongoosejs/browser 0.1.3 is a prebuilt UMD (1.1 MB, 270 KB gzip) of mongoose 9.0.0-rc1 that validates documents only; its Node entry exports the driver, not mongoose, despite its README.
389
+ 10. z.object builds a fast path with new Function when eval is allowed; a CSP probe (or z.config({ jitless: true })) switches to the interpreter. z.compile / "zod/compile" also use new Function and fall back to the runtime parser.
390
+ 11. Standard (TC39) decorators are not supported; class-transformer's implicit conversion also needs emitDecoratorMetadata.
391
+ 12. Since v13 the transform is written in Go and run by ttsc on the TypeScript 7 native compiler (the first build compiled the plugin in 85 s); typia 12 is the legacy ts-patch setup for TypeScript &lt; 7. Bundlers need @ttsc/unplugin.
392
+ 13. After registerSchema(), validating any decorated class throws the same TypeError (MetadataStorage.js:107).
393
+ 14. optional() lets null through and drops it from the output; nullable() keeps the key required; an absent key and undefined are the same.
394
+ 15. A longer array is accepted and truncated, not rejected.
395
+ 16. The invalid_length message is garbled in 0.5.5 ("expected an arraywith items", :852-866): a missing space and no count.
396
+ 17. Regex-only: uuid() accepts versions 1-5 only (a v7 UUID fails) and datetime() does not check ranges.
397
+ 18. The core has none: in strict mode a schema with an unknown format fails to compile ("unknown format \"email\" ignored in schema").
398
+ 19. An unregistered format name passes silently: Format.Test returns true when the name is unknown (_registry.ts:103-106; typebox-behaviour.mjs).
399
+ 20. Type.Date and Type.Uint8Array were removed in 1.0; the migration guide rebuilds them with Type.Unsafe + Type.Refine.
400
+ 21. An invalid Date (new Date("nope")) passes as a Date, and NaN passes as a number unless the numeric/finite transform flags are set.
401
+ 22. A JS Map passes a map type vacuously (it has no own keys): new Map([['a', 'x']]) is valid for values int and encodes as an empty map (lib/types.js:1799-1830).
402
+ 23. verify() rejects a BigInt for int64 ("integer|Long expected") although fromObject and toObject accept it.
403
+ 24. A field validate runs even when the type check already failed (both messages reported).
404
+ 25. Async needs the parallel *Async API (objectAsync, pipeAsync, checkAsync). In plain JS, the sync safeParse of an async schema reports success: true for invalid input (the Promise has no issues); TypeScript forbids the call.
405
+ 26. A narrow that returns a Promise passes, because the predicate result is only tested for truthiness.
406
+ 27. TaskDecoder belongs to the experimental modules (lib/TaskDecoder.d.ts:2, "independent and backward-incompatible with stable ones").
407
+ 28. An async predicate silently passes every value (its promise is truthy).
408
+ 29. An async predicate silently passes every value.
409
+ 30. custom() given an async function passes and returns a Promise as the value (research-scripts/joi-extra.mjs).
410
+ 31. validateSync() skips async validators silently and reports the value valid (Validator.js:31; script).
411
+ 32. A refinement that returns a promise is not awaited: Value.Check returns true, and a compiled Check returns the Promise object itself, so the value is accepted.
412
+ 33. The Ajv security guide says not to use allErrors: true in production (research/ajv-src/docs/security.md:41).
413
+ 34. An unknown nested key loses its path: { nested: { extra } } reports Field "extra" (research-scripts/metarhia-basics.mjs).
414
+ 35. In @valibot/i18n 1.3.0 the CommonJS root entry does not load (index.cjs declares <code>var import_zh-CN</code>, a SyntaxError); ESM and per-locale imports work.
415
+ 36. Keys named like Struct.prototype members (constructor, check, __proto__) pass silently: this[name] finds the inherited member (lib/struct.js:29-34).
416
+ 37. The same schema keeps unknown keys under check()/guard() and drops them under parse().
417
+ 38. noUnknown() strips unknown keys instead of rejecting them unless the schema is strict() (the README warns about it); exact() rejects.
418
+ 39. No way to reject unknown keys.
419
+ 40. whitelist deletes the keys from the validated object itself; forbidUnknownValues (default true) rejects an object with no metadata, so a plain object fails.
420
+ 41. equals accepts an extra key whose value is undefined.
421
+ 42. Each policy belongs to a different API: verify ignores, fromObject strips, ProtoJSON fromJson rejects by default.
422
+ 43. <code>check(null)</code> throws.
423
+ 44. validateSync is deprecated in 9.x and emits a process warning on every call (research-scripts/mongoose-custom.mjs); validate() rejects; the constructor throws for strict: 'throw' and cyclic input.
424
+ 45. The classic API installs a memoizer: a self-referencing value parses (output keeps the cycle), unless the cycle closes through a transform ($ZodCyclicError). zod/mini has no memoizer unless configured. 10 000-deep input overflows the stack.
425
+ 46. The RangeError surfaces as a defect: the Result/Exit adapters throw "Result adapter can only return schema issues".
426
+ 47. The RangeError of a cyclic or 3 000-deep value is returned as an issue whose path is thousands of keys long.
427
+ 48. A cycle is accepted (coinductive), and there is no depth limit.
428
+ 49. Defaults apply only on the coercing calls (create, mask, validate with coerce: true), not in is()/assert().
429
+ 50. The default is a value, not a factory: default([]) hands every parse the same array (script).
430
+ 51. Defaults are written into the input object, and not inside anyOf/oneOf/not.
431
+ 52. Value.Parse and Compile().Parse never fill defaults (only with the global correctiveParse setting, and only for a value that fails the check); Value.Decode does, and Compile().Decode does only when the type contains a codec.
432
+ 53. Lenient: number().coerce() turns "1abc" into 1, number() accepts NaN, bigint() accepts true (script).
433
+ 54. number() also rejects values beyond Number.MAX_SAFE_INTEGER unless unsafe() (types/number.js:104).
434
+ 55. fromObject does not validate: { age: 'abc' } becomes 0 and { name: 42 } "42".
435
+ 56. Only number/string/boolean are typed: a nested struct, enum, array or custom type is rendered as string (profile: string), and a reference as &lt;name&gt;Id: string although check validates the embedded record.
436
+ 57. Schemas do not carry ~standard themselves ('~standard' in schema is false); wrap with Schema.toStandardSchemaV1 / toStandardJSONSchemaV1.
437
+ 58. ~standard.validate always returns a promise and runs with abortEarly: false; array indexes come back as strings.
438
+ 59. ~standard.validate puts the dotted field string in path (the specification wants an array) and, for a valid falsy output (false, 0, ''), returns { issues: undefined } without the value. Schemas themselves have no ~standard; vine.create() validators do.
439
+ 60. On models only (a Schema has none), and validate always returns a promise; it casts, so { n: '5' } is valid with value n: 5.
440
+ 61. Its JSDoc calls it semi-experimental.
441
+ 62. Marked @stability unstable.
442
+ 63. An id is never accepted, while the generated dts names the field companyId: string.
443
+ 64. A populated document is not validated with its own schema (an invalid Dog passes).
444
+ 65. The labels are reversed: a many field is labelled many-to-one and a single reference one-to-many.
445
+ 66. A resolver either builds or throws for one reader/writer pair; there is no backward/forward/full classification.
446
+ 67. Any non-integer number below 2^53 is inferred as float (32-bit), which loses precision when encoded (lib/types.js:247-252).
447
+ 68. Works on Effect Channels/Streams (unstable), not on Web Streams directly.
448
+ 69. Both are @stability unstable; the interpreter is the default.
449
+
450
+ <!-- comparison:end -->
85
451
 
86
452
  ## Installation
87
453
 
@@ -102,7 +468,7 @@ TypeScript 5.0 or newer.
102
468
  | Optional | `subtitle: '?string'` or `'subtitle?': 'string'` | the key may be absent, `undefined` or `null` |
103
469
  | Nullable | `parent: { type: 'string', nullable: true }` | the key is required, the value may be `null` |
104
470
  | Long form | `login: { type: 'string', length: [3, 32] }` | a type with options, `type` first |
105
- | Rules | `{ type: 'integer', min: 18, max: 120 }`, `{ type: 'string', pattern: '^[a-z]+$', length: { max: 32 } }` | `min`/`max` for numbers, `length`/`pattern` for strings, `length` for collections |
471
+ | Rules | `{ type: 'integer', min: 18, max: 120 }`, `{ type: 'string', pattern: '^[a-z]+$', length: { max: 32 } }` | `min`/`max` for numbers, `length`/`pattern`/`format` for strings, `length` for collections |
106
472
  | Collections | `{ array: 'number' }`, `{ set: 'string' }`, `{ object: { string: 'number' } }`, `{ map: { string: 'string' } }` | |
107
473
  | Enum | `{ enum: ['admin', 'user'] }` | one of the values |
108
474
  | Tuple | `point: ['number', 'number']` | a fixed-length array, each element its own definition |
@@ -114,14 +480,14 @@ TypeScript 5.0 or newer.
114
480
 
115
481
  The first key of an object decides what it is. Built-in types: `string`, `number`, `integer`,
116
482
  `bigint`, `boolean`, `date`, `null`, `any`/`unknown`, `enum`, `array`, `set`, `object`, `map`,
117
- `tuple`, `union`, `json`. Rules: `length` (with `unicode: true` for code points) and `pattern`
118
- for strings, `length` for collections, `min`/`max` for numbers; a rule on a type that does not
483
+ `tuple`, `union`, `json`. Rules: `length` (with `unicode: true` for code points), `pattern` and
484
+ `format` for strings, `length` for collections, `min`/`max` for numbers; a rule on a type that does not
119
485
  take it is a definition error. Fields can add a `validate(value, path)` function, and a schema
120
486
  can have a top-level `validate` for rules across fields. `check(value, options)` takes `root`
121
487
  (the label of the error lines), `maxErrors`, `unknown: 'ignore'` (keys the schema does not have;
122
488
  `{ Struct: { unknown: 'ignore' } }` makes it the schema's default), `references` (`'kind'`,
123
489
  `'embed'` or `'id'`) and `messages` (a locale); the result has `issues`, `errors`, `summary`,
124
- `flatten()` and `tree()`. `schema.warnings` lints the definition (a mistyped option, a `pattern`
490
+ `flatten()`, `tree()` and `toJSON()`. `schema.warnings` lints the definition (a mistyped option, a `pattern`
125
491
  without `length.max`). See [Schema Syntax](https://metaschema.vercel.app/guide/schema-syntax),
126
492
  [Types](https://metaschema.vercel.app/guide/types),
127
493
  [Unions, nullable and null](https://metaschema.vercel.app/guide/unions),
@@ -191,6 +557,78 @@ generated types alike. See
191
557
  [Custom Types](https://metaschema.vercel.app/guide/custom-types) and
192
558
  [Domain Models](https://metaschema.vercel.app/guide/model).
193
559
 
560
+ ## String formats
561
+
562
+ `format` names a form a string must have; `@alexify/metaschema/formats` registers the nine
563
+ built-in formats and your own, once per process:
564
+
565
+ ```js
566
+ const { register } = require('@alexify/metaschema/formats');
567
+ register({ phone: { test: (value) => /^\+\d{9,15}$/.test(value), examples: ['+380501234567'] } });
568
+
569
+ const signup = Schema.from({
570
+ email: { type: 'string', format: 'email', length: { max: 254 } },
571
+ phone: { type: 'string', format: 'phone' },
572
+ });
573
+ signup.check({ email: 'ann@', phone: '050' }).errors;
574
+ // [ 'Field "email" is not a valid email', 'Field "phone" is not a valid phone' ]
575
+ ```
576
+
577
+ A format the table does not know is a definition error, never a check that passes everything;
578
+ `toJSONSchema` writes the name, `fromJSONSchema` reads it back, `sample` draws the format's
579
+ examples and `infer` reads a format out of the strings. See
580
+ [String formats](https://metaschema.vercel.app/guide/formats).
581
+
582
+ ## Records and streams
583
+
584
+ `@alexify/metaschema/stream` runs a schema over a sequence of records, lazily and in order:
585
+
586
+ ```js
587
+ const { checkEach, parseEach, transform } = require('@alexify/metaschema/stream');
588
+
589
+ for (const { index, record, result } of checkEach(user, rows)) {
590
+ if (!result.valid) console.log(index, result.errors);
591
+ }
592
+ for (const { result } of parseEach(user, rows, { unknown: 'strip', maxInvalid: 10 })) save(result.value);
593
+
594
+ const parsed = ReadableStream.from(rows).pipeThrough(
595
+ transform(user, { onInvalid: (record, result, index) => log(index, result.issues) }),
596
+ );
597
+ ```
598
+
599
+ `checkEachAsync` and `parseEachAsync` take a sync or async source and keep `concurrency` records
600
+ in flight; `maxInvalid` ends an iteration after that many invalid records, and a `transform`
601
+ without `onInvalid` ends its stream with `ERR_INVALID_RECORD`. See
602
+ [Records and streams](https://metaschema.vercel.app/guide/streaming).
603
+
604
+ ## Inferring a definition
605
+
606
+ `infer` of `@alexify/metaschema/model` reads a definition out of the values that exist, the
607
+ reverse of `sample`, to bootstrap a model from the documents of a collection or the rows of a
608
+ table:
609
+
610
+ ```js
611
+ const { infer } = require('@alexify/metaschema/model');
612
+
613
+ infer([
614
+ { id: 'ord-1', total: 12.5, status: 'paid', address: { city: 'Kyiv', zip: '01001' } },
615
+ { id: 'ord-2', total: 7, status: 'new', address: { city: 'Lviv', zip: null }, coupon: 'X1' },
616
+ ]);
617
+ // {
618
+ // Struct: {},
619
+ // id: 'string',
620
+ // total: 'number',
621
+ // status: 'string',
622
+ // address: { city: 'string', zip: { type: 'string', nullable: true } },
623
+ // coupon: '?string',
624
+ // }
625
+ ```
626
+
627
+ Records fuse into one struct with optional keys, a string of few recurring values is an `enum`,
628
+ records whose keys are data are a dictionary, and the definition is checked against every
629
+ sample before it comes back. See
630
+ [Schema inference](https://metaschema.vercel.app/guide/infer).
631
+
194
632
  ## TypeScript
195
633
 
196
634
  A schema keeps its definition as a type parameter, and `InferSchema` turns it into the type of
@@ -226,7 +664,7 @@ tuples, unions, nested structs, references (an id, or the record through an enti
226
664
  augmentation of `CustomTypes`. A model renders its entities as interfaces with `toTypeScript`. See
227
665
  [TypeScript](https://metaschema.vercel.app/guide/typescript).
228
666
 
229
- A `Schema<D>` is also a `StandardSchemaV1<Infer<D>, Infer<D>>` of `@standard-schema/spec`:
667
+ A `Schema<D>` is also a `StandardSchemaV1<Infer<D>, InferOutput<D>>` of `@standard-schema/spec`:
230
668
  `schema['~standard']` is typed as `StandardProps<D>`, with `StandardResult<T>` and
231
669
  `StandardOptions` beside it. See
232
670
  [Standard Schema](https://metaschema.vercel.app/guide/standard-schema).
@@ -278,9 +716,10 @@ Cloudflare Workers, `node --disallow-code-generation-from-strings`) nothing chan
278
716
  closures stay, silently unless `{ jit: true }` asks for an error.
279
717
 
280
718
  ```js
281
- const { compile, register, canEval } = require('@alexify/metaschema/compile');
719
+ const { compile, compiled, register, canEval } = require('@alexify/metaschema/compile');
282
720
 
283
721
  compile(user); // { accelerated: true }: user.check runs generated code now
722
+ compiled(user); // true
284
723
  compile(model); // every entity; { accelerated: false } where there is no eval
285
724
  register(); // every schema built from here on is compiled as it is built
286
725
  canEval(); // whether this environment builds functions from source
@@ -298,8 +737,11 @@ const {
298
737
  getKindMetadata, Schema, Model, SchemaDefinitionError, ValidationResult,
299
738
  } = require('@alexify/metaschema');
300
739
 
301
- const { toJSONSchema, toTypeScript, saveTypes, register } = require('@alexify/metaschema/generators');
302
- const { compile, canEval } = require('@alexify/metaschema/compile'); // and its own register()
740
+ const { toJSONSchema, toTypeScript, saveTypes, fromJSONSchema, register } = require('@alexify/metaschema/generators');
741
+ const { compile, compiled, canEval } = require('@alexify/metaschema/compile'); // and its own register()
742
+ const { fromJSON, diff, compatibility, compatibilityOf, sample, merge, infer } = require('@alexify/metaschema/model'); // and its own register()
743
+ const { checkEach, parseEach, checkEachAsync, parseEachAsync, transform } = require('@alexify/metaschema/stream'); // and its own register()
744
+ const { FORMATS, register: registerFormats } = require('@alexify/metaschema/formats'); // fills the table the format rule reads
303
745
 
304
746
  const en = require('@alexify/metaschema/locales/en'); // the built-in messages
305
747
  const uk = require('@alexify/metaschema/locales/uk'); // schema.check(value, { messages: uk })
@@ -330,7 +772,11 @@ promise, a graph deeper than 128 embedded records is a `depth` issue (`maxDepth`
330
772
  `Infer` makes a defaulted key optional, and a few definitions that could never work throw when
331
773
  the schema is built. Everything else is additive: `parse`, `serialize`, `checkAsync` and
332
774
  `parseAsync`, the JSON Schema export, the JIT backend of `@alexify/metaschema/compile`, JSDoc
333
- and named types. The step-by-step guide with before-and-after examples is
775
+ and named types. 3.1 and 3.2 add without breaking, with a few behaviours a 2.x program meets on
776
+ the way: two fields of one key and a non-list `aliases` are definition errors,
777
+ `JSON.stringify(model)` writes the snapshot, the issues of an async check come in walk order
778
+ then field order, a `pattern` is not run past `length.max`, and the `unexpected` message lists
779
+ ten keys. The step-by-step guide with before-and-after examples is
334
780
  [Migrating from 2.x](https://metaschema.vercel.app/guide/migrating-from-2); the full list is
335
781
  under "Upgrading from 2.0" in the [CHANGELOG](./CHANGELOG.md).
336
782