@oxog/vld 2.0.3 → 2.1.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 (449) hide show
  1. package/CHANGELOG.md +33 -1
  2. package/README.md +101 -37
  3. package/dist/chunks/errors-core-BeiFUtZM.js +81 -0
  4. package/dist/chunks/{index-DO8CFMxD.js → index-0R2ntSud.js} +16 -402
  5. package/dist/chunks/index-BvH403Yy.js +88 -0
  6. package/dist/chunks/security-B0Pd_vSY.js +35 -0
  7. package/dist/chunks/string-BJRQod3t.js +530 -0
  8. package/dist/cjs/chunks/errors-core-DWxLFs2f.cjs +83 -0
  9. package/dist/cjs/chunks/index-BkI37108.cjs +538 -0
  10. package/dist/cjs/chunks/index-Cc3bjUMX.cjs +91 -0
  11. package/dist/cjs/chunks/security-Dc3Jh13T.cjs +37 -0
  12. package/dist/cjs/chunks/string-BKZrc4hs.cjs +533 -0
  13. package/dist/cjs/cli/bin.cjs +506 -0
  14. package/dist/cjs/cli/index.cjs +209 -0
  15. package/dist/cjs/codecs/index.cjs +45 -0
  16. package/dist/{chunks/date-50JV_Mfj.js → cjs/coercion/index.cjs} +185 -103
  17. package/dist/cjs/compat/emitter.cjs +184 -0
  18. package/dist/cjs/compat/result.cjs +189 -0
  19. package/dist/cjs/errors.cjs +6 -213
  20. package/dist/cjs/index.cjs +1471 -10336
  21. package/dist/cjs/kernel.cjs +415 -0
  22. package/dist/cjs/locales/af.cjs +108 -0
  23. package/dist/cjs/locales/ar.cjs +108 -0
  24. package/dist/cjs/locales/bn.cjs +108 -0
  25. package/dist/cjs/locales/da.cjs +108 -0
  26. package/dist/cjs/locales/de.cjs +108 -0
  27. package/dist/cjs/locales/en.cjs +108 -0
  28. package/dist/cjs/locales/es-MX.cjs +107 -0
  29. package/dist/cjs/locales/es.cjs +96 -0
  30. package/dist/cjs/locales/fi.cjs +108 -0
  31. package/dist/cjs/locales/fr.cjs +96 -0
  32. package/dist/cjs/locales/hi.cjs +108 -0
  33. package/dist/cjs/locales/id.cjs +108 -0
  34. package/dist/cjs/locales/index.cjs +41 -2875
  35. package/dist/cjs/locales/it.cjs +108 -0
  36. package/dist/cjs/locales/ja.cjs +108 -0
  37. package/dist/cjs/locales/ko.cjs +108 -0
  38. package/dist/cjs/locales/lazy.cjs +42 -3023
  39. package/dist/cjs/locales/nl.cjs +108 -0
  40. package/dist/cjs/locales/no.cjs +108 -0
  41. package/dist/cjs/locales/pl.cjs +108 -0
  42. package/dist/cjs/locales/pt-BR.cjs +108 -0
  43. package/dist/cjs/locales/pt.cjs +108 -0
  44. package/dist/cjs/locales/ru.cjs +108 -0
  45. package/dist/cjs/locales/runtime.cjs +51 -0
  46. package/dist/cjs/locales/sv.cjs +108 -0
  47. package/dist/cjs/locales/sw.cjs +108 -0
  48. package/dist/cjs/locales/th.cjs +108 -0
  49. package/dist/cjs/locales/tr.cjs +108 -0
  50. package/dist/cjs/locales/vi.cjs +108 -0
  51. package/dist/cjs/locales/zh.cjs +108 -0
  52. package/dist/cjs/mini.cjs +121 -7353
  53. package/dist/cjs/pigment.cjs +207 -0
  54. package/dist/cjs/plugins/index.cjs +12 -0
  55. package/dist/cjs/registry.cjs +37 -0
  56. package/dist/cjs/v3/index.cjs +425 -0
  57. package/dist/cjs/v4/core/index.cjs +894 -0
  58. package/dist/cjs/v4/index.cjs +425 -0
  59. package/dist/cjs/v4/locales/index.cjs +130 -0
  60. package/dist/cjs/v4/mini/index.cjs +509 -0
  61. package/dist/cjs/v4-mini/index.cjs +532 -0
  62. package/dist/cjs/validators/any.cjs +40 -0
  63. package/dist/cjs/validators/array.cjs +283 -0
  64. package/dist/cjs/validators/base.cjs +887 -0
  65. package/dist/cjs/validators/base64.cjs +73 -0
  66. package/dist/cjs/validators/bigint.cjs +232 -0
  67. package/dist/cjs/validators/boolean.cjs +146 -0
  68. package/dist/cjs/validators/codec.cjs +205 -0
  69. package/dist/cjs/validators/custom.cjs +71 -0
  70. package/dist/cjs/validators/date.cjs +278 -0
  71. package/dist/cjs/validators/discriminated-union.cjs +130 -0
  72. package/dist/cjs/validators/enum.cjs +154 -0
  73. package/dist/cjs/validators/file.cjs +130 -0
  74. package/dist/cjs/validators/function.cjs +63 -0
  75. package/dist/cjs/validators/hex.cjs +70 -0
  76. package/dist/cjs/validators/index.cjs +123 -0
  77. package/dist/cjs/validators/intersection.cjs +120 -0
  78. package/dist/cjs/validators/json.cjs +70 -0
  79. package/dist/cjs/validators/lazy.cjs +53 -0
  80. package/dist/cjs/validators/literal.cjs +64 -0
  81. package/dist/cjs/validators/map.cjs +218 -0
  82. package/dist/cjs/validators/nan.cjs +41 -0
  83. package/dist/cjs/validators/never.cjs +36 -0
  84. package/dist/cjs/validators/null.cjs +43 -0
  85. package/dist/cjs/validators/number.cjs +427 -0
  86. package/dist/cjs/validators/object.cjs +868 -0
  87. package/dist/cjs/validators/promise.cjs +115 -0
  88. package/dist/cjs/validators/record.cjs +262 -0
  89. package/dist/cjs/validators/set.cjs +203 -0
  90. package/dist/cjs/validators/string-bool.cjs +124 -0
  91. package/dist/cjs/validators/string-formats.cjs +168 -0
  92. package/dist/cjs/validators/string.cjs +12 -0
  93. package/dist/cjs/validators/symbol.cjs +62 -0
  94. package/dist/cjs/validators/template-literal.cjs +108 -0
  95. package/dist/cjs/validators/tuple.cjs +187 -0
  96. package/dist/cjs/validators/uint8array.cjs +106 -0
  97. package/dist/cjs/validators/undefined.cjs +43 -0
  98. package/dist/cjs/validators/union.cjs +191 -0
  99. package/dist/cjs/validators/unknown.cjs +40 -0
  100. package/dist/cjs/validators/void.cjs +48 -0
  101. package/dist/cjs/validators/xor.cjs +69 -0
  102. package/dist/cli/bin.d.ts +0 -1
  103. package/dist/cli/bin.js +407 -0
  104. package/dist/cli/commands/benchmark.d.ts +1 -2
  105. package/dist/cli/commands/validate.d.ts +1 -2
  106. package/dist/cli/index.d.ts +0 -1
  107. package/dist/cli/index.js +205 -0
  108. package/dist/codecs/index.d.ts +21 -4
  109. package/dist/codecs/index.js +11 -4
  110. package/dist/coercion/bigint.d.ts +2 -3
  111. package/dist/coercion/boolean.d.ts +3 -3
  112. package/dist/coercion/date.d.ts +3 -3
  113. package/dist/coercion/index.d.ts +5 -6
  114. package/dist/coercion/index.js +473 -5
  115. package/dist/coercion/number.d.ts +2 -3
  116. package/dist/coercion/string.d.ts +2 -3
  117. package/dist/compat/emitter.d.ts +0 -1
  118. package/dist/compat/emitter.js +0 -1
  119. package/dist/compat/index.d.ts +4 -5
  120. package/dist/compat/result.d.ts +1 -2
  121. package/dist/compat/result.js +0 -1
  122. package/dist/errors-core.d.ts +39 -0
  123. package/dist/errors.d.ts +4 -54
  124. package/dist/errors.js +4 -68
  125. package/dist/events.d.ts +3 -4
  126. package/dist/index.d.ts +1186 -835
  127. package/dist/index.js +1046 -367
  128. package/dist/kernel.d.ts +2 -3
  129. package/dist/kernel.js +10 -6
  130. package/dist/locales/af.d.ts +1 -2
  131. package/dist/locales/af.js +0 -1
  132. package/dist/locales/ar.d.ts +1 -2
  133. package/dist/locales/ar.js +0 -1
  134. package/dist/locales/bn.d.ts +1 -2
  135. package/dist/locales/bn.js +0 -1
  136. package/dist/locales/da.d.ts +1 -2
  137. package/dist/locales/da.js +0 -1
  138. package/dist/locales/de.d.ts +1 -2
  139. package/dist/locales/de.js +0 -1
  140. package/dist/locales/en.d.ts +1 -2
  141. package/dist/locales/en.js +0 -1
  142. package/dist/locales/es-MX.d.ts +1 -2
  143. package/dist/locales/es-MX.js +0 -1
  144. package/dist/locales/es.d.ts +1 -2
  145. package/dist/locales/es.js +0 -1
  146. package/dist/locales/fi.d.ts +1 -2
  147. package/dist/locales/fi.js +0 -1
  148. package/dist/locales/fr.d.ts +1 -2
  149. package/dist/locales/fr.js +0 -1
  150. package/dist/locales/hi.d.ts +1 -2
  151. package/dist/locales/hi.js +0 -1
  152. package/dist/locales/id.d.ts +1 -2
  153. package/dist/locales/id.js +0 -1
  154. package/dist/locales/index.d.ts +10 -15
  155. package/dist/locales/index.js +28 -2
  156. package/dist/locales/it.d.ts +1 -2
  157. package/dist/locales/it.js +0 -1
  158. package/dist/locales/ja.d.ts +1 -2
  159. package/dist/locales/ja.js +0 -1
  160. package/dist/locales/ko.d.ts +1 -2
  161. package/dist/locales/ko.js +0 -1
  162. package/dist/locales/lazy.d.ts +4 -26
  163. package/dist/locales/lazy.js +12 -55
  164. package/dist/locales/nl.d.ts +1 -2
  165. package/dist/locales/nl.js +0 -1
  166. package/dist/locales/no.d.ts +1 -2
  167. package/dist/locales/no.js +0 -1
  168. package/dist/locales/pl.d.ts +1 -2
  169. package/dist/locales/pl.js +0 -1
  170. package/dist/locales/pt-BR.d.ts +1 -2
  171. package/dist/locales/pt-BR.js +0 -1
  172. package/dist/locales/pt.d.ts +1 -2
  173. package/dist/locales/pt.js +0 -1
  174. package/dist/locales/ru.d.ts +1 -2
  175. package/dist/locales/ru.js +0 -1
  176. package/dist/locales/runtime.d.ts +10 -0
  177. package/dist/locales/runtime.js +41 -0
  178. package/dist/locales/sv.d.ts +1 -2
  179. package/dist/locales/sv.js +0 -1
  180. package/dist/locales/sw.d.ts +1 -2
  181. package/dist/locales/sw.js +0 -1
  182. package/dist/locales/th.d.ts +1 -2
  183. package/dist/locales/th.js +0 -1
  184. package/dist/locales/tr.d.ts +1 -2
  185. package/dist/locales/tr.js +0 -1
  186. package/dist/locales/types.d.ts +0 -1
  187. package/dist/locales/vi.d.ts +1 -2
  188. package/dist/locales/vi.js +0 -1
  189. package/dist/locales/zh.d.ts +1 -2
  190. package/dist/locales/zh.js +0 -1
  191. package/dist/logger.d.ts +0 -1
  192. package/dist/mini.d.ts +64 -65
  193. package/dist/mini.js +31 -7
  194. package/dist/pigment.d.ts +0 -1
  195. package/dist/pigment.js +6 -4
  196. package/dist/plugins/index.d.ts +2 -3
  197. package/dist/plugins/index.js +1 -0
  198. package/dist/plugins/types.d.ts +4 -5
  199. package/dist/registry.d.ts +23 -0
  200. package/dist/registry.js +34 -0
  201. package/dist/utils/codec-utils.d.ts +0 -1
  202. package/dist/utils/deep-merge.d.ts +0 -1
  203. package/dist/utils/ip-validation.d.ts +0 -1
  204. package/dist/utils/json-schema.d.ts +16 -6
  205. package/dist/utils/security.d.ts +2 -6
  206. package/dist/v3/index.d.ts +2 -0
  207. package/dist/v3/index.js +46 -0
  208. package/dist/v4/core/index.d.ts +260 -0
  209. package/dist/v4/core/index.js +277 -0
  210. package/dist/v4/index.d.ts +4 -0
  211. package/dist/v4/index.js +50 -0
  212. package/dist/v4/locales/index.d.ts +53 -0
  213. package/dist/v4/locales/index.js +77 -0
  214. package/dist/v4/mini/index.d.ts +2 -0
  215. package/dist/v4/mini/index.js +47 -0
  216. package/dist/v4-mini/index.d.ts +22 -0
  217. package/dist/v4-mini/index.js +75 -0
  218. package/dist/validators/any.d.ts +7 -2
  219. package/dist/validators/any.js +37 -0
  220. package/dist/validators/array.d.ts +9 -2
  221. package/dist/validators/array.js +279 -0
  222. package/dist/validators/base.d.ts +150 -6
  223. package/dist/validators/base.js +868 -0
  224. package/dist/validators/base64.d.ts +1 -2
  225. package/dist/validators/base64.js +68 -0
  226. package/dist/validators/bigint.d.ts +21 -3
  227. package/dist/validators/bigint.js +228 -0
  228. package/dist/validators/boolean.d.ts +13 -4
  229. package/dist/validators/boolean.js +142 -0
  230. package/dist/validators/codec.d.ts +9 -2
  231. package/dist/validators/codec.js +200 -0
  232. package/dist/validators/custom.d.ts +15 -2
  233. package/dist/validators/custom.js +67 -0
  234. package/dist/validators/date.d.ts +19 -3
  235. package/dist/validators/date.js +274 -0
  236. package/dist/validators/discriminated-union.d.ts +4 -3
  237. package/dist/validators/discriminated-union.js +123 -0
  238. package/dist/validators/enum.d.ts +10 -7
  239. package/dist/validators/enum.js +150 -0
  240. package/dist/validators/file.d.ts +7 -2
  241. package/dist/validators/file.js +125 -0
  242. package/dist/validators/function.d.ts +11 -5
  243. package/dist/validators/function.js +58 -0
  244. package/dist/validators/hex.d.ts +1 -2
  245. package/dist/validators/hex.js +65 -0
  246. package/dist/validators/index.d.ts +38 -39
  247. package/dist/validators/index.js +35 -515
  248. package/dist/validators/intersection.d.ts +1 -2
  249. package/dist/validators/intersection.js +116 -0
  250. package/dist/validators/json.d.ts +1 -2
  251. package/dist/validators/json.js +66 -0
  252. package/dist/validators/lazy.d.ts +5 -9
  253. package/dist/validators/lazy.js +50 -0
  254. package/dist/validators/literal.d.ts +2 -2
  255. package/dist/validators/literal.js +60 -0
  256. package/dist/validators/map.d.ts +15 -2
  257. package/dist/validators/map.js +214 -0
  258. package/dist/validators/nan.d.ts +2 -3
  259. package/dist/validators/nan.js +38 -0
  260. package/dist/validators/never.d.ts +1 -2
  261. package/dist/validators/never.js +32 -0
  262. package/dist/validators/null.d.ts +3 -3
  263. package/dist/validators/null.js +40 -0
  264. package/dist/validators/number.d.ts +56 -27
  265. package/dist/validators/number.js +423 -0
  266. package/dist/validators/object.d.ts +30 -9
  267. package/dist/validators/object.js +864 -0
  268. package/dist/validators/promise.d.ts +15 -10
  269. package/dist/validators/promise.js +111 -0
  270. package/dist/validators/record.d.ts +11 -2
  271. package/dist/validators/record.js +258 -0
  272. package/dist/validators/set.d.ts +11 -2
  273. package/dist/validators/set.js +199 -0
  274. package/dist/validators/string-bool.d.ts +7 -10
  275. package/dist/validators/string-bool.js +120 -0
  276. package/dist/validators/string-formats.d.ts +7 -4
  277. package/dist/validators/string-formats.js +135 -0
  278. package/dist/validators/string.d.ts +39 -18
  279. package/dist/validators/string.js +4 -0
  280. package/dist/validators/symbol.d.ts +8 -3
  281. package/dist/validators/symbol.js +58 -0
  282. package/dist/validators/template-literal.d.ts +1 -2
  283. package/dist/validators/template-literal.js +103 -0
  284. package/dist/validators/tuple.d.ts +15 -2
  285. package/dist/validators/tuple.js +183 -0
  286. package/dist/validators/uint8array.d.ts +3 -4
  287. package/dist/validators/uint8array.js +101 -0
  288. package/dist/validators/undefined.d.ts +3 -3
  289. package/dist/validators/undefined.js +40 -0
  290. package/dist/validators/union.d.ts +7 -4
  291. package/dist/validators/union.js +187 -0
  292. package/dist/validators/unknown.d.ts +7 -2
  293. package/dist/{chunks/unknown-Dhzri_T-.js → validators/unknown.js} +12 -3
  294. package/dist/validators/void.d.ts +3 -2
  295. package/dist/validators/void.js +44 -0
  296. package/dist/validators/xor.d.ts +2 -3
  297. package/dist/validators/xor.js +66 -0
  298. package/package.json +114 -30
  299. package/dist/chunks/bigint-CRS0QVsy.js +0 -1854
  300. package/dist/chunks/bigint-CRS0QVsy.js.map +0 -1
  301. package/dist/chunks/date-50JV_Mfj.js.map +0 -1
  302. package/dist/chunks/index-DO8CFMxD.js.map +0 -1
  303. package/dist/chunks/json-Cp4WO0M9.js +0 -2021
  304. package/dist/chunks/json-Cp4WO0M9.js.map +0 -1
  305. package/dist/chunks/unknown-Dhzri_T-.js.map +0 -1
  306. package/dist/cjs/errors.cjs.map +0 -1
  307. package/dist/cjs/index.cjs.map +0 -1
  308. package/dist/cjs/locales/index.cjs.map +0 -1
  309. package/dist/cjs/locales/lazy.cjs.map +0 -1
  310. package/dist/cjs/mini.cjs.map +0 -1
  311. package/dist/cli/bin.d.ts.map +0 -1
  312. package/dist/cli/commands/benchmark.d.ts.map +0 -1
  313. package/dist/cli/commands/validate.d.ts.map +0 -1
  314. package/dist/cli/index.d.ts.map +0 -1
  315. package/dist/codecs/index.d.ts.map +0 -1
  316. package/dist/codecs/index.js.map +0 -1
  317. package/dist/coercion/bigint.d.ts.map +0 -1
  318. package/dist/coercion/boolean.d.ts.map +0 -1
  319. package/dist/coercion/date.d.ts.map +0 -1
  320. package/dist/coercion/index.d.ts.map +0 -1
  321. package/dist/coercion/index.js.map +0 -1
  322. package/dist/coercion/number.d.ts.map +0 -1
  323. package/dist/coercion/string.d.ts.map +0 -1
  324. package/dist/compat/emitter.d.ts.map +0 -1
  325. package/dist/compat/emitter.js.map +0 -1
  326. package/dist/compat/index.d.ts.map +0 -1
  327. package/dist/compat/result.d.ts.map +0 -1
  328. package/dist/compat/result.js.map +0 -1
  329. package/dist/errors.d.ts.map +0 -1
  330. package/dist/errors.js.map +0 -1
  331. package/dist/events.d.ts.map +0 -1
  332. package/dist/index.d.ts.map +0 -1
  333. package/dist/index.js.map +0 -1
  334. package/dist/kernel.d.ts.map +0 -1
  335. package/dist/kernel.js.map +0 -1
  336. package/dist/locales/af.d.ts.map +0 -1
  337. package/dist/locales/af.js.map +0 -1
  338. package/dist/locales/ar.d.ts.map +0 -1
  339. package/dist/locales/ar.js.map +0 -1
  340. package/dist/locales/backup-en.d.ts +0 -3
  341. package/dist/locales/backup-en.d.ts.map +0 -1
  342. package/dist/locales/bn.d.ts.map +0 -1
  343. package/dist/locales/bn.js.map +0 -1
  344. package/dist/locales/da.d.ts.map +0 -1
  345. package/dist/locales/da.js.map +0 -1
  346. package/dist/locales/de.d.ts.map +0 -1
  347. package/dist/locales/de.js.map +0 -1
  348. package/dist/locales/en.d.ts.map +0 -1
  349. package/dist/locales/en.js.map +0 -1
  350. package/dist/locales/es-MX.d.ts.map +0 -1
  351. package/dist/locales/es-MX.js.map +0 -1
  352. package/dist/locales/es.d.ts.map +0 -1
  353. package/dist/locales/es.js.map +0 -1
  354. package/dist/locales/fi.d.ts.map +0 -1
  355. package/dist/locales/fi.js.map +0 -1
  356. package/dist/locales/fr.d.ts.map +0 -1
  357. package/dist/locales/fr.js.map +0 -1
  358. package/dist/locales/hi.d.ts.map +0 -1
  359. package/dist/locales/hi.js.map +0 -1
  360. package/dist/locales/id.d.ts.map +0 -1
  361. package/dist/locales/id.js.map +0 -1
  362. package/dist/locales/index.d.ts.map +0 -1
  363. package/dist/locales/index.js.map +0 -1
  364. package/dist/locales/it.d.ts.map +0 -1
  365. package/dist/locales/it.js.map +0 -1
  366. package/dist/locales/ja.d.ts.map +0 -1
  367. package/dist/locales/ja.js.map +0 -1
  368. package/dist/locales/ko.d.ts.map +0 -1
  369. package/dist/locales/ko.js.map +0 -1
  370. package/dist/locales/lazy.d.ts.map +0 -1
  371. package/dist/locales/lazy.js.map +0 -1
  372. package/dist/locales/nl.d.ts.map +0 -1
  373. package/dist/locales/nl.js.map +0 -1
  374. package/dist/locales/no.d.ts.map +0 -1
  375. package/dist/locales/no.js.map +0 -1
  376. package/dist/locales/pl.d.ts.map +0 -1
  377. package/dist/locales/pl.js.map +0 -1
  378. package/dist/locales/pt-BR.d.ts.map +0 -1
  379. package/dist/locales/pt-BR.js.map +0 -1
  380. package/dist/locales/pt.d.ts.map +0 -1
  381. package/dist/locales/pt.js.map +0 -1
  382. package/dist/locales/ru.d.ts.map +0 -1
  383. package/dist/locales/ru.js.map +0 -1
  384. package/dist/locales/sv.d.ts.map +0 -1
  385. package/dist/locales/sv.js.map +0 -1
  386. package/dist/locales/sw.d.ts.map +0 -1
  387. package/dist/locales/sw.js.map +0 -1
  388. package/dist/locales/th.d.ts.map +0 -1
  389. package/dist/locales/th.js.map +0 -1
  390. package/dist/locales/tr.d.ts.map +0 -1
  391. package/dist/locales/tr.js.map +0 -1
  392. package/dist/locales/types.d.ts.map +0 -1
  393. package/dist/locales/vi.d.ts.map +0 -1
  394. package/dist/locales/vi.js.map +0 -1
  395. package/dist/locales/zh.d.ts.map +0 -1
  396. package/dist/locales/zh.js.map +0 -1
  397. package/dist/logger.d.ts.map +0 -1
  398. package/dist/mini.d.ts.map +0 -1
  399. package/dist/mini.js.map +0 -1
  400. package/dist/pigment.d.ts.map +0 -1
  401. package/dist/pigment.js.map +0 -1
  402. package/dist/plugins/index.d.ts.map +0 -1
  403. package/dist/plugins/types.d.ts.map +0 -1
  404. package/dist/utils/codec-utils.d.ts.map +0 -1
  405. package/dist/utils/deep-merge.d.ts.map +0 -1
  406. package/dist/utils/ip-validation.d.ts.map +0 -1
  407. package/dist/utils/json-schema.d.ts.map +0 -1
  408. package/dist/utils/security.d.ts.map +0 -1
  409. package/dist/validators/any.d.ts.map +0 -1
  410. package/dist/validators/array.d.ts.map +0 -1
  411. package/dist/validators/base.d.ts.map +0 -1
  412. package/dist/validators/base64.d.ts.map +0 -1
  413. package/dist/validators/bigint.d.ts.map +0 -1
  414. package/dist/validators/boolean.d.ts.map +0 -1
  415. package/dist/validators/codec.d.ts.map +0 -1
  416. package/dist/validators/custom.d.ts.map +0 -1
  417. package/dist/validators/date.d.ts.map +0 -1
  418. package/dist/validators/discriminated-union.d.ts.map +0 -1
  419. package/dist/validators/enum.d.ts.map +0 -1
  420. package/dist/validators/file.d.ts.map +0 -1
  421. package/dist/validators/function.d.ts.map +0 -1
  422. package/dist/validators/hex.d.ts.map +0 -1
  423. package/dist/validators/index.d.ts.map +0 -1
  424. package/dist/validators/index.js.map +0 -1
  425. package/dist/validators/intersection.d.ts.map +0 -1
  426. package/dist/validators/json.d.ts.map +0 -1
  427. package/dist/validators/lazy.d.ts.map +0 -1
  428. package/dist/validators/literal.d.ts.map +0 -1
  429. package/dist/validators/map.d.ts.map +0 -1
  430. package/dist/validators/nan.d.ts.map +0 -1
  431. package/dist/validators/never.d.ts.map +0 -1
  432. package/dist/validators/null.d.ts.map +0 -1
  433. package/dist/validators/number.d.ts.map +0 -1
  434. package/dist/validators/object.d.ts.map +0 -1
  435. package/dist/validators/promise.d.ts.map +0 -1
  436. package/dist/validators/record.d.ts.map +0 -1
  437. package/dist/validators/set.d.ts.map +0 -1
  438. package/dist/validators/string-bool.d.ts.map +0 -1
  439. package/dist/validators/string-formats.d.ts.map +0 -1
  440. package/dist/validators/string.d.ts.map +0 -1
  441. package/dist/validators/symbol.d.ts.map +0 -1
  442. package/dist/validators/template-literal.d.ts.map +0 -1
  443. package/dist/validators/tuple.d.ts.map +0 -1
  444. package/dist/validators/uint8array.d.ts.map +0 -1
  445. package/dist/validators/undefined.d.ts.map +0 -1
  446. package/dist/validators/union.d.ts.map +0 -1
  447. package/dist/validators/unknown.d.ts.map +0 -1
  448. package/dist/validators/void.d.ts.map +0 -1
  449. package/dist/validators/xor.d.ts.map +0 -1
@@ -0,0 +1,130 @@
1
+ 'use strict';
2
+
3
+ var validators_base = require('./base.cjs');
4
+ var locales_runtime = require('../locales/runtime.cjs');
5
+ var errorsCore = require('../chunks/errors-core-DWxLFs2f.cjs');
6
+ require('../registry.cjs');
7
+ require('../locales/en.cjs');
8
+
9
+ function createFileError(message) {
10
+ return new errorsCore.VldError([{ code: 'invalid_type', path: [], message }]);
11
+ }
12
+ /**
13
+ * Immutable file validator for file uploads
14
+ * Supports size and MIME type validation
15
+ */
16
+ class VldFile extends validators_base.VldBase {
17
+ constructor(checks = []) {
18
+ super(validators_base.VLD_VALIDATOR_TYPES.FILE);
19
+ this.checks = checks;
20
+ }
21
+ /**
22
+ * Create a new file validator
23
+ */
24
+ static create() {
25
+ return new VldFile();
26
+ }
27
+ isFileLike(value) {
28
+ if (typeof value !== 'object' || value === null) {
29
+ return false;
30
+ }
31
+ if (typeof File !== 'undefined' && value instanceof File) {
32
+ return true;
33
+ }
34
+ return 'size' in value && 'type' in value;
35
+ }
36
+ /**
37
+ * Parse and validate a file value
38
+ */
39
+ parse(value) {
40
+ if (this.isFileLike(value)) {
41
+ return this.parseKnownFile(value);
42
+ }
43
+ if (typeof File === 'undefined') {
44
+ throw new Error(locales_runtime.getMessages().fileNotSupported || 'File API not supported in this environment');
45
+ }
46
+ throw new Error(locales_runtime.getMessages().invalidFile || 'Expected a File object');
47
+ }
48
+ /**
49
+ * Parse a value that has already passed the file-like type guard.
50
+ * @internal Used by object validators to avoid duplicate hot-path checks.
51
+ */
52
+ parseKnownFile(value) {
53
+ return this.runChecks(value);
54
+ }
55
+ /**
56
+ * Run all validation checks on the file
57
+ */
58
+ runChecks(file) {
59
+ const msgs = locales_runtime.getMessages();
60
+ for (const check of this.checks) {
61
+ switch (check.type) {
62
+ case 'min':
63
+ if (file.size < check.value) {
64
+ throw new Error(check.message ||
65
+ (msgs.fileMinSize?.(check.value) || `File size must be at least ${check.value} bytes`));
66
+ }
67
+ break;
68
+ case 'max':
69
+ if (file.size > check.value) {
70
+ throw new Error(check.message ||
71
+ (msgs.fileMaxSize?.(check.value) || `File size must not exceed ${check.value} bytes`));
72
+ }
73
+ break;
74
+ case 'mime':
75
+ if (!check.value.includes(file.type)) {
76
+ throw new Error(check.message ||
77
+ (msgs.fileMimeType?.(check.value) || `Invalid file type. Expected: ${check.value.join(', ')}`));
78
+ }
79
+ break;
80
+ }
81
+ }
82
+ return file;
83
+ }
84
+ /**
85
+ * Safely parse and validate a file value
86
+ */
87
+ safeParse(value) {
88
+ try {
89
+ return { success: true, data: this.parse(value) };
90
+ }
91
+ catch (error) {
92
+ return { success: false, error: createFileError(error.message) };
93
+ }
94
+ }
95
+ /**
96
+ * Set minimum file size in bytes
97
+ */
98
+ min(bytes, message) {
99
+ return new VldFile([...this.checks, { type: 'min', value: bytes, message }]);
100
+ }
101
+ /**
102
+ * Set maximum file size in bytes
103
+ */
104
+ max(bytes, message) {
105
+ return new VldFile([...this.checks, { type: 'max', value: bytes, message }]);
106
+ }
107
+ /**
108
+ * Set allowed MIME types
109
+ */
110
+ mime(types, message) {
111
+ const typeArray = Array.isArray(types) ? types : [types];
112
+ return new VldFile([...this.checks, { type: 'mime', value: typeArray, message }]);
113
+ }
114
+ /**
115
+ * Set both minimum and maximum file size
116
+ */
117
+ size(min, max, message) {
118
+ return this.min(min, message).max(max, message);
119
+ }
120
+ }
121
+ /**
122
+ * Helper function to create file validators
123
+ * Usage: v.file().min(1024).max(10485760).mime(['image/jpeg', 'image/png'])
124
+ */
125
+ function file() {
126
+ return VldFile.create();
127
+ }
128
+
129
+ exports.VldFile = VldFile;
130
+ exports.file = file;
@@ -0,0 +1,63 @@
1
+ 'use strict';
2
+
3
+ var validators_base = require('./base.cjs');
4
+ var locales_runtime = require('../locales/runtime.cjs');
5
+ var errorsCore = require('../chunks/errors-core-DWxLFs2f.cjs');
6
+ require('../registry.cjs');
7
+ require('../locales/en.cjs');
8
+
9
+ function createFunctionError(message) {
10
+ return new errorsCore.VldError([{ code: 'invalid_type', path: [], message }]);
11
+ }
12
+ /**
13
+ * Immutable function validator
14
+ * Validates that a value is a function
15
+ */
16
+ class VldFunction extends validators_base.VldBase {
17
+ constructor() {
18
+ super(validators_base.VLD_VALIDATOR_TYPES.FUNCTION);
19
+ }
20
+ /**
21
+ * Create a new function validator
22
+ */
23
+ static create() {
24
+ return new VldFunction();
25
+ }
26
+ /**
27
+ * Parse and validate a function value
28
+ */
29
+ parse(value) {
30
+ if (typeof value !== 'function') {
31
+ throw new Error(locales_runtime.getMessages().invalidFunction || 'Expected a function');
32
+ }
33
+ return value;
34
+ }
35
+ /**
36
+ * Parse a value that has already passed the function type guard.
37
+ * @internal Used by object validators to avoid duplicate hot-path checks.
38
+ */
39
+ parseKnownFunction(value) {
40
+ return value;
41
+ }
42
+ /**
43
+ * Safely parse and validate a function value
44
+ */
45
+ safeParse(value) {
46
+ try {
47
+ return { success: true, data: this.parse(value) };
48
+ }
49
+ catch (error) {
50
+ return { success: false, error: createFunctionError(error.message) };
51
+ }
52
+ }
53
+ }
54
+ /**
55
+ * Helper function to create function validators
56
+ * Usage: v.function()
57
+ */
58
+ function functionValidator() {
59
+ return VldFunction.create();
60
+ }
61
+
62
+ exports.VldFunction = VldFunction;
63
+ exports.functionValidator = functionValidator;
@@ -0,0 +1,70 @@
1
+ 'use strict';
2
+
3
+ var validators_base = require('./base.cjs');
4
+ var errors = require('../errors.cjs');
5
+ var locales_runtime = require('../locales/runtime.cjs');
6
+ var errorsCore = require('../chunks/errors-core-DWxLFs2f.cjs');
7
+ require('../registry.cjs');
8
+ require('../pigment.cjs');
9
+ require('../locales/en.cjs');
10
+
11
+ /**
12
+ * Hexadecimal string validator
13
+ */
14
+ class VldHex extends validators_base.VldBase {
15
+ constructor(lowercase = false) {
16
+ super(validators_base.VLD_VALIDATOR_TYPES.HEX);
17
+ this.lowercase = lowercase;
18
+ }
19
+ parse(value) {
20
+ const result = this.safeParse(value);
21
+ if (!result.success) {
22
+ throw result.error;
23
+ }
24
+ return result.data;
25
+ }
26
+ safeParse(value) {
27
+ if (typeof value !== 'string') {
28
+ return {
29
+ success: false,
30
+ error: new errorsCore.VldError([
31
+ errors.createIssue('invalid_type', [], locales_runtime.getMessages().expectedString)
32
+ ])
33
+ };
34
+ }
35
+ // Check if it's a valid hex string
36
+ if (!VldHex.HEX_REGEX.test(value)) {
37
+ return {
38
+ success: false,
39
+ error: new errorsCore.VldError([
40
+ errors.createIssue('custom', [], locales_runtime.getMessages().invalidHex)
41
+ ])
42
+ };
43
+ }
44
+ // Check if even length (full bytes)
45
+ if (value.length % 2 !== 0) {
46
+ return {
47
+ success: false,
48
+ error: new errorsCore.VldError([
49
+ errors.createIssue('custom', [], locales_runtime.getMessages().invalidHex)
50
+ ])
51
+ };
52
+ }
53
+ // Normalize case if required
54
+ const normalizedValue = this.lowercase ? value.toLowerCase() : value;
55
+ return { success: true, data: normalizedValue };
56
+ }
57
+ /**
58
+ * Require lowercase hex characters
59
+ */
60
+ lowercaseMode() {
61
+ return new VldHex(true);
62
+ }
63
+ static create(lowercase = false) {
64
+ return new VldHex(lowercase);
65
+ }
66
+ }
67
+ // BUG-008 FIX: Use * instead of + to allow empty hex strings (consistent with base64 validator)
68
+ VldHex.HEX_REGEX = /^[0-9a-fA-F]*$/;
69
+
70
+ exports.VldHex = VldHex;
@@ -0,0 +1,123 @@
1
+ 'use strict';
2
+
3
+ var validators_base = require('./base.cjs');
4
+ var validators_string = require('../chunks/string-BKZrc4hs.cjs');
5
+ var validators_number = require('./number.cjs');
6
+ var validators_boolean = require('./boolean.cjs');
7
+ var validators_date = require('./date.cjs');
8
+ var validators_stringBool = require('./string-bool.cjs');
9
+ var validators_array = require('./array.cjs');
10
+ var validators_object = require('./object.cjs');
11
+ var validators_union = require('./union.cjs');
12
+ var validators_intersection = require('./intersection.cjs');
13
+ var validators_literal = require('./literal.cjs');
14
+ var validators_enum = require('./enum.cjs');
15
+ var validators_tuple = require('./tuple.cjs');
16
+ var validators_record = require('./record.cjs');
17
+ var validators_set = require('./set.cjs');
18
+ var validators_map = require('./map.cjs');
19
+ var validators_bigint = require('./bigint.cjs');
20
+ var validators_symbol = require('./symbol.cjs');
21
+ var validators_any = require('./any.cjs');
22
+ var validators_unknown = require('./unknown.cjs');
23
+ var validators_void = require('./void.cjs');
24
+ var validators_never = require('./never.cjs');
25
+ var validators_null = require('./null.cjs');
26
+ var validators_undefined = require('./undefined.cjs');
27
+ var validators_nan = require('./nan.cjs');
28
+ var validators_lazy = require('./lazy.cjs');
29
+ var validators_discriminatedUnion = require('./discriminated-union.cjs');
30
+ var validators_xor = require('./xor.cjs');
31
+ var validators_json = require('./json.cjs');
32
+ var validators_templateLiteral = require('./template-literal.cjs');
33
+ var validators_custom = require('./custom.cjs');
34
+ var validators_file = require('./file.cjs');
35
+ var validators_function = require('./function.cjs');
36
+ var validators_promise = require('./promise.cjs');
37
+ var validators_stringFormats = require('./string-formats.cjs');
38
+ require('../registry.cjs');
39
+ require('../locales/runtime.cjs');
40
+ require('../locales/en.cjs');
41
+ require('../chunks/errors-core-DWxLFs2f.cjs');
42
+ require('../chunks/security-Dc3Jh13T.cjs');
43
+
44
+
45
+
46
+ exports.VldBase = validators_base.VldBase;
47
+ exports.VldBrand = validators_base.VldBrand;
48
+ exports.VldCatch = validators_base.VldCatch;
49
+ exports.VldDefault = validators_base.VldDefault;
50
+ exports.VldExactOptional = validators_base.VldExactOptional;
51
+ exports.VldNullable = validators_base.VldNullable;
52
+ exports.VldNullish = validators_base.VldNullish;
53
+ exports.VldOptional = validators_base.VldOptional;
54
+ exports.VldPipe = validators_base.VldPipe;
55
+ exports.VldPreprocess = validators_base.VldPreprocess;
56
+ exports.VldReadonly = validators_base.VldReadonly;
57
+ exports.VldRefine = validators_base.VldRefine;
58
+ exports.VldSuperRefine = validators_base.VldSuperRefine;
59
+ exports.VldTransform = validators_base.VldTransform;
60
+ exports.VldString = validators_string.VldString;
61
+ exports.VldNumber = validators_number.VldNumber;
62
+ exports.VldBoolean = validators_boolean.VldBoolean;
63
+ exports.VldDate = validators_date.VldDate;
64
+ exports.VldStringBool = validators_stringBool.VldStringBool;
65
+ exports.VldArray = validators_array.VldArray;
66
+ exports.VldObject = validators_object.VldObject;
67
+ exports.VldUnion = validators_union.VldUnion;
68
+ exports.VldIntersection = validators_intersection.VldIntersection;
69
+ exports.VldLiteral = validators_literal.VldLiteral;
70
+ exports.VldEnum = validators_enum.VldEnum;
71
+ exports.VldTuple = validators_tuple.VldTuple;
72
+ exports.VldRecord = validators_record.VldRecord;
73
+ exports.VldSet = validators_set.VldSet;
74
+ exports.VldMap = validators_map.VldMap;
75
+ exports.VldBigInt = validators_bigint.VldBigInt;
76
+ exports.VldSymbol = validators_symbol.VldSymbol;
77
+ exports.VldAny = validators_any.VldAny;
78
+ exports.VldUnknown = validators_unknown.VldUnknown;
79
+ exports.VldVoid = validators_void.VldVoid;
80
+ exports.VldNever = validators_never.VldNever;
81
+ exports.VldNull = validators_null.VldNull;
82
+ exports.VldUndefined = validators_undefined.VldUndefined;
83
+ exports.VldNan = validators_nan.VldNan;
84
+ exports.VldLazy = validators_lazy.VldLazy;
85
+ exports.VldDiscriminatedUnion = validators_discriminatedUnion.VldDiscriminatedUnion;
86
+ exports.VldXor = validators_xor.VldXor;
87
+ exports.VldJson = validators_json.VldJson;
88
+ exports.VldTemplateLiteral = validators_templateLiteral.VldTemplateLiteral;
89
+ exports.templateLiteral = validators_templateLiteral.templateLiteral;
90
+ exports.VldCustom = validators_custom.VldCustom;
91
+ exports.custom = validators_custom.custom;
92
+ exports.VldFile = validators_file.VldFile;
93
+ exports.file = validators_file.file;
94
+ exports.VldFunction = validators_function.VldFunction;
95
+ exports.functionValidator = validators_function.functionValidator;
96
+ exports.VldPromise = validators_promise.VldPromise;
97
+ exports.promise = validators_promise.promise;
98
+ exports.base64 = validators_stringFormats.base64;
99
+ exports.base64url = validators_stringFormats.base64url;
100
+ exports.cidrv4 = validators_stringFormats.cidrv4;
101
+ exports.cidrv6 = validators_stringFormats.cidrv6;
102
+ exports.cuid = validators_stringFormats.cuid;
103
+ exports.cuid2 = validators_stringFormats.cuid2;
104
+ exports.e164 = validators_stringFormats.e164;
105
+ exports.email = validators_stringFormats.email;
106
+ exports.emoji = validators_stringFormats.emoji;
107
+ exports.guid = validators_stringFormats.guid;
108
+ exports.hash = validators_stringFormats.hash;
109
+ exports.hex = validators_stringFormats.hex;
110
+ exports.hostname = validators_stringFormats.hostname;
111
+ exports.httpUrl = validators_stringFormats.httpUrl;
112
+ exports.ipv4 = validators_stringFormats.ipv4;
113
+ exports.ipv6 = validators_stringFormats.ipv6;
114
+ exports.iso = validators_stringFormats.iso;
115
+ exports.jwt = validators_stringFormats.jwt;
116
+ exports.mac = validators_stringFormats.mac;
117
+ exports.nanoid = validators_stringFormats.nanoid;
118
+ exports.regexes = validators_stringFormats.regexes;
119
+ exports.stringFormat = validators_stringFormats.stringFormat;
120
+ exports.ulid = validators_stringFormats.ulid;
121
+ exports.uuid = validators_stringFormats.uuid;
122
+ exports.uuidv4 = validators_stringFormats.uuidv4;
123
+ exports.xid = validators_stringFormats.xid;
@@ -0,0 +1,120 @@
1
+ 'use strict';
2
+
3
+ var validators_base = require('./base.cjs');
4
+ var security = require('../chunks/security-Dc3Jh13T.cjs');
5
+ var locales_runtime = require('../locales/runtime.cjs');
6
+ var errorsCore = require('../chunks/errors-core-DWxLFs2f.cjs');
7
+ require('../registry.cjs');
8
+ require('../locales/en.cjs');
9
+
10
+ /**
11
+ * Type guard to check if a value is a plain object
12
+ */
13
+ function isPlainObject(obj) {
14
+ return (obj !== null &&
15
+ typeof obj === 'object' &&
16
+ obj.constructor === Object &&
17
+ Object.prototype.toString.call(obj) === '[object Object]');
18
+ }
19
+ /**
20
+ * Safely deep merge two objects without prototype pollution vulnerability
21
+ * Optimized for performance with minimal object allocations
22
+ * BUG-NEW-020 FIX: Use comprehensive dangerous key protection from shared utility
23
+ * @param target The target object
24
+ * @param source The source object to merge from
25
+ * @returns A new merged object
26
+ */
27
+ function deepMerge(target, source) {
28
+ // Create a new object to avoid mutations (only once)
29
+ const result = { ...target };
30
+ // Get source keys directly for better performance
31
+ const sourceKeys = Object.keys(source);
32
+ for (let i = 0; i < sourceKeys.length; i++) {
33
+ const key = sourceKeys[i];
34
+ // Skip dangerous keys that could lead to prototype pollution
35
+ if (security.isDangerousKey(key)) {
36
+ continue;
37
+ }
38
+ // Only process own properties (redundant with Object.keys but safe)
39
+ if (!Object.prototype.hasOwnProperty.call(source, key)) {
40
+ continue;
41
+ }
42
+ const sourceValue = source[key];
43
+ const targetValue = target[key];
44
+ // If both values are plain objects, merge them recursively
45
+ if (isPlainObject(sourceValue) && isPlainObject(targetValue)) {
46
+ result[key] = deepMerge(targetValue, sourceValue);
47
+ }
48
+ else {
49
+ // Otherwise, use the source value (including undefined)
50
+ result[key] = sourceValue;
51
+ }
52
+ }
53
+ return result;
54
+ }
55
+
56
+ function createIntersectionError(message) {
57
+ return new errorsCore.VldError([{ code: 'invalid_type', path: [], message }]);
58
+ }
59
+ /**
60
+ * Immutable intersection validator for combining validators
61
+ */
62
+ class VldIntersection extends validators_base.VldBase {
63
+ /**
64
+ * Private constructor to enforce immutability
65
+ */
66
+ constructor(validatorA, validatorB) {
67
+ super(validators_base.VLD_VALIDATOR_TYPES.INTERSECTION);
68
+ this.validatorA = validatorA;
69
+ this.validatorB = validatorB;
70
+ }
71
+ /**
72
+ * Create a new intersection validator
73
+ */
74
+ static create(validatorA, validatorB) {
75
+ return new VldIntersection(validatorA, validatorB);
76
+ }
77
+ /**
78
+ * Parse and validate a value against both validators
79
+ */
80
+ parse(value) {
81
+ try {
82
+ // Both validators must pass
83
+ const resultA = this.validatorA.parse(value);
84
+ const resultB = this.validatorB.parse(value);
85
+ // BUG-NEW-015 FIX: Check type consistency before merging
86
+ const aIsObject = isPlainObject(resultA);
87
+ const bIsObject = isPlainObject(resultB);
88
+ // Both are objects - safe to merge
89
+ if (aIsObject && bIsObject) {
90
+ return deepMerge(resultA, resultB);
91
+ }
92
+ // Neither are objects - must be identical primitives
93
+ if (!aIsObject && !bIsObject) {
94
+ if (resultA === resultB) {
95
+ return resultA;
96
+ }
97
+ throw new Error('Values must be identical for intersection of primitive types');
98
+ }
99
+ // One is object, one is primitive - invalid intersection
100
+ throw new Error('Cannot create intersection of object and primitive types. ' +
101
+ 'Both validators must produce the same type category.');
102
+ }
103
+ catch (error) {
104
+ throw new Error(locales_runtime.getMessages().intersectionError(error.message));
105
+ }
106
+ }
107
+ /**
108
+ * Safely parse and validate a value against both validators
109
+ */
110
+ safeParse(value) {
111
+ try {
112
+ return { success: true, data: this.parse(value) };
113
+ }
114
+ catch (error) {
115
+ return { success: false, error: createIntersectionError(error.message) };
116
+ }
117
+ }
118
+ }
119
+
120
+ exports.VldIntersection = VldIntersection;
@@ -0,0 +1,70 @@
1
+ 'use strict';
2
+
3
+ var validators_base = require('./base.cjs');
4
+ var locales_runtime = require('../locales/runtime.cjs');
5
+ require('../registry.cjs');
6
+ require('../locales/en.cjs');
7
+
8
+ /**
9
+ * Immutable JSON validator that validates and parses JSON strings
10
+ * Accepts both strings (which are parsed) and already-parsed objects
11
+ */
12
+ class VldJson extends validators_base.VldBase {
13
+ constructor(schema) {
14
+ super(validators_base.VLD_VALIDATOR_TYPES.JSON);
15
+ this.schema = schema;
16
+ }
17
+ /**
18
+ * Create a new JSON validator
19
+ */
20
+ static create(schema) {
21
+ return new VldJson(schema);
22
+ }
23
+ /**
24
+ * Parse and validate a JSON value
25
+ */
26
+ parse(value) {
27
+ let parsed;
28
+ // If it's a string, try to parse it as JSON first
29
+ if (typeof value === 'string') {
30
+ try {
31
+ parsed = JSON.parse(value);
32
+ }
33
+ catch {
34
+ throw new Error(locales_runtime.getMessages().invalidJson);
35
+ }
36
+ }
37
+ else {
38
+ // Not a string - assume it's already parsed
39
+ parsed = value;
40
+ }
41
+ // If we have a schema, validate against it
42
+ if (this.schema) {
43
+ return this.schema.parse(parsed);
44
+ }
45
+ // No schema - just return the parsed value
46
+ return parsed;
47
+ }
48
+ /**
49
+ * Safely parse and validate a JSON value
50
+ */
51
+ safeParse(value) {
52
+ try {
53
+ return { success: true, data: this.parse(value) };
54
+ }
55
+ catch (error) {
56
+ return {
57
+ success: false,
58
+ error: error
59
+ };
60
+ }
61
+ }
62
+ /**
63
+ * Create a new JSON validator with a schema for validation
64
+ */
65
+ withSchema(schema) {
66
+ return new VldJson(schema);
67
+ }
68
+ }
69
+
70
+ exports.VldJson = VldJson;
@@ -0,0 +1,53 @@
1
+ 'use strict';
2
+
3
+ var validators_base = require('./base.cjs');
4
+ require('../registry.cjs');
5
+
6
+ /**
7
+ * VldLazy - Lazy evaluation for recursive schemas
8
+ * Part of Zod 4 API parity implementation
9
+ * Allows schemas that reference themselves (e.g., tree structures, nested categories)
10
+ */
11
+ /**
12
+ * Lazy validator - defers schema evaluation until runtime
13
+ * Essential for recursive and self-referencing types
14
+ *
15
+ * Caches the resolved schema after first use. This keeps recursive schemas stable
16
+ * and avoids re-running the schema getter on hot parse paths.
17
+ */
18
+ class VldLazy extends validators_base.VldBase {
19
+ constructor(_schemaGetter) {
20
+ super(validators_base.VLD_VALIDATOR_TYPES.LAZY);
21
+ this._schemaGetter = _schemaGetter;
22
+ this._cachedSchema = null;
23
+ }
24
+ static create(schemaGetter) {
25
+ return new VldLazy(schemaGetter);
26
+ }
27
+ /**
28
+ * Get the actual schema, caching it after first retrieval
29
+ */
30
+ _getSchema() {
31
+ if (this._cachedSchema) {
32
+ return this._cachedSchema;
33
+ }
34
+ const schema = this._schemaGetter();
35
+ this._cachedSchema = schema;
36
+ return schema;
37
+ }
38
+ /**
39
+ * Get the inner schema (unwrap)
40
+ * Returns a strong reference that will keep the schema alive
41
+ */
42
+ unwrap() {
43
+ return this._getSchema();
44
+ }
45
+ parse(value) {
46
+ return this._getSchema().parse(value);
47
+ }
48
+ safeParse(value) {
49
+ return this._getSchema().safeParse(value);
50
+ }
51
+ }
52
+
53
+ exports.VldLazy = VldLazy;
@@ -0,0 +1,64 @@
1
+ 'use strict';
2
+
3
+ var validators_base = require('./base.cjs');
4
+ var locales_runtime = require('../locales/runtime.cjs');
5
+ var errorsCore = require('../chunks/errors-core-DWxLFs2f.cjs');
6
+ require('../registry.cjs');
7
+ require('../locales/en.cjs');
8
+
9
+ function createLiteralError(message) {
10
+ return new errorsCore.VldError([{ code: 'invalid_literal', path: [], message }]);
11
+ }
12
+ /**
13
+ * Immutable literal validator for exact value matching
14
+ */
15
+ class VldLiteral extends validators_base.VldBase {
16
+ /**
17
+ * Private constructor to enforce immutability
18
+ */
19
+ constructor(_literal, errorMessage) {
20
+ super(validators_base.VLD_VALIDATOR_TYPES.LITERAL);
21
+ this._literal = _literal;
22
+ this.errorMessage = errorMessage;
23
+ }
24
+ /**
25
+ * Get the literal value
26
+ */
27
+ get literal() {
28
+ return this._literal;
29
+ }
30
+ get isSimple() {
31
+ return true;
32
+ }
33
+ /**
34
+ * Create a new literal validator
35
+ */
36
+ static create(literal) {
37
+ return new VldLiteral(literal);
38
+ }
39
+ /**
40
+ * Parse and validate a literal value
41
+ */
42
+ parse(value) {
43
+ if (value !== this._literal) {
44
+ throw new Error(this.errorMessage ||
45
+ locales_runtime.getMessages().literalExpected(JSON.stringify(this._literal), JSON.stringify(value)));
46
+ }
47
+ return this._literal;
48
+ }
49
+ /**
50
+ * Safely parse and validate a literal value
51
+ */
52
+ safeParse(value) {
53
+ if (value === this._literal) {
54
+ return { success: true, data: this._literal };
55
+ }
56
+ return {
57
+ success: false,
58
+ error: createLiteralError(this.errorMessage ||
59
+ locales_runtime.getMessages().literalExpected(JSON.stringify(this._literal), JSON.stringify(value)))
60
+ };
61
+ }
62
+ }
63
+
64
+ exports.VldLiteral = VldLiteral;