@oxog/vld 2.0.2 → 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 (450) hide show
  1. package/CHANGELOG.md +75 -1
  2. package/LICENSE +20 -20
  3. package/README.md +101 -37
  4. package/dist/chunks/errors-core-BeiFUtZM.js +81 -0
  5. package/dist/chunks/{index-CETyGkrv.js → index-0R2ntSud.js} +16 -402
  6. package/dist/chunks/index-BvH403Yy.js +88 -0
  7. package/dist/chunks/security-B0Pd_vSY.js +35 -0
  8. package/dist/chunks/string-BJRQod3t.js +530 -0
  9. package/dist/cjs/chunks/errors-core-DWxLFs2f.cjs +83 -0
  10. package/dist/cjs/chunks/index-BkI37108.cjs +538 -0
  11. package/dist/cjs/chunks/index-Cc3bjUMX.cjs +91 -0
  12. package/dist/cjs/chunks/security-Dc3Jh13T.cjs +37 -0
  13. package/dist/cjs/chunks/string-BKZrc4hs.cjs +533 -0
  14. package/dist/cjs/cli/bin.cjs +506 -0
  15. package/dist/cjs/cli/index.cjs +209 -0
  16. package/dist/cjs/codecs/index.cjs +45 -0
  17. package/dist/{chunks/date-ODue_rtq.js → cjs/coercion/index.cjs} +185 -103
  18. package/dist/cjs/compat/emitter.cjs +184 -0
  19. package/dist/cjs/compat/result.cjs +189 -0
  20. package/dist/cjs/errors.cjs +6 -213
  21. package/dist/cjs/index.cjs +1558 -9647
  22. package/dist/cjs/kernel.cjs +415 -0
  23. package/dist/cjs/locales/af.cjs +108 -0
  24. package/dist/cjs/locales/ar.cjs +108 -0
  25. package/dist/cjs/locales/bn.cjs +108 -0
  26. package/dist/cjs/locales/da.cjs +108 -0
  27. package/dist/cjs/locales/de.cjs +108 -0
  28. package/dist/cjs/locales/en.cjs +108 -0
  29. package/dist/cjs/locales/es-MX.cjs +107 -0
  30. package/dist/cjs/locales/es.cjs +96 -0
  31. package/dist/cjs/locales/fi.cjs +108 -0
  32. package/dist/cjs/locales/fr.cjs +96 -0
  33. package/dist/cjs/locales/hi.cjs +108 -0
  34. package/dist/cjs/locales/id.cjs +108 -0
  35. package/dist/cjs/locales/index.cjs +41 -2875
  36. package/dist/cjs/locales/it.cjs +108 -0
  37. package/dist/cjs/locales/ja.cjs +108 -0
  38. package/dist/cjs/locales/ko.cjs +108 -0
  39. package/dist/cjs/locales/lazy.cjs +42 -3023
  40. package/dist/cjs/locales/nl.cjs +108 -0
  41. package/dist/cjs/locales/no.cjs +108 -0
  42. package/dist/cjs/locales/pl.cjs +108 -0
  43. package/dist/cjs/locales/pt-BR.cjs +108 -0
  44. package/dist/cjs/locales/pt.cjs +108 -0
  45. package/dist/cjs/locales/ru.cjs +108 -0
  46. package/dist/cjs/locales/runtime.cjs +51 -0
  47. package/dist/cjs/locales/sv.cjs +108 -0
  48. package/dist/cjs/locales/sw.cjs +108 -0
  49. package/dist/cjs/locales/th.cjs +108 -0
  50. package/dist/cjs/locales/tr.cjs +108 -0
  51. package/dist/cjs/locales/vi.cjs +108 -0
  52. package/dist/cjs/locales/zh.cjs +108 -0
  53. package/dist/cjs/mini.cjs +121 -7208
  54. package/dist/cjs/pigment.cjs +207 -0
  55. package/dist/cjs/plugins/index.cjs +12 -0
  56. package/dist/cjs/registry.cjs +37 -0
  57. package/dist/cjs/v3/index.cjs +425 -0
  58. package/dist/cjs/v4/core/index.cjs +894 -0
  59. package/dist/cjs/v4/index.cjs +425 -0
  60. package/dist/cjs/v4/locales/index.cjs +130 -0
  61. package/dist/cjs/v4/mini/index.cjs +509 -0
  62. package/dist/cjs/v4-mini/index.cjs +532 -0
  63. package/dist/cjs/validators/any.cjs +40 -0
  64. package/dist/cjs/validators/array.cjs +283 -0
  65. package/dist/cjs/validators/base.cjs +887 -0
  66. package/dist/cjs/validators/base64.cjs +73 -0
  67. package/dist/cjs/validators/bigint.cjs +232 -0
  68. package/dist/cjs/validators/boolean.cjs +146 -0
  69. package/dist/cjs/validators/codec.cjs +205 -0
  70. package/dist/cjs/validators/custom.cjs +71 -0
  71. package/dist/cjs/validators/date.cjs +278 -0
  72. package/dist/cjs/validators/discriminated-union.cjs +130 -0
  73. package/dist/cjs/validators/enum.cjs +154 -0
  74. package/dist/cjs/validators/file.cjs +130 -0
  75. package/dist/cjs/validators/function.cjs +63 -0
  76. package/dist/cjs/validators/hex.cjs +70 -0
  77. package/dist/cjs/validators/index.cjs +123 -0
  78. package/dist/cjs/validators/intersection.cjs +120 -0
  79. package/dist/cjs/validators/json.cjs +70 -0
  80. package/dist/cjs/validators/lazy.cjs +53 -0
  81. package/dist/cjs/validators/literal.cjs +64 -0
  82. package/dist/cjs/validators/map.cjs +218 -0
  83. package/dist/cjs/validators/nan.cjs +41 -0
  84. package/dist/cjs/validators/never.cjs +36 -0
  85. package/dist/cjs/validators/null.cjs +43 -0
  86. package/dist/cjs/validators/number.cjs +427 -0
  87. package/dist/cjs/validators/object.cjs +868 -0
  88. package/dist/cjs/validators/promise.cjs +115 -0
  89. package/dist/cjs/validators/record.cjs +262 -0
  90. package/dist/cjs/validators/set.cjs +203 -0
  91. package/dist/cjs/validators/string-bool.cjs +124 -0
  92. package/dist/cjs/validators/string-formats.cjs +168 -0
  93. package/dist/cjs/validators/string.cjs +12 -0
  94. package/dist/cjs/validators/symbol.cjs +62 -0
  95. package/dist/cjs/validators/template-literal.cjs +108 -0
  96. package/dist/cjs/validators/tuple.cjs +187 -0
  97. package/dist/cjs/validators/uint8array.cjs +106 -0
  98. package/dist/cjs/validators/undefined.cjs +43 -0
  99. package/dist/cjs/validators/union.cjs +191 -0
  100. package/dist/cjs/validators/unknown.cjs +40 -0
  101. package/dist/cjs/validators/void.cjs +48 -0
  102. package/dist/cjs/validators/xor.cjs +69 -0
  103. package/dist/cli/bin.d.ts +0 -1
  104. package/dist/cli/bin.js +407 -0
  105. package/dist/cli/commands/benchmark.d.ts +1 -2
  106. package/dist/cli/commands/validate.d.ts +1 -2
  107. package/dist/cli/index.d.ts +0 -1
  108. package/dist/cli/index.js +205 -0
  109. package/dist/codecs/index.d.ts +21 -4
  110. package/dist/codecs/index.js +11 -4
  111. package/dist/coercion/bigint.d.ts +2 -3
  112. package/dist/coercion/boolean.d.ts +3 -3
  113. package/dist/coercion/date.d.ts +3 -3
  114. package/dist/coercion/index.d.ts +5 -6
  115. package/dist/coercion/index.js +473 -5
  116. package/dist/coercion/number.d.ts +2 -3
  117. package/dist/coercion/string.d.ts +2 -3
  118. package/dist/compat/emitter.d.ts +0 -1
  119. package/dist/compat/emitter.js +0 -1
  120. package/dist/compat/index.d.ts +4 -5
  121. package/dist/compat/result.d.ts +1 -2
  122. package/dist/compat/result.js +0 -1
  123. package/dist/errors-core.d.ts +39 -0
  124. package/dist/errors.d.ts +4 -54
  125. package/dist/errors.js +4 -68
  126. package/dist/events.d.ts +3 -4
  127. package/dist/index.d.ts +1195 -600
  128. package/dist/index.js +1262 -44
  129. package/dist/kernel.d.ts +2 -3
  130. package/dist/kernel.js +10 -6
  131. package/dist/locales/af.d.ts +1 -2
  132. package/dist/locales/af.js +0 -1
  133. package/dist/locales/ar.d.ts +1 -2
  134. package/dist/locales/ar.js +0 -1
  135. package/dist/locales/bn.d.ts +1 -2
  136. package/dist/locales/bn.js +0 -1
  137. package/dist/locales/da.d.ts +1 -2
  138. package/dist/locales/da.js +0 -1
  139. package/dist/locales/de.d.ts +1 -2
  140. package/dist/locales/de.js +0 -1
  141. package/dist/locales/en.d.ts +1 -2
  142. package/dist/locales/en.js +0 -1
  143. package/dist/locales/es-MX.d.ts +1 -2
  144. package/dist/locales/es-MX.js +0 -1
  145. package/dist/locales/es.d.ts +1 -2
  146. package/dist/locales/es.js +0 -1
  147. package/dist/locales/fi.d.ts +1 -2
  148. package/dist/locales/fi.js +0 -1
  149. package/dist/locales/fr.d.ts +1 -2
  150. package/dist/locales/fr.js +0 -1
  151. package/dist/locales/hi.d.ts +1 -2
  152. package/dist/locales/hi.js +0 -1
  153. package/dist/locales/id.d.ts +1 -2
  154. package/dist/locales/id.js +0 -1
  155. package/dist/locales/index.d.ts +10 -15
  156. package/dist/locales/index.js +28 -2
  157. package/dist/locales/it.d.ts +1 -2
  158. package/dist/locales/it.js +0 -1
  159. package/dist/locales/ja.d.ts +1 -2
  160. package/dist/locales/ja.js +0 -1
  161. package/dist/locales/ko.d.ts +1 -2
  162. package/dist/locales/ko.js +0 -1
  163. package/dist/locales/lazy.d.ts +4 -26
  164. package/dist/locales/lazy.js +12 -55
  165. package/dist/locales/nl.d.ts +1 -2
  166. package/dist/locales/nl.js +0 -1
  167. package/dist/locales/no.d.ts +1 -2
  168. package/dist/locales/no.js +0 -1
  169. package/dist/locales/pl.d.ts +1 -2
  170. package/dist/locales/pl.js +0 -1
  171. package/dist/locales/pt-BR.d.ts +1 -2
  172. package/dist/locales/pt-BR.js +0 -1
  173. package/dist/locales/pt.d.ts +1 -2
  174. package/dist/locales/pt.js +0 -1
  175. package/dist/locales/ru.d.ts +1 -2
  176. package/dist/locales/ru.js +0 -1
  177. package/dist/locales/runtime.d.ts +10 -0
  178. package/dist/locales/runtime.js +41 -0
  179. package/dist/locales/sv.d.ts +1 -2
  180. package/dist/locales/sv.js +0 -1
  181. package/dist/locales/sw.d.ts +1 -2
  182. package/dist/locales/sw.js +0 -1
  183. package/dist/locales/th.d.ts +1 -2
  184. package/dist/locales/th.js +0 -1
  185. package/dist/locales/tr.d.ts +1 -2
  186. package/dist/locales/tr.js +0 -1
  187. package/dist/locales/types.d.ts +0 -1
  188. package/dist/locales/vi.d.ts +1 -2
  189. package/dist/locales/vi.js +0 -1
  190. package/dist/locales/zh.d.ts +1 -2
  191. package/dist/locales/zh.js +0 -1
  192. package/dist/logger.d.ts +0 -1
  193. package/dist/mini.d.ts +64 -65
  194. package/dist/mini.js +31 -7
  195. package/dist/pigment.d.ts +0 -1
  196. package/dist/pigment.js +6 -4
  197. package/dist/plugins/index.d.ts +2 -3
  198. package/dist/plugins/index.js +1 -0
  199. package/dist/plugins/types.d.ts +4 -5
  200. package/dist/registry.d.ts +23 -0
  201. package/dist/registry.js +34 -0
  202. package/dist/utils/codec-utils.d.ts +0 -1
  203. package/dist/utils/deep-merge.d.ts +0 -1
  204. package/dist/utils/ip-validation.d.ts +0 -1
  205. package/dist/utils/json-schema.d.ts +77 -0
  206. package/dist/utils/security.d.ts +2 -6
  207. package/dist/v3/index.d.ts +2 -0
  208. package/dist/v3/index.js +46 -0
  209. package/dist/v4/core/index.d.ts +260 -0
  210. package/dist/v4/core/index.js +277 -0
  211. package/dist/v4/index.d.ts +4 -0
  212. package/dist/v4/index.js +50 -0
  213. package/dist/v4/locales/index.d.ts +53 -0
  214. package/dist/v4/locales/index.js +77 -0
  215. package/dist/v4/mini/index.d.ts +2 -0
  216. package/dist/v4/mini/index.js +47 -0
  217. package/dist/v4-mini/index.d.ts +22 -0
  218. package/dist/v4-mini/index.js +75 -0
  219. package/dist/validators/any.d.ts +7 -2
  220. package/dist/validators/any.js +37 -0
  221. package/dist/validators/array.d.ts +9 -2
  222. package/dist/validators/array.js +279 -0
  223. package/dist/validators/base.d.ts +228 -5
  224. package/dist/validators/base.js +868 -0
  225. package/dist/validators/base64.d.ts +1 -2
  226. package/dist/validators/base64.js +68 -0
  227. package/dist/validators/bigint.d.ts +21 -3
  228. package/dist/validators/bigint.js +228 -0
  229. package/dist/validators/boolean.d.ts +13 -4
  230. package/dist/validators/boolean.js +142 -0
  231. package/dist/validators/codec.d.ts +9 -2
  232. package/dist/validators/codec.js +200 -0
  233. package/dist/validators/custom.d.ts +15 -2
  234. package/dist/validators/custom.js +67 -0
  235. package/dist/validators/date.d.ts +19 -3
  236. package/dist/validators/date.js +274 -0
  237. package/dist/validators/discriminated-union.d.ts +4 -3
  238. package/dist/validators/discriminated-union.js +123 -0
  239. package/dist/validators/enum.d.ts +10 -7
  240. package/dist/validators/enum.js +150 -0
  241. package/dist/validators/file.d.ts +7 -2
  242. package/dist/validators/file.js +125 -0
  243. package/dist/validators/function.d.ts +11 -5
  244. package/dist/validators/function.js +58 -0
  245. package/dist/validators/hex.d.ts +1 -2
  246. package/dist/validators/hex.js +65 -0
  247. package/dist/validators/index.d.ts +38 -38
  248. package/dist/validators/index.js +35 -5
  249. package/dist/validators/intersection.d.ts +1 -2
  250. package/dist/validators/intersection.js +116 -0
  251. package/dist/validators/json.d.ts +1 -2
  252. package/dist/validators/json.js +66 -0
  253. package/dist/validators/lazy.d.ts +5 -9
  254. package/dist/validators/lazy.js +50 -0
  255. package/dist/validators/literal.d.ts +2 -2
  256. package/dist/validators/literal.js +60 -0
  257. package/dist/validators/map.d.ts +15 -2
  258. package/dist/validators/map.js +214 -0
  259. package/dist/validators/nan.d.ts +2 -3
  260. package/dist/validators/nan.js +38 -0
  261. package/dist/validators/never.d.ts +1 -2
  262. package/dist/validators/never.js +32 -0
  263. package/dist/validators/null.d.ts +3 -3
  264. package/dist/validators/null.js +40 -0
  265. package/dist/validators/number.d.ts +80 -21
  266. package/dist/validators/number.js +423 -0
  267. package/dist/validators/object.d.ts +30 -9
  268. package/dist/validators/object.js +864 -0
  269. package/dist/validators/promise.d.ts +58 -0
  270. package/dist/validators/promise.js +111 -0
  271. package/dist/validators/record.d.ts +11 -2
  272. package/dist/validators/record.js +258 -0
  273. package/dist/validators/set.d.ts +11 -2
  274. package/dist/validators/set.js +199 -0
  275. package/dist/validators/string-bool.d.ts +7 -10
  276. package/dist/validators/string-bool.js +120 -0
  277. package/dist/validators/string-formats.d.ts +13 -4
  278. package/dist/validators/string-formats.js +135 -0
  279. package/dist/validators/string.d.ts +39 -18
  280. package/dist/validators/string.js +4 -0
  281. package/dist/validators/symbol.d.ts +8 -3
  282. package/dist/validators/symbol.js +58 -0
  283. package/dist/validators/template-literal.d.ts +1 -2
  284. package/dist/validators/template-literal.js +103 -0
  285. package/dist/validators/tuple.d.ts +15 -2
  286. package/dist/validators/tuple.js +183 -0
  287. package/dist/validators/uint8array.d.ts +3 -4
  288. package/dist/validators/uint8array.js +101 -0
  289. package/dist/validators/undefined.d.ts +3 -3
  290. package/dist/validators/undefined.js +40 -0
  291. package/dist/validators/union.d.ts +7 -4
  292. package/dist/validators/union.js +187 -0
  293. package/dist/validators/unknown.d.ts +7 -2
  294. package/dist/{chunks/unknown-SLIH1VCf.js → validators/unknown.js} +12 -3
  295. package/dist/validators/void.d.ts +3 -2
  296. package/dist/validators/void.js +44 -0
  297. package/dist/validators/xor.d.ts +2 -3
  298. package/dist/validators/xor.js +66 -0
  299. package/package.json +116 -31
  300. package/dist/chunks/bigint-DgsCr2dC.js +0 -1709
  301. package/dist/chunks/bigint-DgsCr2dC.js.map +0 -1
  302. package/dist/chunks/date-ODue_rtq.js.map +0 -1
  303. package/dist/chunks/index-BZqWZvVe.js +0 -426
  304. package/dist/chunks/index-BZqWZvVe.js.map +0 -1
  305. package/dist/chunks/index-CETyGkrv.js.map +0 -1
  306. package/dist/chunks/json-o20GFhTh.js +0 -2021
  307. package/dist/chunks/json-o20GFhTh.js.map +0 -1
  308. package/dist/chunks/unknown-SLIH1VCf.js.map +0 -1
  309. package/dist/cjs/errors.cjs.map +0 -1
  310. package/dist/cjs/index.cjs.map +0 -1
  311. package/dist/cjs/locales/index.cjs.map +0 -1
  312. package/dist/cjs/locales/lazy.cjs.map +0 -1
  313. package/dist/cjs/mini.cjs.map +0 -1
  314. package/dist/cli/bin.d.ts.map +0 -1
  315. package/dist/cli/commands/benchmark.d.ts.map +0 -1
  316. package/dist/cli/commands/validate.d.ts.map +0 -1
  317. package/dist/cli/index.d.ts.map +0 -1
  318. package/dist/codecs/index.d.ts.map +0 -1
  319. package/dist/codecs/index.js.map +0 -1
  320. package/dist/coercion/bigint.d.ts.map +0 -1
  321. package/dist/coercion/boolean.d.ts.map +0 -1
  322. package/dist/coercion/date.d.ts.map +0 -1
  323. package/dist/coercion/index.d.ts.map +0 -1
  324. package/dist/coercion/index.js.map +0 -1
  325. package/dist/coercion/number.d.ts.map +0 -1
  326. package/dist/coercion/string.d.ts.map +0 -1
  327. package/dist/compat/emitter.d.ts.map +0 -1
  328. package/dist/compat/emitter.js.map +0 -1
  329. package/dist/compat/index.d.ts.map +0 -1
  330. package/dist/compat/result.d.ts.map +0 -1
  331. package/dist/compat/result.js.map +0 -1
  332. package/dist/errors.d.ts.map +0 -1
  333. package/dist/errors.js.map +0 -1
  334. package/dist/events.d.ts.map +0 -1
  335. package/dist/index.d.ts.map +0 -1
  336. package/dist/index.js.map +0 -1
  337. package/dist/kernel.d.ts.map +0 -1
  338. package/dist/kernel.js.map +0 -1
  339. package/dist/locales/af.d.ts.map +0 -1
  340. package/dist/locales/af.js.map +0 -1
  341. package/dist/locales/ar.d.ts.map +0 -1
  342. package/dist/locales/ar.js.map +0 -1
  343. package/dist/locales/backup-en.d.ts +0 -3
  344. package/dist/locales/backup-en.d.ts.map +0 -1
  345. package/dist/locales/bn.d.ts.map +0 -1
  346. package/dist/locales/bn.js.map +0 -1
  347. package/dist/locales/da.d.ts.map +0 -1
  348. package/dist/locales/da.js.map +0 -1
  349. package/dist/locales/de.d.ts.map +0 -1
  350. package/dist/locales/de.js.map +0 -1
  351. package/dist/locales/en.d.ts.map +0 -1
  352. package/dist/locales/en.js.map +0 -1
  353. package/dist/locales/es-MX.d.ts.map +0 -1
  354. package/dist/locales/es-MX.js.map +0 -1
  355. package/dist/locales/es.d.ts.map +0 -1
  356. package/dist/locales/es.js.map +0 -1
  357. package/dist/locales/fi.d.ts.map +0 -1
  358. package/dist/locales/fi.js.map +0 -1
  359. package/dist/locales/fr.d.ts.map +0 -1
  360. package/dist/locales/fr.js.map +0 -1
  361. package/dist/locales/hi.d.ts.map +0 -1
  362. package/dist/locales/hi.js.map +0 -1
  363. package/dist/locales/id.d.ts.map +0 -1
  364. package/dist/locales/id.js.map +0 -1
  365. package/dist/locales/index.d.ts.map +0 -1
  366. package/dist/locales/index.js.map +0 -1
  367. package/dist/locales/it.d.ts.map +0 -1
  368. package/dist/locales/it.js.map +0 -1
  369. package/dist/locales/ja.d.ts.map +0 -1
  370. package/dist/locales/ja.js.map +0 -1
  371. package/dist/locales/ko.d.ts.map +0 -1
  372. package/dist/locales/ko.js.map +0 -1
  373. package/dist/locales/lazy.d.ts.map +0 -1
  374. package/dist/locales/lazy.js.map +0 -1
  375. package/dist/locales/nl.d.ts.map +0 -1
  376. package/dist/locales/nl.js.map +0 -1
  377. package/dist/locales/no.d.ts.map +0 -1
  378. package/dist/locales/no.js.map +0 -1
  379. package/dist/locales/pl.d.ts.map +0 -1
  380. package/dist/locales/pl.js.map +0 -1
  381. package/dist/locales/pt-BR.d.ts.map +0 -1
  382. package/dist/locales/pt-BR.js.map +0 -1
  383. package/dist/locales/pt.d.ts.map +0 -1
  384. package/dist/locales/pt.js.map +0 -1
  385. package/dist/locales/ru.d.ts.map +0 -1
  386. package/dist/locales/ru.js.map +0 -1
  387. package/dist/locales/sv.d.ts.map +0 -1
  388. package/dist/locales/sv.js.map +0 -1
  389. package/dist/locales/sw.d.ts.map +0 -1
  390. package/dist/locales/sw.js.map +0 -1
  391. package/dist/locales/th.d.ts.map +0 -1
  392. package/dist/locales/th.js.map +0 -1
  393. package/dist/locales/tr.d.ts.map +0 -1
  394. package/dist/locales/tr.js.map +0 -1
  395. package/dist/locales/types.d.ts.map +0 -1
  396. package/dist/locales/vi.d.ts.map +0 -1
  397. package/dist/locales/vi.js.map +0 -1
  398. package/dist/locales/zh.d.ts.map +0 -1
  399. package/dist/locales/zh.js.map +0 -1
  400. package/dist/logger.d.ts.map +0 -1
  401. package/dist/mini.d.ts.map +0 -1
  402. package/dist/mini.js.map +0 -1
  403. package/dist/pigment.d.ts.map +0 -1
  404. package/dist/pigment.js.map +0 -1
  405. package/dist/plugins/index.d.ts.map +0 -1
  406. package/dist/plugins/types.d.ts.map +0 -1
  407. package/dist/utils/codec-utils.d.ts.map +0 -1
  408. package/dist/utils/deep-merge.d.ts.map +0 -1
  409. package/dist/utils/ip-validation.d.ts.map +0 -1
  410. package/dist/utils/security.d.ts.map +0 -1
  411. package/dist/validators/any.d.ts.map +0 -1
  412. package/dist/validators/array.d.ts.map +0 -1
  413. package/dist/validators/base.d.ts.map +0 -1
  414. package/dist/validators/base64.d.ts.map +0 -1
  415. package/dist/validators/bigint.d.ts.map +0 -1
  416. package/dist/validators/boolean.d.ts.map +0 -1
  417. package/dist/validators/codec.d.ts.map +0 -1
  418. package/dist/validators/custom.d.ts.map +0 -1
  419. package/dist/validators/date.d.ts.map +0 -1
  420. package/dist/validators/discriminated-union.d.ts.map +0 -1
  421. package/dist/validators/enum.d.ts.map +0 -1
  422. package/dist/validators/file.d.ts.map +0 -1
  423. package/dist/validators/function.d.ts.map +0 -1
  424. package/dist/validators/hex.d.ts.map +0 -1
  425. package/dist/validators/index.d.ts.map +0 -1
  426. package/dist/validators/index.js.map +0 -1
  427. package/dist/validators/intersection.d.ts.map +0 -1
  428. package/dist/validators/json.d.ts.map +0 -1
  429. package/dist/validators/lazy.d.ts.map +0 -1
  430. package/dist/validators/literal.d.ts.map +0 -1
  431. package/dist/validators/map.d.ts.map +0 -1
  432. package/dist/validators/nan.d.ts.map +0 -1
  433. package/dist/validators/never.d.ts.map +0 -1
  434. package/dist/validators/null.d.ts.map +0 -1
  435. package/dist/validators/number.d.ts.map +0 -1
  436. package/dist/validators/object.d.ts.map +0 -1
  437. package/dist/validators/record.d.ts.map +0 -1
  438. package/dist/validators/set.d.ts.map +0 -1
  439. package/dist/validators/string-bool.d.ts.map +0 -1
  440. package/dist/validators/string-formats.d.ts.map +0 -1
  441. package/dist/validators/string.d.ts.map +0 -1
  442. package/dist/validators/symbol.d.ts.map +0 -1
  443. package/dist/validators/template-literal.d.ts.map +0 -1
  444. package/dist/validators/tuple.d.ts.map +0 -1
  445. package/dist/validators/uint8array.d.ts.map +0 -1
  446. package/dist/validators/undefined.d.ts.map +0 -1
  447. package/dist/validators/union.d.ts.map +0 -1
  448. package/dist/validators/unknown.d.ts.map +0 -1
  449. package/dist/validators/void.d.ts.map +0 -1
  450. package/dist/validators/xor.d.ts.map +0 -1
@@ -0,0 +1,864 @@
1
+ import { VldBase, VLD_VALIDATOR_TYPES, VldOptional } from './base.js';
2
+ import { getMessages } from '../locales/runtime.js';
3
+ import { VldEnum } from './enum.js';
4
+ import { i as isDangerousKey } from '../chunks/security-B0Pd_vSY.js';
5
+ import { V as VldError } from '../chunks/errors-core-BeiFUtZM.js';
6
+
7
+ /**
8
+ * Optimized immutable object validator with chainable methods
9
+ * Features pre-computed keys and Set-based lookups for better performance
10
+ */
11
+ class VldObject extends VldBase {
12
+ createSafeParseError(message) {
13
+ return new VldError([{ code: 'invalid_object', path: [], message }]);
14
+ }
15
+ /**
16
+ * Private constructor to enforce immutability
17
+ */
18
+ constructor(config) {
19
+ super(VLD_VALIDATOR_TYPES.OBJECT);
20
+ this._config = config;
21
+ // Pre-compute shape keys for faster access
22
+ this._shapeKeys = Object.keys(config.shape);
23
+ this._shapeKeysSet = new Set(this._shapeKeys);
24
+ this._validators = this._shapeKeys.map(k => this.tryGetFieldValidator(k));
25
+ // Pre-compute validator types when possible. Getter-based recursive schemas
26
+ // may reference the object being constructed, so unresolved getters fall
27
+ // back to the generic path and are resolved at parse time.
28
+ this._validatorTypes = this._shapeKeys.map((k, i) => this._validators[i]?.validatorType || this.getValidatorType(k));
29
+ this._simpleFieldModes = this._validators.map((validator, i) => this.getSimpleFieldMode(validator, this._validatorTypes[i]));
30
+ this._simpleFieldValues = this._validators.map((validator, i) => this._simpleFieldModes[i] === 'literal' ? validator.literal : undefined);
31
+ this._canUseSimpleObjectFastPath =
32
+ !config.strict &&
33
+ !config.passthrough &&
34
+ !config.catchall &&
35
+ this._shapeKeys.length > 0 &&
36
+ this._simpleFieldModes.every(mode => mode !== undefined);
37
+ this._canUseSafeParseFastPath =
38
+ this._validators.every(validator => validator instanceof VldBase) &&
39
+ (config.catchall === undefined || config.catchall instanceof VldBase);
40
+ }
41
+ tryGetFieldValidator(key) {
42
+ try {
43
+ const descriptor = Object.getOwnPropertyDescriptor(this._config.shape, key);
44
+ if (descriptor?.get) {
45
+ return undefined;
46
+ }
47
+ return this.resolveFieldValidator(key);
48
+ }
49
+ catch {
50
+ return undefined;
51
+ }
52
+ }
53
+ resolveFieldValidator(key) {
54
+ try {
55
+ const validator = this._config.shape[key];
56
+ if (!validator || typeof validator.safeParse !== 'function') {
57
+ return undefined;
58
+ }
59
+ return validator;
60
+ }
61
+ catch {
62
+ return undefined;
63
+ }
64
+ }
65
+ getFieldValidator(key, index) {
66
+ const cached = index === undefined ? undefined : this._validators[index];
67
+ const validator = cached || this.resolveFieldValidator(key);
68
+ if (!validator) {
69
+ throw new Error(`Invalid validator for field "${key}"`);
70
+ }
71
+ return validator;
72
+ }
73
+ getValidatorType(key) {
74
+ try {
75
+ const validator = this._config.shape[key];
76
+ return validator?.validatorType || VLD_VALIDATOR_TYPES.UNKNOWN;
77
+ }
78
+ catch {
79
+ return VLD_VALIDATOR_TYPES.UNKNOWN;
80
+ }
81
+ }
82
+ getSimpleFieldMode(validator, type) {
83
+ if (!validator || validator.isSimple !== true) {
84
+ return undefined;
85
+ }
86
+ switch (type) {
87
+ case VLD_VALIDATOR_TYPES.STRING:
88
+ return 'string';
89
+ case VLD_VALIDATOR_TYPES.NUMBER:
90
+ return 'number';
91
+ case VLD_VALIDATOR_TYPES.BOOLEAN:
92
+ return 'boolean';
93
+ case VLD_VALIDATOR_TYPES.BIGINT:
94
+ return 'bigint';
95
+ case VLD_VALIDATOR_TYPES.SYMBOL:
96
+ return 'symbol';
97
+ case VLD_VALIDATOR_TYPES.NULL:
98
+ return 'null';
99
+ case VLD_VALIDATOR_TYPES.UNDEFINED:
100
+ case VLD_VALIDATOR_TYPES.VOID:
101
+ return 'undefinedValue';
102
+ case VLD_VALIDATOR_TYPES.LITERAL:
103
+ return 'literal';
104
+ case VLD_VALIDATOR_TYPES.ANY:
105
+ case VLD_VALIDATOR_TYPES.UNKNOWN:
106
+ return 'passthrough';
107
+ default:
108
+ return undefined;
109
+ }
110
+ }
111
+ getSimpleFieldError(mode, expected, received) {
112
+ switch (mode) {
113
+ case 'string':
114
+ return getMessages().invalidString;
115
+ case 'number':
116
+ return getMessages().invalidNumber;
117
+ case 'boolean':
118
+ return getMessages().invalidBoolean;
119
+ case 'bigint':
120
+ return getMessages().invalidBigint;
121
+ case 'symbol':
122
+ return getMessages().invalidSymbol;
123
+ case 'null':
124
+ return `Expected null, received ${typeof received}`;
125
+ case 'undefinedValue':
126
+ return getMessages().expectedUndefined;
127
+ case 'literal':
128
+ return getMessages().literalExpected(JSON.stringify(expected), JSON.stringify(received));
129
+ case 'passthrough':
130
+ return getMessages().invalidObject;
131
+ default:
132
+ return getMessages().invalidObject;
133
+ }
134
+ }
135
+ parseCheckedField(validator, type, value) {
136
+ if (type === VLD_VALIDATOR_TYPES.STRING && typeof value === 'string') {
137
+ const parseKnownString = validator.parseKnownString;
138
+ if (typeof parseKnownString === 'function') {
139
+ return parseKnownString.call(validator, value);
140
+ }
141
+ }
142
+ if (type === VLD_VALIDATOR_TYPES.NUMBER && typeof value === 'number' && !isNaN(value)) {
143
+ const parseKnownNumber = validator.parseKnownNumber;
144
+ if (typeof parseKnownNumber === 'function') {
145
+ return parseKnownNumber.call(validator, value);
146
+ }
147
+ }
148
+ if (type === VLD_VALIDATOR_TYPES.BOOLEAN && typeof value === 'boolean') {
149
+ const parseKnownBoolean = validator.parseKnownBoolean;
150
+ if (typeof parseKnownBoolean === 'function') {
151
+ return parseKnownBoolean.call(validator, value);
152
+ }
153
+ }
154
+ if (type === VLD_VALIDATOR_TYPES.BIGINT && typeof value === 'bigint') {
155
+ const parseKnownBigInt = validator.parseKnownBigInt;
156
+ if (typeof parseKnownBigInt === 'function') {
157
+ return parseKnownBigInt.call(validator, value);
158
+ }
159
+ }
160
+ if (type === VLD_VALIDATOR_TYPES.SYMBOL && typeof value === 'symbol') {
161
+ const parseKnownSymbol = validator.parseKnownSymbol;
162
+ if (typeof parseKnownSymbol === 'function') {
163
+ return parseKnownSymbol.call(validator, value);
164
+ }
165
+ }
166
+ if (type === VLD_VALIDATOR_TYPES.FUNCTION && typeof value === 'function') {
167
+ const parseKnownFunction = validator.parseKnownFunction;
168
+ if (typeof parseKnownFunction === 'function') {
169
+ return parseKnownFunction.call(validator, value);
170
+ }
171
+ }
172
+ if (type === VLD_VALIDATOR_TYPES.FILE &&
173
+ typeof value === 'object' &&
174
+ value !== null &&
175
+ (('size' in value && 'type' in value) ||
176
+ (typeof File !== 'undefined' && value instanceof File))) {
177
+ const parseKnownFile = validator.parseKnownFile;
178
+ if (typeof parseKnownFile === 'function') {
179
+ return parseKnownFile.call(validator, value);
180
+ }
181
+ }
182
+ if (type === VLD_VALIDATOR_TYPES.DATE && value instanceof Date) {
183
+ const parseKnownDate = validator.parseKnownDate;
184
+ if (typeof parseKnownDate === 'function') {
185
+ return parseKnownDate.call(validator, value);
186
+ }
187
+ }
188
+ if (type === VLD_VALIDATOR_TYPES.OBJECT &&
189
+ typeof value === 'object' &&
190
+ value !== null &&
191
+ !Array.isArray(value)) {
192
+ const parseKnownObject = validator.parseKnownObject;
193
+ if (typeof parseKnownObject === 'function') {
194
+ return parseKnownObject.call(validator, value);
195
+ }
196
+ }
197
+ if (type === VLD_VALIDATOR_TYPES.ARRAY && Array.isArray(value)) {
198
+ const parseKnownArray = validator.parseKnownArray;
199
+ if (typeof parseKnownArray === 'function') {
200
+ return parseKnownArray.call(validator, value);
201
+ }
202
+ }
203
+ if (type === VLD_VALIDATOR_TYPES.TUPLE && Array.isArray(value)) {
204
+ const parseKnownTuple = validator.parseKnownTuple;
205
+ if (typeof parseKnownTuple === 'function') {
206
+ return parseKnownTuple.call(validator, value);
207
+ }
208
+ }
209
+ if (type === VLD_VALIDATOR_TYPES.RECORD &&
210
+ typeof value === 'object' &&
211
+ value !== null &&
212
+ !Array.isArray(value)) {
213
+ const parseKnownRecord = validator.parseKnownRecord;
214
+ if (typeof parseKnownRecord === 'function') {
215
+ return parseKnownRecord.call(validator, value);
216
+ }
217
+ }
218
+ if (type === VLD_VALIDATOR_TYPES.SET && value instanceof Set) {
219
+ const parseKnownSet = validator.parseKnownSet;
220
+ if (typeof parseKnownSet === 'function') {
221
+ return parseKnownSet.call(validator, value);
222
+ }
223
+ }
224
+ if (type === VLD_VALIDATOR_TYPES.MAP && value instanceof Map) {
225
+ const parseKnownMap = validator.parseKnownMap;
226
+ if (typeof parseKnownMap === 'function') {
227
+ return parseKnownMap.call(validator, value);
228
+ }
229
+ }
230
+ return validator.parse(value);
231
+ }
232
+ parseSimpleObjectValue(obj, trustedKey, skipTrustedLiteralCheck = false) {
233
+ if (this._shapeKeys.length === 2 &&
234
+ this._simpleFieldModes[0] === 'string' &&
235
+ this._simpleFieldModes[1] === 'number') {
236
+ const key0 = this._shapeKeys[0];
237
+ const value0 = obj[key0];
238
+ if (typeof value0 !== 'string') {
239
+ throw new Error(getMessages().objectField(key0, getMessages().invalidString));
240
+ }
241
+ const key1 = this._shapeKeys[1];
242
+ const value1 = obj[key1];
243
+ if (typeof value1 !== 'number' || isNaN(value1)) {
244
+ throw new Error(getMessages().objectField(key1, getMessages().invalidNumber));
245
+ }
246
+ const result = {};
247
+ result[key0] = value0;
248
+ result[key1] = value1;
249
+ return result;
250
+ }
251
+ if (this._shapeKeys.length === 3 &&
252
+ this._simpleFieldModes[0] === 'literal' &&
253
+ this._simpleFieldModes[1] === 'string' &&
254
+ this._simpleFieldModes[2] === 'number') {
255
+ const key0 = this._shapeKeys[0];
256
+ const value0 = obj[key0];
257
+ const literal0 = this._simpleFieldValues[0];
258
+ if (!(skipTrustedLiteralCheck && key0 === trustedKey) && value0 !== literal0) {
259
+ throw new Error(getMessages().objectField(key0, this.getSimpleFieldError('literal', literal0, value0)));
260
+ }
261
+ const key1 = this._shapeKeys[1];
262
+ const value1 = obj[key1];
263
+ if (typeof value1 !== 'string') {
264
+ throw new Error(getMessages().objectField(key1, getMessages().invalidString));
265
+ }
266
+ const key2 = this._shapeKeys[2];
267
+ const value2 = obj[key2];
268
+ if (typeof value2 !== 'number' || isNaN(value2)) {
269
+ throw new Error(getMessages().objectField(key2, getMessages().invalidNumber));
270
+ }
271
+ const result = {};
272
+ result[key0] = literal0;
273
+ result[key1] = value1;
274
+ result[key2] = value2;
275
+ return result;
276
+ }
277
+ const result = {};
278
+ for (let i = 0; i < this._shapeKeys.length; i++) {
279
+ const key = this._shapeKeys[i];
280
+ const fieldValue = obj[key];
281
+ const simpleMode = this._simpleFieldModes[i];
282
+ switch (simpleMode) {
283
+ case 'string':
284
+ if (typeof fieldValue !== 'string') {
285
+ throw new Error(getMessages().objectField(key, getMessages().invalidString));
286
+ }
287
+ result[key] = fieldValue;
288
+ break;
289
+ case 'number':
290
+ if (typeof fieldValue !== 'number' || isNaN(fieldValue)) {
291
+ throw new Error(getMessages().objectField(key, getMessages().invalidNumber));
292
+ }
293
+ result[key] = fieldValue;
294
+ break;
295
+ case 'boolean':
296
+ if (typeof fieldValue !== 'boolean') {
297
+ throw new Error(getMessages().objectField(key, getMessages().invalidBoolean));
298
+ }
299
+ result[key] = fieldValue;
300
+ break;
301
+ case 'bigint':
302
+ if (typeof fieldValue !== 'bigint') {
303
+ throw new Error(getMessages().objectField(key, getMessages().invalidBigint));
304
+ }
305
+ result[key] = fieldValue;
306
+ break;
307
+ case 'symbol':
308
+ if (typeof fieldValue !== 'symbol') {
309
+ throw new Error(getMessages().objectField(key, getMessages().invalidSymbol));
310
+ }
311
+ result[key] = fieldValue;
312
+ break;
313
+ case 'null':
314
+ if (fieldValue !== null) {
315
+ throw new Error(getMessages().objectField(key, this.getSimpleFieldError(simpleMode, undefined, fieldValue)));
316
+ }
317
+ result[key] = null;
318
+ break;
319
+ case 'undefinedValue':
320
+ if (fieldValue !== undefined) {
321
+ throw new Error(getMessages().objectField(key, getMessages().expectedUndefined));
322
+ }
323
+ result[key] = undefined;
324
+ break;
325
+ case 'literal':
326
+ if (skipTrustedLiteralCheck && key === trustedKey) {
327
+ result[key] = this._simpleFieldValues[i];
328
+ break;
329
+ }
330
+ if (fieldValue !== this._simpleFieldValues[i]) {
331
+ throw new Error(getMessages().objectField(key, this.getSimpleFieldError(simpleMode, this._simpleFieldValues[i], fieldValue)));
332
+ }
333
+ result[key] = this._simpleFieldValues[i];
334
+ break;
335
+ case 'passthrough':
336
+ result[key] = fieldValue;
337
+ break;
338
+ default:
339
+ throw new Error(getMessages().objectField(key, getMessages().invalidObject));
340
+ }
341
+ }
342
+ return result;
343
+ }
344
+ /**
345
+ * Get the validator configuration
346
+ * @internal Used by discriminated union validator
347
+ */
348
+ get config() {
349
+ return this._config;
350
+ }
351
+ /**
352
+ * Get the shape keys array
353
+ */
354
+ get shapeKeys() {
355
+ return this._shapeKeys;
356
+ }
357
+ /**
358
+ * Get the shape keys set for O(1) lookups
359
+ * @internal Used by discriminated union validator
360
+ */
361
+ get shapeKeysSet() {
362
+ return this._shapeKeysSet;
363
+ }
364
+ /**
365
+ * Create a new object validator
366
+ */
367
+ static create(shape) {
368
+ return new VldObject({ shape });
369
+ }
370
+ /**
371
+ * Parse and validate an object value
372
+ * Ultra-optimized with inline type checks and minimal overhead
373
+ */
374
+ parse(value) {
375
+ // Fast type check
376
+ if (typeof value !== 'object' || value === null || Array.isArray(value)) {
377
+ throw new Error(this._config.errorMessage || getMessages().invalidObject);
378
+ }
379
+ return this.parseObjectValue(value);
380
+ }
381
+ /**
382
+ * Parse an object value that already passed the object type guard.
383
+ * @internal Used by discriminated unions after discriminator lookup.
384
+ */
385
+ parseKnownObject(value, trustedKey) {
386
+ return this.parseObjectValue(value, trustedKey);
387
+ }
388
+ /**
389
+ * Parse an object after an owning discriminated union has already matched
390
+ * the discriminator value to this exact object schema.
391
+ * @internal
392
+ */
393
+ parseTrustedKnownObject(value, trustedKey) {
394
+ return this.parseObjectValue(value, trustedKey, true);
395
+ }
396
+ parseObjectValue(obj, trustedKey, skipTrustedLiteralCheck = false) {
397
+ if (this._canUseSimpleObjectFastPath) {
398
+ return this.parseSimpleObjectValue(obj, trustedKey, skipTrustedLiteralCheck);
399
+ }
400
+ const result = {};
401
+ // Validate fields directly on parse() to avoid safeParse result allocation
402
+ // in the successful hot path.
403
+ let currentKey = '';
404
+ try {
405
+ for (let i = 0; i < this._shapeKeys.length; i++) {
406
+ currentKey = this._shapeKeys[i];
407
+ if (skipTrustedLiteralCheck &&
408
+ currentKey === trustedKey &&
409
+ this._simpleFieldModes[i] === 'literal') {
410
+ result[currentKey] = this._simpleFieldValues[i];
411
+ continue;
412
+ }
413
+ const simpleMode = this._simpleFieldModes[i];
414
+ if (simpleMode !== undefined) {
415
+ const fieldValue = obj[currentKey];
416
+ switch (simpleMode) {
417
+ case 'string':
418
+ if (typeof fieldValue !== 'string') {
419
+ throw new Error(getMessages().invalidString);
420
+ }
421
+ result[currentKey] = fieldValue;
422
+ continue;
423
+ case 'number':
424
+ if (typeof fieldValue !== 'number' || isNaN(fieldValue)) {
425
+ throw new Error(getMessages().invalidNumber);
426
+ }
427
+ result[currentKey] = fieldValue;
428
+ continue;
429
+ case 'boolean':
430
+ if (typeof fieldValue !== 'boolean') {
431
+ throw new Error(getMessages().invalidBoolean);
432
+ }
433
+ result[currentKey] = fieldValue;
434
+ continue;
435
+ case 'bigint':
436
+ if (typeof fieldValue !== 'bigint') {
437
+ throw new Error(getMessages().invalidBigint);
438
+ }
439
+ result[currentKey] = fieldValue;
440
+ continue;
441
+ case 'symbol':
442
+ if (typeof fieldValue !== 'symbol') {
443
+ throw new Error(getMessages().invalidSymbol);
444
+ }
445
+ result[currentKey] = fieldValue;
446
+ continue;
447
+ case 'null':
448
+ if (fieldValue !== null) {
449
+ throw new Error(this.getSimpleFieldError(simpleMode, undefined, fieldValue));
450
+ }
451
+ result[currentKey] = null;
452
+ continue;
453
+ case 'undefinedValue':
454
+ if (fieldValue !== undefined) {
455
+ throw new Error(getMessages().expectedUndefined);
456
+ }
457
+ result[currentKey] = undefined;
458
+ continue;
459
+ case 'literal':
460
+ if (fieldValue !== this._simpleFieldValues[i]) {
461
+ throw new Error(this.getSimpleFieldError(simpleMode, this._simpleFieldValues[i], fieldValue));
462
+ }
463
+ result[currentKey] = this._simpleFieldValues[i];
464
+ continue;
465
+ case 'passthrough':
466
+ result[currentKey] = fieldValue;
467
+ continue;
468
+ }
469
+ continue;
470
+ }
471
+ const validator = this.getFieldValidator(currentKey, i);
472
+ result[currentKey] = this.parseCheckedField(validator, this._validatorTypes[i], obj[currentKey]);
473
+ }
474
+ }
475
+ catch (error) {
476
+ throw new Error(getMessages().objectField(currentKey, error.message));
477
+ }
478
+ // Handle strict/passthrough/catchall modes - optimized single Object.keys() call
479
+ if (this._config.strict || this._config.passthrough || this._config.catchall) {
480
+ const objKeys = Object.keys(obj);
481
+ // Handle strict mode - optimized with Set
482
+ if (this._config.strict) {
483
+ const extraKeys = [];
484
+ for (let i = 0; i < objKeys.length; i++) {
485
+ const key = objKeys[i];
486
+ if (!this._shapeKeysSet.has(key)) {
487
+ extraKeys.push(key);
488
+ }
489
+ }
490
+ if (extraKeys.length > 0) {
491
+ throw new Error(getMessages().unexpectedKeys(extraKeys));
492
+ }
493
+ }
494
+ // Handle passthrough mode - optimized with comprehensive prototype pollution protection
495
+ if (this._config.passthrough) {
496
+ for (let i = 0; i < objKeys.length; i++) {
497
+ const key = objKeys[i];
498
+ // Skip dangerous keys to prevent prototype pollution
499
+ if (!this._shapeKeysSet.has(key) && !isDangerousKey(key)) {
500
+ result[key] = obj[key];
501
+ }
502
+ }
503
+ }
504
+ // Handle catchall - validate extra keys with catchall validator
505
+ if (this._config.catchall) {
506
+ for (let i = 0; i < objKeys.length; i++) {
507
+ const key = objKeys[i];
508
+ // Skip keys already in shape and dangerous keys
509
+ if (!this._shapeKeysSet.has(key) && !isDangerousKey(key)) {
510
+ try {
511
+ result[key] = this._config.catchall.parse(obj[key]);
512
+ }
513
+ catch (error) {
514
+ throw new Error(getMessages().objectField(key, error.message));
515
+ }
516
+ }
517
+ }
518
+ }
519
+ }
520
+ return result;
521
+ }
522
+ /**
523
+ * Safely parse and validate an object value
524
+ * Optimized version using pre-computed keys
525
+ */
526
+ safeParse(value) {
527
+ // Fast type check
528
+ if (typeof value !== 'object' || value === null || Array.isArray(value)) {
529
+ return {
530
+ success: false,
531
+ error: this.createSafeParseError(this._config.errorMessage || getMessages().invalidObject)
532
+ };
533
+ }
534
+ const obj = value;
535
+ if (this._canUseSimpleObjectFastPath) {
536
+ try {
537
+ return { success: true, data: this.parseSimpleObjectValue(obj) };
538
+ }
539
+ catch (error) {
540
+ return { success: false, error: this.createSafeParseError(error.message) };
541
+ }
542
+ }
543
+ if (this._canUseSafeParseFastPath) {
544
+ try {
545
+ return { success: true, data: this.parseObjectValue(obj) };
546
+ }
547
+ catch (error) {
548
+ return { success: false, error: this.createSafeParseError(error.message) };
549
+ }
550
+ }
551
+ const result = {};
552
+ // Ultra-optimized field validation - use pre-computed validatorTypes in hot path
553
+ for (let i = 0; i < this._shapeKeys.length; i++) {
554
+ const key = this._shapeKeys[i];
555
+ const fieldValue = obj[key];
556
+ const simpleMode = this._simpleFieldModes[i];
557
+ if (simpleMode !== undefined) {
558
+ if ((simpleMode === 'string' && typeof fieldValue === 'string') ||
559
+ (simpleMode === 'number' && typeof fieldValue === 'number' && !isNaN(fieldValue)) ||
560
+ (simpleMode === 'boolean' && typeof fieldValue === 'boolean') ||
561
+ (simpleMode === 'bigint' && typeof fieldValue === 'bigint') ||
562
+ (simpleMode === 'symbol' && typeof fieldValue === 'symbol') ||
563
+ (simpleMode === 'null' && fieldValue === null) ||
564
+ (simpleMode === 'undefinedValue' && fieldValue === undefined) ||
565
+ (simpleMode === 'literal' && fieldValue === this._simpleFieldValues[i]) ||
566
+ simpleMode === 'passthrough') {
567
+ result[key] = simpleMode === 'literal'
568
+ ? this._simpleFieldValues[i]
569
+ : simpleMode === 'null'
570
+ ? null
571
+ : fieldValue;
572
+ continue;
573
+ }
574
+ return {
575
+ success: false,
576
+ error: this.createSafeParseError(getMessages().objectField(key, this.getSimpleFieldError(simpleMode, this._simpleFieldValues[i], fieldValue)))
577
+ };
578
+ }
579
+ let validator;
580
+ try {
581
+ validator = this.getFieldValidator(key, i);
582
+ }
583
+ catch (error) {
584
+ const message = error instanceof Error ? error.message : String(error);
585
+ return {
586
+ success: false,
587
+ error: this.createSafeParseError(getMessages().objectField(key, message))
588
+ };
589
+ }
590
+ try {
591
+ if (validator instanceof VldBase) {
592
+ result[key] = this.parseCheckedField(validator, this._validatorTypes[i], fieldValue);
593
+ }
594
+ else {
595
+ const parseResult = validator.safeParse(fieldValue);
596
+ if (!parseResult.success) {
597
+ return {
598
+ success: false,
599
+ error: this.createSafeParseError(getMessages().objectField(key, parseResult.error.message))
600
+ };
601
+ }
602
+ result[key] = parseResult.data;
603
+ }
604
+ }
605
+ catch (error) {
606
+ const message = error instanceof Error ? error.message : String(error);
607
+ return {
608
+ success: false,
609
+ error: this.createSafeParseError(getMessages().objectField(key, message))
610
+ };
611
+ }
612
+ }
613
+ // Handle strict/passthrough/catchall modes - optimized single Object.keys() call
614
+ if (this._config.strict || this._config.passthrough || this._config.catchall) {
615
+ const objKeys = Object.keys(obj);
616
+ // Handle strict mode
617
+ if (this._config.strict) {
618
+ const extraKeys = [];
619
+ for (let i = 0; i < objKeys.length; i++) {
620
+ const key = objKeys[i];
621
+ if (!this._shapeKeysSet.has(key)) {
622
+ extraKeys.push(key);
623
+ }
624
+ }
625
+ if (extraKeys.length > 0) {
626
+ return {
627
+ success: false,
628
+ error: this.createSafeParseError(getMessages().unexpectedKeys(extraKeys))
629
+ };
630
+ }
631
+ }
632
+ // Handle passthrough mode with comprehensive prototype pollution protection
633
+ if (this._config.passthrough) {
634
+ for (let i = 0; i < objKeys.length; i++) {
635
+ const key = objKeys[i];
636
+ // Skip dangerous keys to prevent prototype pollution
637
+ if (!this._shapeKeysSet.has(key) && !isDangerousKey(key)) {
638
+ result[key] = obj[key];
639
+ }
640
+ }
641
+ }
642
+ // Handle catchall - validate extra keys with catchall validator
643
+ if (this._config.catchall) {
644
+ const catchallValidator = this._config.catchall;
645
+ for (let i = 0; i < objKeys.length; i++) {
646
+ const key = objKeys[i];
647
+ // Skip keys already in shape and dangerous keys
648
+ if (!this._shapeKeysSet.has(key) && !isDangerousKey(key)) {
649
+ try {
650
+ if (catchallValidator instanceof VldBase) {
651
+ result[key] = catchallValidator.parse(obj[key]);
652
+ }
653
+ else {
654
+ const catchallResult = catchallValidator.safeParse(obj[key]);
655
+ if (!catchallResult.success) {
656
+ return {
657
+ success: false,
658
+ error: this.createSafeParseError(getMessages().objectField(key, catchallResult.error.message))
659
+ };
660
+ }
661
+ result[key] = catchallResult.data;
662
+ }
663
+ }
664
+ catch (error) {
665
+ const message = error instanceof Error ? error.message : String(error);
666
+ return {
667
+ success: false,
668
+ error: this.createSafeParseError(getMessages().objectField(key, message))
669
+ };
670
+ }
671
+ }
672
+ }
673
+ }
674
+ }
675
+ return { success: true, data: result };
676
+ }
677
+ /**
678
+ * Create a new validator in strict mode (no extra keys allowed)
679
+ */
680
+ strict(message) {
681
+ return new VldObject({
682
+ ...this._config,
683
+ strict: true,
684
+ passthrough: false,
685
+ errorMessage: message
686
+ });
687
+ }
688
+ /**
689
+ * Create a new validator in passthrough mode (extra keys are preserved)
690
+ */
691
+ passthrough() {
692
+ return new VldObject({
693
+ ...this._config,
694
+ strict: false,
695
+ passthrough: true
696
+ });
697
+ }
698
+ /**
699
+ * Create a new validator with all fields optional
700
+ */
701
+ partial() {
702
+ const partialShape = {};
703
+ for (const key in this._config.shape) {
704
+ partialShape[key] = new VldOptional(this._config.shape[key]);
705
+ }
706
+ return new VldObject({
707
+ ...this._config,
708
+ shape: partialShape
709
+ });
710
+ }
711
+ /**
712
+ * Create a new validator with deep partial (nested objects also partial)
713
+ */
714
+ deepPartial() {
715
+ const deepPartialShape = {};
716
+ for (const key in this._config.shape) {
717
+ const validator = this._config.shape[key];
718
+ if (validator instanceof VldObject) {
719
+ deepPartialShape[key] = new VldOptional(validator.deepPartial());
720
+ }
721
+ else {
722
+ deepPartialShape[key] = new VldOptional(validator);
723
+ }
724
+ }
725
+ return new VldObject({
726
+ ...this._config,
727
+ shape: deepPartialShape
728
+ });
729
+ }
730
+ /**
731
+ * Create a new validator with only specified keys
732
+ */
733
+ pick(...keys) {
734
+ const pickedShape = {};
735
+ for (const key of keys) {
736
+ if (key in this._config.shape) {
737
+ pickedShape[key] = this._config.shape[key];
738
+ }
739
+ }
740
+ return new VldObject({
741
+ ...this._config,
742
+ shape: pickedShape
743
+ });
744
+ }
745
+ /**
746
+ * Create a new validator without specified keys
747
+ */
748
+ omit(...keys) {
749
+ const omittedShape = {};
750
+ const keysToOmit = new Set(keys);
751
+ for (const key in this._config.shape) {
752
+ if (!keysToOmit.has(key)) {
753
+ omittedShape[key] = this._config.shape[key];
754
+ }
755
+ }
756
+ return new VldObject({
757
+ ...this._config,
758
+ shape: omittedShape
759
+ });
760
+ }
761
+ /**
762
+ * Create a new validator with additional fields
763
+ */
764
+ extend(extension) {
765
+ return new VldObject({
766
+ ...this._config,
767
+ shape: { ...this._config.shape, ...extension }
768
+ });
769
+ }
770
+ /**
771
+ * Create a new validator by merging with another object validator
772
+ */
773
+ merge(other) {
774
+ return new VldObject({
775
+ ...this._config,
776
+ shape: { ...this._config.shape, ...other.config.shape }
777
+ });
778
+ }
779
+ /**
780
+ * Create a new validator with all fields required (removes optional)
781
+ */
782
+ required() {
783
+ const requiredShape = {};
784
+ for (const key in this._config.shape) {
785
+ const validator = this._config.shape[key];
786
+ // If it's optional, unwrap it
787
+ if (validator instanceof VldOptional) {
788
+ // BUG-001 FIX: Add defensive check for baseValidator property
789
+ const unwrapped = validator.baseValidator;
790
+ if (!unwrapped || typeof unwrapped.parse !== 'function') {
791
+ throw new Error(`Invalid VldOptional structure for field "${key}": missing or invalid baseValidator`);
792
+ }
793
+ requiredShape[key] = unwrapped;
794
+ }
795
+ else {
796
+ requiredShape[key] = validator;
797
+ }
798
+ }
799
+ return new VldObject({
800
+ ...this._config,
801
+ shape: requiredShape
802
+ });
803
+ }
804
+ /**
805
+ * Create a new validator with a catchall validator for extra keys
806
+ * Zod 4 API parity - validates unknown keys with provided schema
807
+ */
808
+ catchall(schema) {
809
+ return new VldObject({
810
+ ...this._config,
811
+ catchall: schema,
812
+ passthrough: false // catchall overrides passthrough
813
+ });
814
+ }
815
+ /**
816
+ * Access the inner shape schemas
817
+ * Zod 4 API parity - returns the shape object
818
+ */
819
+ get shape() {
820
+ return this._config.shape;
821
+ }
822
+ /**
823
+ * Create an enum validator from object keys
824
+ * Zod 4 API parity - creates literal union of keys
825
+ */
826
+ keyof() {
827
+ const keys = Object.keys(this._config.shape);
828
+ if (keys.length === 0) {
829
+ throw new Error('Cannot create keyof enum from empty object');
830
+ }
831
+ return VldEnum.create(keys);
832
+ }
833
+ /**
834
+ * Type-safe extend that throws an error if any key already exists
835
+ * Zod 4 API parity - prevents accidental field override
836
+ * @param extension The extension shape to add
837
+ * @returns A new validator with extended shape
838
+ * @throws {Error} If any extension key already exists in the shape
839
+ * @example
840
+ * const base = v.object({ name: v.string() });
841
+ * const extended = base.safeExtend({ age: v.number() }); // OK
842
+ * const invalid = base.safeExtend({ name: v.number() }); // Throws error
843
+ */
844
+ safeExtend(extension) {
845
+ // Check for overlapping keys
846
+ const existingKeys = new Set(Object.keys(this._config.shape));
847
+ const extensionKeys = Object.keys(extension);
848
+ const overlappingKeys = [];
849
+ for (const key of extensionKeys) {
850
+ if (existingKeys.has(key)) {
851
+ overlappingKeys.push(key);
852
+ }
853
+ }
854
+ if (overlappingKeys.length > 0) {
855
+ throw new Error(`safeExtend: ${getMessages().safeExtendOverlap(overlappingKeys)}`);
856
+ }
857
+ return new VldObject({
858
+ ...this._config,
859
+ shape: { ...this._config.shape, ...extension }
860
+ });
861
+ }
862
+ }
863
+
864
+ export { VldObject };