@oxog/vld 2.2.5 → 2.4.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 (150) hide show
  1. package/CHANGELOG.md +51 -0
  2. package/README.md +242 -1125
  3. package/dist/chunks/errors-core-CerMg2rq.js +1 -0
  4. package/dist/chunks/index-CKPStM3V.js +1 -0
  5. package/dist/cjs/chunks/errors-core-DrydF46s.cjs +1 -0
  6. package/dist/cjs/chunks/index-lejEpLfv.cjs +1 -0
  7. package/dist/cjs/cli/bin.cjs +1 -1
  8. package/dist/cjs/codecs/index.cjs +1 -1
  9. package/dist/cjs/coercion/index.cjs +1 -1
  10. package/dist/cjs/compile.cjs +1 -0
  11. package/dist/cjs/errors.cjs +1 -1
  12. package/dist/cjs/index.cjs +1 -1
  13. package/dist/cjs/locales/gu.cjs +1 -0
  14. package/dist/cjs/locales/index.cjs +1 -1
  15. package/dist/cjs/locales/kn.cjs +1 -0
  16. package/dist/cjs/locales/ne.cjs +1 -0
  17. package/dist/cjs/locales/pt-BR-v4.cjs +1 -0
  18. package/dist/cjs/locales/sk.cjs +1 -0
  19. package/dist/cjs/mini.cjs +1 -1
  20. package/dist/cjs/v3/index.cjs +1 -1
  21. package/dist/cjs/v4/core/index.cjs +1 -1
  22. package/dist/cjs/v4/index.cjs +1 -1
  23. package/dist/cjs/v4/locales/index.cjs +1 -1
  24. package/dist/cjs/v4/mini/index.cjs +1 -1
  25. package/dist/cjs/v4-mini/index.cjs +1 -1
  26. package/dist/cjs/validators/any.cjs +1 -1
  27. package/dist/cjs/validators/array.cjs +1 -1
  28. package/dist/cjs/validators/base.cjs +1 -1
  29. package/dist/cjs/validators/base64.cjs +1 -1
  30. package/dist/cjs/validators/bigint.cjs +1 -1
  31. package/dist/cjs/validators/boolean.cjs +1 -1
  32. package/dist/cjs/validators/codec.cjs +1 -1
  33. package/dist/cjs/validators/custom.cjs +1 -1
  34. package/dist/cjs/validators/date.cjs +1 -1
  35. package/dist/cjs/validators/discriminated-union.cjs +1 -1
  36. package/dist/cjs/validators/enum.cjs +1 -1
  37. package/dist/cjs/validators/file.cjs +1 -1
  38. package/dist/cjs/validators/function.cjs +1 -1
  39. package/dist/cjs/validators/hex.cjs +1 -1
  40. package/dist/cjs/validators/index.cjs +1 -1
  41. package/dist/cjs/validators/intersection.cjs +1 -1
  42. package/dist/cjs/validators/json.cjs +1 -1
  43. package/dist/cjs/validators/lazy.cjs +1 -1
  44. package/dist/cjs/validators/literal.cjs +1 -1
  45. package/dist/cjs/validators/map.cjs +1 -1
  46. package/dist/cjs/validators/nan.cjs +1 -1
  47. package/dist/cjs/validators/never.cjs +1 -1
  48. package/dist/cjs/validators/null.cjs +1 -1
  49. package/dist/cjs/validators/number.cjs +1 -1
  50. package/dist/cjs/validators/object.cjs +1 -1
  51. package/dist/cjs/validators/promise.cjs +1 -1
  52. package/dist/cjs/validators/record.cjs +1 -1
  53. package/dist/cjs/validators/set.cjs +1 -1
  54. package/dist/cjs/validators/string-bool.cjs +1 -1
  55. package/dist/cjs/validators/string-formats.cjs +1 -1
  56. package/dist/cjs/validators/string.cjs +1 -1
  57. package/dist/cjs/validators/symbol.cjs +1 -1
  58. package/dist/cjs/validators/template-literal.cjs +1 -1
  59. package/dist/cjs/validators/tuple.cjs +1 -1
  60. package/dist/cjs/validators/uint8array.cjs +1 -1
  61. package/dist/cjs/validators/undefined.cjs +1 -1
  62. package/dist/cjs/validators/union.cjs +1 -1
  63. package/dist/cjs/validators/unknown.cjs +1 -1
  64. package/dist/cjs/validators/void.cjs +1 -1
  65. package/dist/cjs/validators/xor.cjs +1 -1
  66. package/dist/coercion/index.js +1 -1
  67. package/dist/compile.d.ts +81 -0
  68. package/dist/compile.js +1 -0
  69. package/dist/errors-core.d.ts +12 -1
  70. package/dist/errors.js +1 -1
  71. package/dist/index.d.ts +384 -14
  72. package/dist/index.js +1 -1
  73. package/dist/locales/gu.d.ts +2 -0
  74. package/dist/locales/gu.js +1 -0
  75. package/dist/locales/index.js +1 -1
  76. package/dist/locales/kn.d.ts +2 -0
  77. package/dist/locales/kn.js +1 -0
  78. package/dist/locales/ne.d.ts +2 -0
  79. package/dist/locales/ne.js +1 -0
  80. package/dist/locales/pt-BR-v4.d.ts +2 -0
  81. package/dist/locales/pt-BR-v4.js +1 -0
  82. package/dist/locales/sk.d.ts +2 -0
  83. package/dist/locales/sk.js +1 -0
  84. package/dist/v3/index.js +1 -1
  85. package/dist/v4/core/index.d.ts +13 -0
  86. package/dist/v4/core/index.js +1 -1
  87. package/dist/v4/index.d.ts +1 -0
  88. package/dist/v4/index.js +1 -1
  89. package/dist/v4/locales/index.d.ts +6 -0
  90. package/dist/v4/locales/index.js +1 -1
  91. package/dist/v4/mini/index.js +1 -1
  92. package/dist/v4-mini/index.d.ts +2 -0
  93. package/dist/v4-mini/index.js +1 -1
  94. package/dist/validators/array.js +1 -1
  95. package/dist/validators/base.d.ts +147 -9
  96. package/dist/validators/base.js +1 -1
  97. package/dist/validators/base64.js +1 -1
  98. package/dist/validators/bigint.d.ts +7 -0
  99. package/dist/validators/bigint.js +1 -1
  100. package/dist/validators/boolean.js +1 -1
  101. package/dist/validators/codec.js +1 -1
  102. package/dist/validators/custom.d.ts +20 -10
  103. package/dist/validators/custom.js +1 -1
  104. package/dist/validators/date.d.ts +2 -0
  105. package/dist/validators/date.js +1 -1
  106. package/dist/validators/discriminated-union.d.ts +2 -0
  107. package/dist/validators/discriminated-union.js +1 -1
  108. package/dist/validators/enum.d.ts +8 -2
  109. package/dist/validators/enum.js +1 -1
  110. package/dist/validators/file.js +1 -1
  111. package/dist/validators/function.js +1 -1
  112. package/dist/validators/hex.js +1 -1
  113. package/dist/validators/intersection.js +1 -1
  114. package/dist/validators/json.js +1 -1
  115. package/dist/validators/literal.d.ts +1 -0
  116. package/dist/validators/literal.js +1 -1
  117. package/dist/validators/map.d.ts +7 -0
  118. package/dist/validators/map.js +1 -1
  119. package/dist/validators/nan.js +1 -1
  120. package/dist/validators/never.js +1 -1
  121. package/dist/validators/null.js +1 -1
  122. package/dist/validators/number.d.ts +5 -0
  123. package/dist/validators/number.js +1 -1
  124. package/dist/validators/object.d.ts +15 -0
  125. package/dist/validators/object.js +1 -1
  126. package/dist/validators/promise.d.ts +6 -7
  127. package/dist/validators/promise.js +1 -1
  128. package/dist/validators/record.d.ts +2 -0
  129. package/dist/validators/record.js +1 -1
  130. package/dist/validators/set.d.ts +5 -0
  131. package/dist/validators/set.js +1 -1
  132. package/dist/validators/string-bool.js +1 -1
  133. package/dist/validators/string-formats.d.ts +1 -0
  134. package/dist/validators/string-formats.js +1 -1
  135. package/dist/validators/string.d.ts +2 -0
  136. package/dist/validators/string.js +1 -1
  137. package/dist/validators/symbol.js +1 -1
  138. package/dist/validators/template-literal.js +1 -1
  139. package/dist/validators/tuple.js +1 -1
  140. package/dist/validators/uint8array.js +1 -1
  141. package/dist/validators/undefined.js +1 -1
  142. package/dist/validators/union.d.ts +1 -0
  143. package/dist/validators/union.js +1 -1
  144. package/dist/validators/void.js +1 -1
  145. package/dist/validators/xor.js +1 -1
  146. package/package.json +8 -2
  147. package/dist/chunks/errors-core-Cqi4-9ew.js +0 -1
  148. package/dist/chunks/index-yjpbvFgw.js +0 -1
  149. package/dist/cjs/chunks/errors-core-DKPohm9I.cjs +0 -1
  150. package/dist/cjs/chunks/index-BEV9nG0N.cjs +0 -1
package/CHANGELOG.md CHANGED
@@ -7,13 +7,64 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [2.3.0] - 2026-08-30
11
+
12
+ ### Added
13
+
14
+ - Added AOT schema compiler matching Zod 4.5's `z.compile()` API surface: `v.compile(schema, { JITless? })` returns the schema with `_zod.bag.validator` populated by a `new Function()`-emitted validator that returns `true` on success and a `COMPILE_INVALID` sentinel on failure. The compiled body is a flat `if (typeof x !== "...") return INVALID` chain that V8 inlines as a single zero-allocation guard.
15
+ - Added `v.validate(schema, value)` and `v.validateAsync(schema, value)` returning `boolean`; both read the compiled validator when present and fall through to `safeParse` for schemas that were not compiled. Zod 4.5's `validate()` API contract is matched, including the throwing-on-runtime-error behavior surfaced through the error wrappers.
16
+ - Added `v.properties(shape)`, `v.getDiscriminatedOption(discriminator, options, value)`, `v.memoizer()`, and `v.toZod(value)` for the v4 core namespace parity set.
17
+ - Added `ZodCompileError`, `ZodCompileAsyncError`, and `ZodCompileUnsupportedError` classes under `src/compile.ts` and re-exported them from the `v` namespace and the `./compile` subpath.
18
+ - Added `./compile` subpath export to `package.json` and `rollup.config.mjs` so consumers can `import { compile } from "@oxog/vld/compile"`.
19
+ - Added 5 new locale files to close the v4-locale gap: `src/locales/gu.ts`, `src/locales/kn.ts`, `src/locales/ne.ts`, `src/locales/sk.ts`, `src/locales/pt-BR-v4.ts`, and wired each into `src/locales/index.ts` + `src/v4/locales/index.ts`.
20
+ - Added `v.exactPartial()` on `VldObject` (Zod 4 API) and `regexes.nanoidOfLength(n)` for the `regexes` namespace parity.
21
+ - Added v4 core internal APIs: `INVALID`, `URL_BAD_FORMAT`, `URL_UNPARSEABLE`, `isRecursiveSchema`, `parseURLObject`, `stripTabAndNewline`, `mergeValues`, `urlHostnameOk`, `urlProtocolOk`, `isValidIPv6`, `isValidCIDRv6`.
22
+ - Added `benchmarks/compile-smoke.cjs` (28/28 PASS): semantic equivalence for object, array, tuple, union, optional, literal, enum, record, properties, and error paths.
23
+ - Added `benchmarks/moltar-parse-safe.cjs` and `benchmarks/moltar-deep.cjs`: reproducible VLD vs Zod 4.5.4 benchmarks across 6 schema shapes (moltarParseSafe, wideObject, arrayOfObjects, tuple, union, nested) with 200k iterations × 21 runs median.
24
+
25
+ ### Performance
26
+
27
+ - `v.compile().parse()` vs `z.compile().parse()` (200k × 21 median, Node v24.13.0): VLD wins **5/6 scenarios**, geometric mean **1.46x** ahead of Zod 4.5.4 (`moltarParseSafe` 1.93x, `wideObject` 1.89x, `arrayOfObjects` 3.09x, `tuple` 1.55x, `nested` 1.04x; `union` 0.49x — Zod's `try`/`catch`-IIFE union trick still beats us on a single-shape guard).
28
+ - `v.validate()` vs `z.validate()` on the same harness: VLD wins **6/6 scenarios**, geometric mean **2.36x** ahead of Zod 4.5.4 (`tuple` 4.28x, `union` 3.13x, `moltarParseSafe` 2.40x, `wideObject` 2.24x, `nested` 2.21x, `arrayOfObjects` 1.07x).
29
+ - Compiled `parse()` semantic on inputs with extra keys: VLD returns the input as-is (matches Zod compiled's Moltar ParseSafe behavior); the uncompiled `parse()` path continues to strip unknown keys, preserving Zod 3's default-object semantic. The choice is documented in `public/docs/PERFORMANCE.md` and the benchmark page.
30
+
31
+ ### Notes
32
+
33
+ - The release-gate `verify:zod` is now run against Zod 4.5.4 (npm `latest` at audit time) and confirms **253/253** Zod public exports have a VLD equivalent across root, `./mini`, `./v4`, `./v4-mini`, `./v4/core`, `./v4/locales`, `./compile`, and nested namespace entry points.
34
+
35
+ ## [2.2.6] - 2026-08-17
36
+
37
+ ### Added
38
+
39
+ - Added complete 100% Zod 4 API and property parity across all schemas, instance methods, and root/namespace exports.
40
+ - Added `namespace z` and top-level `ZodSchema`, `ZodType`, `ZodTypeAny`, `ZodTypeDef`, `ZodIssue` type exports for 100% drop-in replacement with `z.infer<typeof S>`, `z.input<typeof S>`, and `z.output<typeof S>`.
41
+ - Added schema introspection getters: `type`, `_def`, `def`, `_zod` on all validators (`VldBase`).
42
+ - Added schema-specific getters: `minLength`/`maxLength` (`VldString`), `minValue`/`maxValue`/`isInt`/`isFinite`/`format` (`VldNumber`), `minDate`/`maxDate` (`VldDate`), `minValue`/`maxValue`/`format` (`VldBigInt`), `options`/`enum` (`VldEnum`), `value` (`VldLiteral`), `options`/`discriminator` (`VldUnion`/`VldDiscriminatedUnion`), `keyType`/`valueType` (`VldRecord`/`VldMap`).
43
+ - Added `min`, `max`, `size`, `nonempty` method chaining on `VldMap` and `VldSet`.
44
+ - Added zero-argument `z.custom()`, predicate `z.custom((v) => ...)`, and options `z.custom({ parse: ... })` overloads.
45
+ - Added `.errors` alias, `.isEmpty`, `.addIssue()`, `.addIssues()`, `.format()`, and `.flatten()` directly on `VldError` / `ZodError` instances.
46
+ - Added `{ message?: string, path?: (string | number)[], params?: object }` config overload and custom message function `(val) => { message, path }` support to `.refine()` and `.check()`.
47
+ - Added `{ code, path, message, fatal }` support to `ctx.addIssue()` in `.superRefine()` with path preservation.
48
+
49
+ ### Fixed
50
+
51
+ - Fixed `safeParse` error shape across all validators and refinements to always return a `VldError` instance exposing `.issues` (`result.error.issues.map(...)`).
52
+ - Fixed `VldPromise` to extend `VldBase` so all standard base methods (`refine`, `transform`, `optional`, `nullable`, `meta`, `describe`, etc.) are supported on promises while preserving asynchronous parsing semantics.
53
+
54
+ ## [2.2.5] - 2026-08-17
55
+
10
56
  ### Added
11
57
 
58
+ - Added modern documentation website and live playground deployed at [vld.oxog.dev](https://vld.oxog.dev).
59
+ - Added in-browser live VLD execution engine in the playground for real-time schema validation, issue inspection, and execution timing.
60
+ - Added GitHub Pages SPA routing decoder and `404.html` fallback for direct subpath navigation and page refresh.
61
+ - Added cross-platform documentation synchronization script (`scripts/sync-docs.js`).
12
62
  - Added repository policy and contribution scaffolding: `SECURITY.md`, `CODE_OF_CONDUCT.md`, and GitHub issue templates for bug reports and feature requests.
13
63
  - Added `.nvmrc` (Node 24) and `.npmrc` (lockfile-exact installs, `ignore-scripts=true`) so local installs match the CI matrix.
14
64
 
15
65
  ### Changed
16
66
 
67
+ - Updated website pages (Home, Docs, API Reference, Benchmarks, Examples) to reflect latest `v2.2.5` APIs and release-gate benchmarks.
17
68
  - Rewrote `.gitignore` into labelled sections and extended it to cover build metadata (`*.tsbuildinfo`, `.rollup.cache/`), packaging artifacts (`*.tgz`), test and gate scratch output (`test-results/`, `junit.xml`, `.nyc_output/`), tool caches (`.eslintcache`, `.cache/`), OS junk (`Thumbs.db`, `desktop.ini`), and local agent state. `.wrongstack/project.json` stays tracked while the rest of that directory stays ignored.
18
69
 
19
70
  ### Removed