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