@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,58 @@
1
+ /**
2
+ * Promise validator - validates Promise values
3
+ * Validates that the resolved value matches the inner schema
4
+ */
5
+ import { type ParseResult, type StandardSchemaV1Props } from './base.js';
6
+ type PromiseInner<T> = {
7
+ parse(value: unknown): T;
8
+ safeParse(value: unknown): ParseResult<T>;
9
+ parseAsync?(value: unknown): Promise<T>;
10
+ safeParseAsync?(value: unknown): Promise<ParseResult<T>>;
11
+ };
12
+ /**
13
+ * Promise validator - validates Promise<T> where T matches inner schema
14
+ * Zod 4 API parity - allows async validation with proper type inference
15
+ *
16
+ * Validates that the input is a Promise, and validates the resolved value
17
+ * against the inner schema when parsed.
18
+ *
19
+ * Use parseAsync() or safeParseAsync() for proper async handling.
20
+ */
21
+ export declare class VldPromise<T> {
22
+ private readonly inner;
23
+ readonly validatorType: "promise";
24
+ constructor(inner: PromiseInner<T>);
25
+ get '~standard'(): StandardSchemaV1Props<unknown, T>;
26
+ /**
27
+ * Check if value is thenable (Promise-like)
28
+ * Must be called BEFORE wrapping in Promise.resolve
29
+ */
30
+ private _isThenable;
31
+ unwrap(): PromiseInner<T>;
32
+ /**
33
+ * Parse and validate a Promise value asynchronously
34
+ * @param value The Promise to validate
35
+ * @returns The validated value
36
+ * @throws {Error} If validation fails when Promise resolves
37
+ */
38
+ parse(value: unknown): Promise<T>;
39
+ parseAsync(value: unknown): Promise<T>;
40
+ /**
41
+ * Safely parse and validate a Promise value asynchronously
42
+ * @param value The Promise to validate
43
+ * @returns A Promise resolving to ParseResult containing the validated value
44
+ */
45
+ safeParse(value: unknown): Promise<ParseResult<T>>;
46
+ safeParseAsync(value: unknown): Promise<ParseResult<T>>;
47
+ }
48
+ /**
49
+ * Create a Promise validator
50
+ * @param inner The schema to validate the resolved value against
51
+ * @returns A new Promise validator
52
+ * @example
53
+ * const promiseSchema = v.promise(v.string());
54
+ * const result = await promiseSchema.parse(Promise.resolve("hello"));
55
+ * // result is string
56
+ */
57
+ export declare function promise<T>(inner: PromiseInner<T>): VldPromise<T>;
58
+ export {};
@@ -0,0 +1,111 @@
1
+ import { VLD_VALIDATOR_TYPES } from './base.js';
2
+
3
+ /**
4
+ * Promise validator - validates Promise values
5
+ * Validates that the resolved value matches the inner schema
6
+ */
7
+ /**
8
+ * Promise validator - validates Promise<T> where T matches inner schema
9
+ * Zod 4 API parity - allows async validation with proper type inference
10
+ *
11
+ * Validates that the input is a Promise, and validates the resolved value
12
+ * against the inner schema when parsed.
13
+ *
14
+ * Use parseAsync() or safeParseAsync() for proper async handling.
15
+ */
16
+ class VldPromise {
17
+ constructor(inner) {
18
+ this.inner = inner;
19
+ this.validatorType = VLD_VALIDATOR_TYPES.PROMISE;
20
+ }
21
+ get '~standard'() {
22
+ return {
23
+ version: 1,
24
+ vendor: 'vld',
25
+ validate: async (value) => {
26
+ const result = await this.safeParseAsync(value);
27
+ if (result.success) {
28
+ return { value: result.data };
29
+ }
30
+ return { issues: [{ message: result.error.message }] };
31
+ },
32
+ types: undefined
33
+ };
34
+ }
35
+ /**
36
+ * Check if value is thenable (Promise-like)
37
+ * Must be called BEFORE wrapping in Promise.resolve
38
+ */
39
+ _isThenable(value) {
40
+ return value !== null && typeof value.then === 'function';
41
+ }
42
+ unwrap() {
43
+ return this.inner;
44
+ }
45
+ /**
46
+ * Parse and validate a Promise value asynchronously
47
+ * @param value The Promise to validate
48
+ * @returns The validated value
49
+ * @throws {Error} If validation fails when Promise resolves
50
+ */
51
+ async parse(value) {
52
+ // Check if value is thenable BEFORE wrapping in Promise.resolve
53
+ if (!this._isThenable(value)) {
54
+ throw new Error('Expected a Promise value');
55
+ }
56
+ // Now we can safely await it
57
+ const resolved = await Promise.resolve(value);
58
+ return this.inner.parseAsync ? this.inner.parseAsync(resolved) : this.inner.parse(resolved);
59
+ }
60
+ parseAsync(value) {
61
+ return this.parse(value);
62
+ }
63
+ /**
64
+ * Safely parse and validate a Promise value asynchronously
65
+ * @param value The Promise to validate
66
+ * @returns A Promise resolving to ParseResult containing the validated value
67
+ */
68
+ async safeParse(value) {
69
+ // Check if value is thenable BEFORE wrapping in Promise.resolve
70
+ if (!this._isThenable(value)) {
71
+ return {
72
+ success: false,
73
+ error: new Error('Expected a Promise value')
74
+ };
75
+ }
76
+ try {
77
+ const resolved = await Promise.resolve(value);
78
+ if (this.inner.safeParseAsync) {
79
+ return await this.inner.safeParseAsync(resolved);
80
+ }
81
+ const innerResult = this.inner.safeParse(resolved);
82
+ if (!innerResult.success) {
83
+ return innerResult;
84
+ }
85
+ return { success: true, data: innerResult.data };
86
+ }
87
+ catch (err) {
88
+ return {
89
+ success: false,
90
+ error: err instanceof Error ? err : new Error(String(err))
91
+ };
92
+ }
93
+ }
94
+ safeParseAsync(value) {
95
+ return this.safeParse(value);
96
+ }
97
+ }
98
+ /**
99
+ * Create a Promise validator
100
+ * @param inner The schema to validate the resolved value against
101
+ * @returns A new Promise validator
102
+ * @example
103
+ * const promiseSchema = v.promise(v.string());
104
+ * const result = await promiseSchema.parse(Promise.resolve("hello"));
105
+ * // result is string
106
+ */
107
+ function promise(inner) {
108
+ return new VldPromise(inner);
109
+ }
110
+
111
+ export { VldPromise, promise };
@@ -1,4 +1,4 @@
1
- import { VldBase, ParseResult } from './base';
1
+ import { VldBase, ParseResult } from './base.js';
2
2
  /**
3
3
  * Immutable record validator for key-value pairs
4
4
  * BUG-NEW-018 FIX: Uses comprehensive dangerous key protection
@@ -10,15 +10,25 @@ export declare class VldRecord<T> extends VldBase<unknown, Record<string, T>> {
10
10
  * Private constructor to enforce immutability
11
11
  */
12
12
  protected constructor(valueValidator: VldBase<unknown, T>, errorMessage?: string | undefined);
13
+ private readonly _simpleValueMode;
14
+ private readonly _simpleValue;
15
+ get valueSchema(): VldBase<unknown, T>;
13
16
  /**
14
17
  * Create a new record validator
15
18
  */
16
19
  static create<T>(valueValidator: VldBase<unknown, T>): VldRecord<T>;
20
+ private getSimpleValueMode;
21
+ private getSimpleValueError;
17
22
  /**
18
23
  * Parse and validate a record value
19
24
  * BUG-NEW-018 FIX: Use comprehensive dangerous key protection
20
25
  */
21
26
  parse(value: unknown): Record<string, T>;
27
+ /**
28
+ * Parse a value that has already passed the record object type guard.
29
+ * @internal Used by object validators to avoid duplicate hot-path checks.
30
+ */
31
+ parseKnownRecord(obj: Record<string, unknown>): Record<string, T>;
22
32
  /**
23
33
  * Safely parse and validate a record value
24
34
  */
@@ -35,4 +45,3 @@ export declare class VldRecord<T> extends VldBase<unknown, Record<string, T>> {
35
45
  */
36
46
  loose(): VldBase<unknown, Record<string, T>>;
37
47
  }
38
- //# sourceMappingURL=record.d.ts.map
@@ -0,0 +1,258 @@
1
+ import { VldBase, VLD_VALIDATOR_TYPES } from './base.js';
2
+ import { getMessages } from '../locales/runtime.js';
3
+ import { i as isDangerousKey } from '../chunks/security-B0Pd_vSY.js';
4
+ import { V as VldError } from '../chunks/errors-core-BeiFUtZM.js';
5
+
6
+ function createRecordError(message) {
7
+ return new VldError([{ code: 'invalid_object', path: [], message }]);
8
+ }
9
+ /**
10
+ * Immutable record validator for key-value pairs
11
+ * BUG-NEW-018 FIX: Uses comprehensive dangerous key protection
12
+ */
13
+ class VldRecord extends VldBase {
14
+ /**
15
+ * Private constructor to enforce immutability
16
+ */
17
+ constructor(valueValidator, errorMessage) {
18
+ super(VLD_VALIDATOR_TYPES.RECORD);
19
+ this.valueValidator = valueValidator;
20
+ this.errorMessage = errorMessage;
21
+ this._simpleValueMode = this.getSimpleValueMode(valueValidator);
22
+ this._simpleValue = this._simpleValueMode === 'literal' ? valueValidator.literal : undefined;
23
+ }
24
+ get valueSchema() {
25
+ return this.valueValidator;
26
+ }
27
+ /**
28
+ * Create a new record validator
29
+ */
30
+ static create(valueValidator) {
31
+ return new VldRecord(valueValidator);
32
+ }
33
+ getSimpleValueMode(valueValidator) {
34
+ if (valueValidator.isSimple !== true) {
35
+ return undefined;
36
+ }
37
+ switch (valueValidator.validatorType) {
38
+ case VLD_VALIDATOR_TYPES.STRING:
39
+ return 'string';
40
+ case VLD_VALIDATOR_TYPES.NUMBER:
41
+ return 'number';
42
+ case VLD_VALIDATOR_TYPES.BOOLEAN:
43
+ return 'boolean';
44
+ case VLD_VALIDATOR_TYPES.BIGINT:
45
+ return 'bigint';
46
+ case VLD_VALIDATOR_TYPES.SYMBOL:
47
+ return 'symbol';
48
+ case VLD_VALIDATOR_TYPES.NULL:
49
+ return 'null';
50
+ case VLD_VALIDATOR_TYPES.UNDEFINED:
51
+ case VLD_VALIDATOR_TYPES.VOID:
52
+ return 'undefinedValue';
53
+ case VLD_VALIDATOR_TYPES.LITERAL:
54
+ return 'literal';
55
+ case VLD_VALIDATOR_TYPES.ANY:
56
+ case VLD_VALIDATOR_TYPES.UNKNOWN:
57
+ return 'passthrough';
58
+ default:
59
+ return undefined;
60
+ }
61
+ }
62
+ getSimpleValueError(received) {
63
+ switch (this._simpleValueMode) {
64
+ case 'string':
65
+ return getMessages().invalidString;
66
+ case 'number':
67
+ return getMessages().invalidNumber;
68
+ case 'boolean':
69
+ return getMessages().invalidBoolean;
70
+ case 'bigint':
71
+ return getMessages().invalidBigint;
72
+ case 'symbol':
73
+ return getMessages().invalidSymbol;
74
+ case 'null':
75
+ return `Expected null, received ${typeof received}`;
76
+ case 'undefinedValue':
77
+ return getMessages().expectedUndefined;
78
+ case 'literal':
79
+ return getMessages().literalExpected(JSON.stringify(this._simpleValue), JSON.stringify(received));
80
+ default:
81
+ return getMessages().invalidRecord;
82
+ }
83
+ }
84
+ /**
85
+ * Parse and validate a record value
86
+ * BUG-NEW-018 FIX: Use comprehensive dangerous key protection
87
+ */
88
+ parse(value) {
89
+ if (typeof value !== 'object' || value === null || Array.isArray(value)) {
90
+ throw new Error(this.errorMessage || getMessages().invalidRecord);
91
+ }
92
+ return this.parseKnownRecord(value);
93
+ }
94
+ /**
95
+ * Parse a value that has already passed the record object type guard.
96
+ * @internal Used by object validators to avoid duplicate hot-path checks.
97
+ */
98
+ parseKnownRecord(obj) {
99
+ const result = {};
100
+ const keys = Object.keys(obj);
101
+ const simpleMode = this._simpleValueMode;
102
+ for (let i = 0; i < keys.length; i++) {
103
+ const key = keys[i];
104
+ // Skip dangerous keys to prevent prototype pollution
105
+ // Now using comprehensive protection from shared utility
106
+ if (isDangerousKey(key)) {
107
+ continue;
108
+ }
109
+ const val = obj[key];
110
+ if (simpleMode !== undefined) {
111
+ switch (simpleMode) {
112
+ case 'string':
113
+ if (typeof val !== 'string') {
114
+ throw new Error(getMessages().objectField(key, getMessages().invalidString));
115
+ }
116
+ result[key] = val;
117
+ continue;
118
+ case 'number':
119
+ if (typeof val !== 'number' || isNaN(val)) {
120
+ throw new Error(getMessages().objectField(key, getMessages().invalidNumber));
121
+ }
122
+ result[key] = val;
123
+ continue;
124
+ case 'boolean':
125
+ if (typeof val !== 'boolean') {
126
+ throw new Error(getMessages().objectField(key, getMessages().invalidBoolean));
127
+ }
128
+ result[key] = val;
129
+ continue;
130
+ case 'bigint':
131
+ if (typeof val !== 'bigint') {
132
+ throw new Error(getMessages().objectField(key, getMessages().invalidBigint));
133
+ }
134
+ result[key] = val;
135
+ continue;
136
+ case 'symbol':
137
+ if (typeof val !== 'symbol') {
138
+ throw new Error(getMessages().objectField(key, getMessages().invalidSymbol));
139
+ }
140
+ result[key] = val;
141
+ continue;
142
+ case 'null':
143
+ if (val !== null) {
144
+ throw new Error(getMessages().objectField(key, this.getSimpleValueError(val)));
145
+ }
146
+ result[key] = null;
147
+ continue;
148
+ case 'undefinedValue':
149
+ if (val !== undefined) {
150
+ throw new Error(getMessages().objectField(key, getMessages().expectedUndefined));
151
+ }
152
+ result[key] = undefined;
153
+ continue;
154
+ case 'literal':
155
+ if (val !== this._simpleValue) {
156
+ throw new Error(getMessages().objectField(key, this.getSimpleValueError(val)));
157
+ }
158
+ result[key] = this._simpleValue;
159
+ continue;
160
+ case 'passthrough':
161
+ result[key] = val;
162
+ continue;
163
+ }
164
+ }
165
+ try {
166
+ result[key] = this.valueValidator.parse(val);
167
+ }
168
+ catch (error) {
169
+ throw new Error(getMessages().objectField(key, error.message));
170
+ }
171
+ }
172
+ return result;
173
+ }
174
+ /**
175
+ * Safely parse and validate a record value
176
+ */
177
+ safeParse(value) {
178
+ try {
179
+ return { success: true, data: this.parse(value) };
180
+ }
181
+ catch (error) {
182
+ return { success: false, error: createRecordError(error.message) };
183
+ }
184
+ }
185
+ /**
186
+ * Create a partial record variant (all keys optional)
187
+ * Similar to v.object().partial() but for records
188
+ */
189
+ partial() {
190
+ const optionalValidator = this.valueValidator.optional();
191
+ return new VldRecord(optionalValidator);
192
+ }
193
+ /**
194
+ * Create a loose record variant (allows extra keys)
195
+ * Similar to v.object().passthrough() but for records
196
+ * Note: Records already allow any keys, so this mainly affects error handling
197
+ */
198
+ loose() {
199
+ // For records, "loose" means we don't throw errors for validation failures
200
+ // We return a modified version that catches validation errors
201
+ return new VldLooseRecord(this.valueValidator);
202
+ }
203
+ }
204
+ /**
205
+ * Loose record variant that allows validation failures
206
+ * Used internally by .loose() method
207
+ */
208
+ class VldLooseRecord extends VldBase {
209
+ constructor(valueValidator) {
210
+ super(VLD_VALIDATOR_TYPES.RECORD);
211
+ this.valueValidator = valueValidator;
212
+ }
213
+ get valueSchema() {
214
+ return this.valueValidator;
215
+ }
216
+ parse(value) {
217
+ if (typeof value !== 'object' || value === null || Array.isArray(value)) {
218
+ throw new Error(getMessages().invalidRecord);
219
+ }
220
+ const result = {};
221
+ const obj = value;
222
+ for (const [key, val] of Object.entries(obj)) {
223
+ // Skip dangerous keys
224
+ if (isDangerousKey(key)) {
225
+ continue;
226
+ }
227
+ // For loose records, skip invalid values instead of throwing
228
+ const parseResult = this.valueValidator.safeParse(val);
229
+ if (parseResult.success) {
230
+ result[key] = parseResult.data;
231
+ }
232
+ }
233
+ return result;
234
+ }
235
+ safeParse(value) {
236
+ try {
237
+ return { success: true, data: this.parse(value) };
238
+ }
239
+ catch (error) {
240
+ return { success: false, error: createRecordError(error.message) };
241
+ }
242
+ }
243
+ /**
244
+ * Create a partial variant (all keys optional)
245
+ */
246
+ partial() {
247
+ const optionalValidator = this.valueValidator.optional();
248
+ return new VldLooseRecord(optionalValidator);
249
+ }
250
+ /**
251
+ * Return self (already loose)
252
+ */
253
+ loose() {
254
+ return this;
255
+ }
256
+ }
257
+
258
+ export { VldRecord };
@@ -1,4 +1,4 @@
1
- import { VldBase, ParseResult } from './base';
1
+ import { VldBase, ParseResult } from './base.js';
2
2
  /**
3
3
  * Immutable Set validator
4
4
  */
@@ -9,17 +9,26 @@ export declare class VldSet<T> extends VldBase<unknown, Set<T>> {
9
9
  * Private constructor to enforce immutability
10
10
  */
11
11
  private constructor();
12
+ private readonly _simpleItemMode;
13
+ private readonly _simpleItemValue;
14
+ get itemSchema(): VldBase<unknown, T>;
12
15
  /**
13
16
  * Create a new Set validator
14
17
  */
15
18
  static create<T>(itemValidator: VldBase<unknown, T>): VldSet<T>;
19
+ private getSimpleItemMode;
20
+ private getSimpleItemError;
16
21
  /**
17
22
  * Parse and validate a Set value
18
23
  */
19
24
  parse(value: unknown): Set<T>;
25
+ /**
26
+ * Parse a value that has already passed the Set instance guard.
27
+ * @internal Used by object validators to avoid duplicate hot-path checks.
28
+ */
29
+ parseKnownSet(value: Set<unknown>): Set<T>;
20
30
  /**
21
31
  * Safely parse and validate a Set value
22
32
  */
23
33
  safeParse(value: unknown): ParseResult<Set<T>>;
24
34
  }
25
- //# sourceMappingURL=set.d.ts.map
@@ -0,0 +1,199 @@
1
+ import { VldBase, VLD_VALIDATOR_TYPES } from './base.js';
2
+ import { getMessages } from '../locales/runtime.js';
3
+ import { V as VldError } from '../chunks/errors-core-BeiFUtZM.js';
4
+
5
+ function createSetError(message) {
6
+ return new VldError([{ code: 'invalid_type', path: [], message }]);
7
+ }
8
+ /**
9
+ * Immutable Set validator
10
+ */
11
+ class VldSet extends VldBase {
12
+ /**
13
+ * Private constructor to enforce immutability
14
+ */
15
+ constructor(itemValidator, errorMessage) {
16
+ super(VLD_VALIDATOR_TYPES.SET);
17
+ this.itemValidator = itemValidator;
18
+ this.errorMessage = errorMessage;
19
+ this._simpleItemMode = this.getSimpleItemMode(itemValidator);
20
+ this._simpleItemValue = this._simpleItemMode === 'literal' ? itemValidator.literal : undefined;
21
+ }
22
+ get itemSchema() {
23
+ return this.itemValidator;
24
+ }
25
+ /**
26
+ * Create a new Set validator
27
+ */
28
+ static create(itemValidator) {
29
+ return new VldSet(itemValidator);
30
+ }
31
+ getSimpleItemMode(itemValidator) {
32
+ if (itemValidator.isSimple !== true) {
33
+ return undefined;
34
+ }
35
+ switch (itemValidator.validatorType) {
36
+ case VLD_VALIDATOR_TYPES.STRING:
37
+ return 'string';
38
+ case VLD_VALIDATOR_TYPES.NUMBER:
39
+ return 'number';
40
+ case VLD_VALIDATOR_TYPES.BOOLEAN:
41
+ return 'boolean';
42
+ case VLD_VALIDATOR_TYPES.BIGINT:
43
+ return 'bigint';
44
+ case VLD_VALIDATOR_TYPES.SYMBOL:
45
+ return 'symbol';
46
+ case VLD_VALIDATOR_TYPES.NULL:
47
+ return 'null';
48
+ case VLD_VALIDATOR_TYPES.UNDEFINED:
49
+ case VLD_VALIDATOR_TYPES.VOID:
50
+ return 'undefinedValue';
51
+ case VLD_VALIDATOR_TYPES.LITERAL:
52
+ return 'literal';
53
+ case VLD_VALIDATOR_TYPES.ANY:
54
+ case VLD_VALIDATOR_TYPES.UNKNOWN:
55
+ return 'passthrough';
56
+ default:
57
+ return undefined;
58
+ }
59
+ }
60
+ getSimpleItemError(received) {
61
+ switch (this._simpleItemMode) {
62
+ case 'string':
63
+ return getMessages().invalidString;
64
+ case 'number':
65
+ return getMessages().invalidNumber;
66
+ case 'boolean':
67
+ return getMessages().invalidBoolean;
68
+ case 'bigint':
69
+ return getMessages().invalidBigint;
70
+ case 'symbol':
71
+ return getMessages().invalidSymbol;
72
+ case 'null':
73
+ return `Expected null, received ${typeof received}`;
74
+ case 'undefinedValue':
75
+ return getMessages().expectedUndefined;
76
+ case 'literal':
77
+ return getMessages().literalExpected(JSON.stringify(this._simpleItemValue), JSON.stringify(received));
78
+ default:
79
+ return getMessages().invalidSet;
80
+ }
81
+ }
82
+ /**
83
+ * Parse and validate a Set value
84
+ */
85
+ parse(value) {
86
+ if (!(value instanceof Set)) {
87
+ throw new Error(this.errorMessage || getMessages().invalidSet);
88
+ }
89
+ return this.parseKnownSet(value);
90
+ }
91
+ /**
92
+ * Parse a value that has already passed the Set instance guard.
93
+ * @internal Used by object validators to avoid duplicate hot-path checks.
94
+ */
95
+ parseKnownSet(value) {
96
+ const result = new Set();
97
+ const simpleMode = this._simpleItemMode;
98
+ if (simpleMode === 'string') {
99
+ for (const item of value) {
100
+ if (typeof item !== 'string') {
101
+ throw new Error(this.getSimpleItemError(item));
102
+ }
103
+ result.add(item);
104
+ }
105
+ return result;
106
+ }
107
+ if (simpleMode === 'number') {
108
+ for (const item of value) {
109
+ if (typeof item !== 'number' || isNaN(item)) {
110
+ throw new Error(this.getSimpleItemError(item));
111
+ }
112
+ result.add(item);
113
+ }
114
+ return result;
115
+ }
116
+ if (simpleMode === 'boolean') {
117
+ for (const item of value) {
118
+ if (typeof item !== 'boolean') {
119
+ throw new Error(this.getSimpleItemError(item));
120
+ }
121
+ result.add(item);
122
+ }
123
+ return result;
124
+ }
125
+ if (simpleMode === 'bigint') {
126
+ for (const item of value) {
127
+ if (typeof item !== 'bigint') {
128
+ throw new Error(this.getSimpleItemError(item));
129
+ }
130
+ result.add(item);
131
+ }
132
+ return result;
133
+ }
134
+ if (simpleMode === 'symbol') {
135
+ for (const item of value) {
136
+ if (typeof item !== 'symbol') {
137
+ throw new Error(this.getSimpleItemError(item));
138
+ }
139
+ result.add(item);
140
+ }
141
+ return result;
142
+ }
143
+ if (simpleMode === 'null') {
144
+ for (const item of value) {
145
+ if (item !== null) {
146
+ throw new Error(this.getSimpleItemError(item));
147
+ }
148
+ result.add(null);
149
+ }
150
+ return result;
151
+ }
152
+ if (simpleMode === 'undefinedValue') {
153
+ for (const item of value) {
154
+ if (item !== undefined) {
155
+ throw new Error(this.getSimpleItemError(item));
156
+ }
157
+ result.add(undefined);
158
+ }
159
+ return result;
160
+ }
161
+ if (simpleMode === 'literal') {
162
+ for (const item of value) {
163
+ if (item !== this._simpleItemValue) {
164
+ throw new Error(this.getSimpleItemError(item));
165
+ }
166
+ result.add(this._simpleItemValue);
167
+ }
168
+ return result;
169
+ }
170
+ if (simpleMode === 'passthrough') {
171
+ for (const item of value) {
172
+ result.add(item);
173
+ }
174
+ return result;
175
+ }
176
+ for (const item of value) {
177
+ try {
178
+ result.add(this.itemValidator.parse(item));
179
+ }
180
+ catch (error) {
181
+ throw new Error(error.message);
182
+ }
183
+ }
184
+ return result;
185
+ }
186
+ /**
187
+ * Safely parse and validate a Set value
188
+ */
189
+ safeParse(value) {
190
+ try {
191
+ return { success: true, data: this.parse(value) };
192
+ }
193
+ catch (error) {
194
+ return { success: false, error: createSetError(error.message) };
195
+ }
196
+ }
197
+ }
198
+
199
+ export { VldSet };