@openclaw/firecrawl-plugin 2026.9.7 → 2026.10.1-beta.1

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 (850) hide show
  1. package/dist/.setup/{firecrawl-client-S2gdb9zo.mjs → firecrawl-client-Bqyr6x90.mjs} +58 -104
  2. package/dist/.setup/{firecrawl-fetch-provider-Cq_h8okw.mjs → firecrawl-fetch-provider-CcYAp_u6.mjs} +1 -1
  3. package/dist/.setup/{firecrawl-search-provider-DzEHIoq7.mjs → firecrawl-search-provider-lAiZ3IJ5.mjs} +1 -1
  4. package/dist/api.js +1 -1
  5. package/dist/index.js +17 -28
  6. package/dist/web-fetch-contract-api.js +1 -1
  7. package/dist/web-fetch-provider.js +1 -1
  8. package/dist/web-search-contract-api.js +1 -1
  9. package/dist/web-search-provider.js +1 -1
  10. package/package.json +6 -8
  11. package/node_modules/zod/LICENSE +0 -21
  12. package/node_modules/zod/README.md +0 -218
  13. package/node_modules/zod/compile.cjs +0 -96
  14. package/node_modules/zod/compile.d.cts +0 -1
  15. package/node_modules/zod/compile.d.ts +0 -1
  16. package/node_modules/zod/compile.js +0 -52
  17. package/node_modules/zod/index.cjs +0 -52
  18. package/node_modules/zod/index.d.cts +0 -3
  19. package/node_modules/zod/index.d.ts +0 -3
  20. package/node_modules/zod/index.js +0 -7
  21. package/node_modules/zod/locales/index.cjs +0 -36
  22. package/node_modules/zod/locales/index.d.cts +0 -1
  23. package/node_modules/zod/locales/index.d.ts +0 -1
  24. package/node_modules/zod/locales/index.js +0 -1
  25. package/node_modules/zod/locales/package.json +0 -7
  26. package/node_modules/zod/mini/index.cjs +0 -51
  27. package/node_modules/zod/mini/index.d.cts +0 -3
  28. package/node_modules/zod/mini/index.d.ts +0 -3
  29. package/node_modules/zod/mini/index.js +0 -3
  30. package/node_modules/zod/mini/package.json +0 -7
  31. package/node_modules/zod/package.json +0 -147
  32. package/node_modules/zod/src/compile.ts +0 -56
  33. package/node_modules/zod/src/index.ts +0 -7
  34. package/node_modules/zod/src/locales/index.ts +0 -1
  35. package/node_modules/zod/src/mini/index.ts +0 -3
  36. package/node_modules/zod/src/v3/ZodError.ts +0 -340
  37. package/node_modules/zod/src/v3/benchmarks/datetime.ts +0 -58
  38. package/node_modules/zod/src/v3/benchmarks/discriminatedUnion.ts +0 -80
  39. package/node_modules/zod/src/v3/benchmarks/index.ts +0 -59
  40. package/node_modules/zod/src/v3/benchmarks/ipv4.ts +0 -57
  41. package/node_modules/zod/src/v3/benchmarks/object.ts +0 -69
  42. package/node_modules/zod/src/v3/benchmarks/primitives.ts +0 -162
  43. package/node_modules/zod/src/v3/benchmarks/realworld.ts +0 -63
  44. package/node_modules/zod/src/v3/benchmarks/string.ts +0 -55
  45. package/node_modules/zod/src/v3/benchmarks/union.ts +0 -80
  46. package/node_modules/zod/src/v3/errors.ts +0 -13
  47. package/node_modules/zod/src/v3/external.ts +0 -6
  48. package/node_modules/zod/src/v3/helpers/enumUtil.ts +0 -17
  49. package/node_modules/zod/src/v3/helpers/errorUtil.ts +0 -8
  50. package/node_modules/zod/src/v3/helpers/parseUtil.ts +0 -176
  51. package/node_modules/zod/src/v3/helpers/partialUtil.ts +0 -34
  52. package/node_modules/zod/src/v3/helpers/typeAliases.ts +0 -2
  53. package/node_modules/zod/src/v3/helpers/util.ts +0 -224
  54. package/node_modules/zod/src/v3/index.ts +0 -4
  55. package/node_modules/zod/src/v3/locales/en.ts +0 -124
  56. package/node_modules/zod/src/v3/standard-schema.ts +0 -113
  57. package/node_modules/zod/src/v3/tests/Mocker.ts +0 -54
  58. package/node_modules/zod/src/v3/tests/all-errors.test.ts +0 -157
  59. package/node_modules/zod/src/v3/tests/anyunknown.test.ts +0 -28
  60. package/node_modules/zod/src/v3/tests/array.test.ts +0 -71
  61. package/node_modules/zod/src/v3/tests/async-parsing.test.ts +0 -388
  62. package/node_modules/zod/src/v3/tests/async-refinements.test.ts +0 -46
  63. package/node_modules/zod/src/v3/tests/base.test.ts +0 -29
  64. package/node_modules/zod/src/v3/tests/bigint.test.ts +0 -55
  65. package/node_modules/zod/src/v3/tests/branded.test.ts +0 -53
  66. package/node_modules/zod/src/v3/tests/catch.test.ts +0 -220
  67. package/node_modules/zod/src/v3/tests/coerce.test.ts +0 -133
  68. package/node_modules/zod/src/v3/tests/complex.test.ts +0 -70
  69. package/node_modules/zod/src/v3/tests/custom.test.ts +0 -31
  70. package/node_modules/zod/src/v3/tests/date.test.ts +0 -32
  71. package/node_modules/zod/src/v3/tests/deepmasking.test.ts +0 -186
  72. package/node_modules/zod/src/v3/tests/default.test.ts +0 -112
  73. package/node_modules/zod/src/v3/tests/description.test.ts +0 -33
  74. package/node_modules/zod/src/v3/tests/discriminated-unions.test.ts +0 -315
  75. package/node_modules/zod/src/v3/tests/enum.test.ts +0 -80
  76. package/node_modules/zod/src/v3/tests/error.test.ts +0 -586
  77. package/node_modules/zod/src/v3/tests/firstparty.test.ts +0 -87
  78. package/node_modules/zod/src/v3/tests/firstpartyschematypes.test.ts +0 -21
  79. package/node_modules/zod/src/v3/tests/function.test.ts +0 -261
  80. package/node_modules/zod/src/v3/tests/generics.test.ts +0 -48
  81. package/node_modules/zod/src/v3/tests/instanceof.test.ts +0 -37
  82. package/node_modules/zod/src/v3/tests/intersection.test.ts +0 -128
  83. package/node_modules/zod/src/v3/tests/language-server.source.ts +0 -76
  84. package/node_modules/zod/src/v3/tests/language-server.test.ts +0 -206
  85. package/node_modules/zod/src/v3/tests/literal.test.ts +0 -36
  86. package/node_modules/zod/src/v3/tests/map.test.ts +0 -110
  87. package/node_modules/zod/src/v3/tests/masking.test.ts +0 -4
  88. package/node_modules/zod/src/v3/tests/mocker.test.ts +0 -19
  89. package/node_modules/zod/src/v3/tests/nan.test.ts +0 -24
  90. package/node_modules/zod/src/v3/tests/nativeEnum.test.ts +0 -87
  91. package/node_modules/zod/src/v3/tests/nullable.test.ts +0 -42
  92. package/node_modules/zod/src/v3/tests/number.test.ts +0 -176
  93. package/node_modules/zod/src/v3/tests/object-augmentation.test.ts +0 -29
  94. package/node_modules/zod/src/v3/tests/object-in-es5-env.test.ts +0 -29
  95. package/node_modules/zod/src/v3/tests/object.test.ts +0 -431
  96. package/node_modules/zod/src/v3/tests/optional.test.ts +0 -42
  97. package/node_modules/zod/src/v3/tests/parseUtil.test.ts +0 -23
  98. package/node_modules/zod/src/v3/tests/parser.test.ts +0 -41
  99. package/node_modules/zod/src/v3/tests/partials.test.ts +0 -243
  100. package/node_modules/zod/src/v3/tests/pickomit.test.ts +0 -111
  101. package/node_modules/zod/src/v3/tests/pipeline.test.ts +0 -29
  102. package/node_modules/zod/src/v3/tests/preprocess.test.ts +0 -186
  103. package/node_modules/zod/src/v3/tests/primitive.test.ts +0 -440
  104. package/node_modules/zod/src/v3/tests/promise.test.ts +0 -90
  105. package/node_modules/zod/src/v3/tests/readonly.test.ts +0 -114
  106. package/node_modules/zod/src/v3/tests/record.test.ts +0 -171
  107. package/node_modules/zod/src/v3/tests/recursive.test.ts +0 -197
  108. package/node_modules/zod/src/v3/tests/refine.test.ts +0 -313
  109. package/node_modules/zod/src/v3/tests/safeparse.test.ts +0 -27
  110. package/node_modules/zod/src/v3/tests/set.test.ts +0 -142
  111. package/node_modules/zod/src/v3/tests/standard-schema.test.ts +0 -83
  112. package/node_modules/zod/src/v3/tests/string.test.ts +0 -922
  113. package/node_modules/zod/src/v3/tests/transformer.test.ts +0 -233
  114. package/node_modules/zod/src/v3/tests/tuple.test.ts +0 -90
  115. package/node_modules/zod/src/v3/tests/unions.test.ts +0 -57
  116. package/node_modules/zod/src/v3/tests/validations.test.ts +0 -133
  117. package/node_modules/zod/src/v3/tests/void.test.ts +0 -15
  118. package/node_modules/zod/src/v3/types.ts +0 -5138
  119. package/node_modules/zod/src/v4/classic/checks.ts +0 -33
  120. package/node_modules/zod/src/v4/classic/coerce.ts +0 -27
  121. package/node_modules/zod/src/v4/classic/compat.ts +0 -78
  122. package/node_modules/zod/src/v4/classic/deep-partial.ts +0 -76
  123. package/node_modules/zod/src/v4/classic/errors.ts +0 -97
  124. package/node_modules/zod/src/v4/classic/external.ts +0 -57
  125. package/node_modules/zod/src/v4/classic/from-json-schema.ts +0 -944
  126. package/node_modules/zod/src/v4/classic/in-out.ts +0 -45
  127. package/node_modules/zod/src/v4/classic/index.ts +0 -5
  128. package/node_modules/zod/src/v4/classic/iso.ts +0 -20
  129. package/node_modules/zod/src/v4/classic/parse.ts +0 -88
  130. package/node_modules/zod/src/v4/classic/schemas.ts +0 -2937
  131. package/node_modules/zod/src/v4/classic/tests/anyunknown.test.ts +0 -26
  132. package/node_modules/zod/src/v4/classic/tests/apply.test.ts +0 -86
  133. package/node_modules/zod/src/v4/classic/tests/array.test.ts +0 -264
  134. package/node_modules/zod/src/v4/classic/tests/assignability.test.ts +0 -402
  135. package/node_modules/zod/src/v4/classic/tests/async-parsing.test.ts +0 -381
  136. package/node_modules/zod/src/v4/classic/tests/async-refinements.test.ts +0 -68
  137. package/node_modules/zod/src/v4/classic/tests/base.test.ts +0 -7
  138. package/node_modules/zod/src/v4/classic/tests/bigint.test.ts +0 -89
  139. package/node_modules/zod/src/v4/classic/tests/brand.test.ts +0 -106
  140. package/node_modules/zod/src/v4/classic/tests/catch.test.ts +0 -604
  141. package/node_modules/zod/src/v4/classic/tests/coalesce.test.ts +0 -20
  142. package/node_modules/zod/src/v4/classic/tests/codec-examples.test.ts +0 -572
  143. package/node_modules/zod/src/v4/classic/tests/codec.test.ts +0 -704
  144. package/node_modules/zod/src/v4/classic/tests/coerce.test.ts +0 -160
  145. package/node_modules/zod/src/v4/classic/tests/continuability.test.ts +0 -374
  146. package/node_modules/zod/src/v4/classic/tests/credit-card.test.ts +0 -76
  147. package/node_modules/zod/src/v4/classic/tests/custom.test.ts +0 -40
  148. package/node_modules/zod/src/v4/classic/tests/cyclic-data.test.ts +0 -985
  149. package/node_modules/zod/src/v4/classic/tests/date.test.ts +0 -92
  150. package/node_modules/zod/src/v4/classic/tests/datetime.test.ts +0 -316
  151. package/node_modules/zod/src/v4/classic/tests/deep-partial.test.ts +0 -380
  152. package/node_modules/zod/src/v4/classic/tests/default-locale.test.ts +0 -32
  153. package/node_modules/zod/src/v4/classic/tests/default.test.ts +0 -455
  154. package/node_modules/zod/src/v4/classic/tests/describe-meta-checks.test.ts +0 -27
  155. package/node_modules/zod/src/v4/classic/tests/description.test.ts +0 -32
  156. package/node_modules/zod/src/v4/classic/tests/detached-methods.test.ts +0 -221
  157. package/node_modules/zod/src/v4/classic/tests/discriminated-unions.test.ts +0 -942
  158. package/node_modules/zod/src/v4/classic/tests/enum.test.ts +0 -305
  159. package/node_modules/zod/src/v4/classic/tests/error-utils.test.ts +0 -917
  160. package/node_modules/zod/src/v4/classic/tests/error.test.ts +0 -1108
  161. package/node_modules/zod/src/v4/classic/tests/file.test.ts +0 -96
  162. package/node_modules/zod/src/v4/classic/tests/firstparty.test.ts +0 -179
  163. package/node_modules/zod/src/v4/classic/tests/fix-json-issue.test.ts +0 -26
  164. package/node_modules/zod/src/v4/classic/tests/from-json-schema.test.ts +0 -1467
  165. package/node_modules/zod/src/v4/classic/tests/function.test.ts +0 -391
  166. package/node_modules/zod/src/v4/classic/tests/generics.test.ts +0 -72
  167. package/node_modules/zod/src/v4/classic/tests/global-config.test.ts +0 -32
  168. package/node_modules/zod/src/v4/classic/tests/hash.test.ts +0 -67
  169. package/node_modules/zod/src/v4/classic/tests/iban.test.ts +0 -81
  170. package/node_modules/zod/src/v4/classic/tests/in-out.test.ts +0 -159
  171. package/node_modules/zod/src/v4/classic/tests/index.test.ts +0 -958
  172. package/node_modules/zod/src/v4/classic/tests/instance-footprint.test.ts +0 -319
  173. package/node_modules/zod/src/v4/classic/tests/instanceof.test.ts +0 -127
  174. package/node_modules/zod/src/v4/classic/tests/intersection.test.ts +0 -334
  175. package/node_modules/zod/src/v4/classic/tests/issue-schema.test.ts +0 -215
  176. package/node_modules/zod/src/v4/classic/tests/jitless-allows-eval.test.ts +0 -39
  177. package/node_modules/zod/src/v4/classic/tests/json.test.ts +0 -109
  178. package/node_modules/zod/src/v4/classic/tests/lazy.test.ts +0 -262
  179. package/node_modules/zod/src/v4/classic/tests/literal.test.ts +0 -128
  180. package/node_modules/zod/src/v4/classic/tests/locales_ka.test.ts +0 -29
  181. package/node_modules/zod/src/v4/classic/tests/locales_ro.test.ts +0 -24
  182. package/node_modules/zod/src/v4/classic/tests/map.test.ts +0 -342
  183. package/node_modules/zod/src/v4/classic/tests/nan.test.ts +0 -21
  184. package/node_modules/zod/src/v4/classic/tests/nested-refine.test.ts +0 -168
  185. package/node_modules/zod/src/v4/classic/tests/nonoptional.test.ts +0 -101
  186. package/node_modules/zod/src/v4/classic/tests/nullable.test.ts +0 -22
  187. package/node_modules/zod/src/v4/classic/tests/number.test.ts +0 -401
  188. package/node_modules/zod/src/v4/classic/tests/object.test.ts +0 -1006
  189. package/node_modules/zod/src/v4/classic/tests/optin-ladder.test.ts +0 -235
  190. package/node_modules/zod/src/v4/classic/tests/optional.test.ts +0 -366
  191. package/node_modules/zod/src/v4/classic/tests/partial.test.ts +0 -497
  192. package/node_modules/zod/src/v4/classic/tests/pickomit.test.ts +0 -211
  193. package/node_modules/zod/src/v4/classic/tests/pipe.test.ts +0 -101
  194. package/node_modules/zod/src/v4/classic/tests/prefault.test.ts +0 -144
  195. package/node_modules/zod/src/v4/classic/tests/preprocess-types.test.ts +0 -44
  196. package/node_modules/zod/src/v4/classic/tests/preprocess.test.ts +0 -351
  197. package/node_modules/zod/src/v4/classic/tests/primitive.test.ts +0 -175
  198. package/node_modules/zod/src/v4/classic/tests/promise.test.ts +0 -81
  199. package/node_modules/zod/src/v4/classic/tests/properties.test.ts +0 -141
  200. package/node_modules/zod/src/v4/classic/tests/prototypes.test.ts +0 -23
  201. package/node_modules/zod/src/v4/classic/tests/readonly.test.ts +0 -184
  202. package/node_modules/zod/src/v4/classic/tests/record.test.ts +0 -885
  203. package/node_modules/zod/src/v4/classic/tests/recursive-types.test.ts +0 -707
  204. package/node_modules/zod/src/v4/classic/tests/redos.test.ts +0 -68
  205. package/node_modules/zod/src/v4/classic/tests/refine.test.ts +0 -693
  206. package/node_modules/zod/src/v4/classic/tests/registries.test.ts +0 -243
  207. package/node_modules/zod/src/v4/classic/tests/set.test.ts +0 -190
  208. package/node_modules/zod/src/v4/classic/tests/standard-schema.test.ts +0 -153
  209. package/node_modules/zod/src/v4/classic/tests/string-formats.test.ts +0 -125
  210. package/node_modules/zod/src/v4/classic/tests/string.test.ts +0 -1440
  211. package/node_modules/zod/src/v4/classic/tests/stringbool.test.ts +0 -124
  212. package/node_modules/zod/src/v4/classic/tests/template-literal.test.ts +0 -812
  213. package/node_modules/zod/src/v4/classic/tests/to-json-schema-methods.test.ts +0 -438
  214. package/node_modules/zod/src/v4/classic/tests/to-json-schema.test.ts +0 -4733
  215. package/node_modules/zod/src/v4/classic/tests/transform.test.ts +0 -378
  216. package/node_modules/zod/src/v4/classic/tests/tuple.test.ts +0 -511
  217. package/node_modules/zod/src/v4/classic/tests/union.test.ts +0 -310
  218. package/node_modules/zod/src/v4/classic/tests/url.test.ts +0 -13
  219. package/node_modules/zod/src/v4/classic/tests/validate.test.ts +0 -645
  220. package/node_modules/zod/src/v4/classic/tests/validations.test.ts +0 -283
  221. package/node_modules/zod/src/v4/classic/tests/void.test.ts +0 -12
  222. package/node_modules/zod/src/v4/core/api.ts +0 -1875
  223. package/node_modules/zod/src/v4/core/checks.ts +0 -1266
  224. package/node_modules/zod/src/v4/core/compile.ts +0 -2313
  225. package/node_modules/zod/src/v4/core/core.ts +0 -230
  226. package/node_modules/zod/src/v4/core/doc.ts +0 -52
  227. package/node_modules/zod/src/v4/core/errors.ts +0 -543
  228. package/node_modules/zod/src/v4/core/index.ts +0 -19
  229. package/node_modules/zod/src/v4/core/json-schema-generator.ts +0 -131
  230. package/node_modules/zod/src/v4/core/json-schema-processors.ts +0 -934
  231. package/node_modules/zod/src/v4/core/json-schema.ts +0 -148
  232. package/node_modules/zod/src/v4/core/memoizer.ts +0 -331
  233. package/node_modules/zod/src/v4/core/parse.ts +0 -309
  234. package/node_modules/zod/src/v4/core/regexes.ts +0 -217
  235. package/node_modules/zod/src/v4/core/registries.ts +0 -105
  236. package/node_modules/zod/src/v4/core/schemas.ts +0 -5192
  237. package/node_modules/zod/src/v4/core/standard-schema.ts +0 -159
  238. package/node_modules/zod/src/v4/core/tests/cached.test.ts +0 -54
  239. package/node_modules/zod/src/v4/core/tests/compile-differential.test.ts +0 -1004
  240. package/node_modules/zod/src/v4/core/tests/compile-generative.test.ts +0 -445
  241. package/node_modules/zod/src/v4/core/tests/compile-global.test.ts +0 -89
  242. package/node_modules/zod/src/v4/core/tests/compile-off-by-default.test.ts +0 -26
  243. package/node_modules/zod/src/v4/core/tests/compile-stats.test.ts +0 -34
  244. package/node_modules/zod/src/v4/core/tests/compile.test.ts +0 -2036
  245. package/node_modules/zod/src/v4/core/tests/email-regex.test.ts +0 -140
  246. package/node_modules/zod/src/v4/core/tests/extend.test.ts +0 -59
  247. package/node_modules/zod/src/v4/core/tests/index.test.ts +0 -46
  248. package/node_modules/zod/src/v4/core/tests/locales/be.test.ts +0 -124
  249. package/node_modules/zod/src/v4/core/tests/locales/el.test.ts +0 -214
  250. package/node_modules/zod/src/v4/core/tests/locales/en.test.ts +0 -22
  251. package/node_modules/zod/src/v4/core/tests/locales/es.test.ts +0 -180
  252. package/node_modules/zod/src/v4/core/tests/locales/fr.test.ts +0 -72
  253. package/node_modules/zod/src/v4/core/tests/locales/he.test.ts +0 -379
  254. package/node_modules/zod/src/v4/core/tests/locales/hr.test.ts +0 -163
  255. package/node_modules/zod/src/v4/core/tests/locales/nl.test.ts +0 -46
  256. package/node_modules/zod/src/v4/core/tests/locales/parity.test.ts +0 -42
  257. package/node_modules/zod/src/v4/core/tests/locales/ru.test.ts +0 -128
  258. package/node_modules/zod/src/v4/core/tests/locales/tg.test.ts +0 -85
  259. package/node_modules/zod/src/v4/core/tests/locales/tk.test.ts +0 -69
  260. package/node_modules/zod/src/v4/core/tests/locales/tr.test.ts +0 -69
  261. package/node_modules/zod/src/v4/core/tests/locales/uz.test.ts +0 -105
  262. package/node_modules/zod/src/v4/core/tests/polyfill-collision.test.ts +0 -46
  263. package/node_modules/zod/src/v4/core/tests/record-constructor.test.ts +0 -125
  264. package/node_modules/zod/src/v4/core/tests/recursive-tuples.test.ts +0 -45
  265. package/node_modules/zod/src/v4/core/tests/treeshake.test.ts +0 -51
  266. package/node_modules/zod/src/v4/core/tests/url-no-canparse.test.ts +0 -133
  267. package/node_modules/zod/src/v4/core/to-json-schema.ts +0 -857
  268. package/node_modules/zod/src/v4/core/util.ts +0 -1280
  269. package/node_modules/zod/src/v4/core/versions.ts +0 -5
  270. package/node_modules/zod/src/v4/core/visit.ts +0 -193
  271. package/node_modules/zod/src/v4/core/zsf.ts +0 -323
  272. package/node_modules/zod/src/v4/index.ts +0 -4
  273. package/node_modules/zod/src/v4/locales/ar.ts +0 -120
  274. package/node_modules/zod/src/v4/locales/az.ts +0 -116
  275. package/node_modules/zod/src/v4/locales/be.ts +0 -188
  276. package/node_modules/zod/src/v4/locales/bg.ts +0 -133
  277. package/node_modules/zod/src/v4/locales/bn.ts +0 -123
  278. package/node_modules/zod/src/v4/locales/ca.ts +0 -121
  279. package/node_modules/zod/src/v4/locales/ckb.ts +0 -140
  280. package/node_modules/zod/src/v4/locales/cs.ts +0 -123
  281. package/node_modules/zod/src/v4/locales/da.ts +0 -128
  282. package/node_modules/zod/src/v4/locales/de.ts +0 -121
  283. package/node_modules/zod/src/v4/locales/el.ts +0 -124
  284. package/node_modules/zod/src/v4/locales/en.ts +0 -136
  285. package/node_modules/zod/src/v4/locales/eo.ts +0 -123
  286. package/node_modules/zod/src/v4/locales/es.ts +0 -145
  287. package/node_modules/zod/src/v4/locales/fa.ts +0 -131
  288. package/node_modules/zod/src/v4/locales/fi.ts +0 -126
  289. package/node_modules/zod/src/v4/locales/fr-CA.ts +0 -121
  290. package/node_modules/zod/src/v4/locales/fr.ts +0 -139
  291. package/node_modules/zod/src/v4/locales/gu.ts +0 -123
  292. package/node_modules/zod/src/v4/locales/he.ts +0 -253
  293. package/node_modules/zod/src/v4/locales/hi.ts +0 -126
  294. package/node_modules/zod/src/v4/locales/hr.ts +0 -135
  295. package/node_modules/zod/src/v4/locales/hu.ts +0 -122
  296. package/node_modules/zod/src/v4/locales/hy.ts +0 -175
  297. package/node_modules/zod/src/v4/locales/id.ts +0 -120
  298. package/node_modules/zod/src/v4/locales/index.ts +0 -63
  299. package/node_modules/zod/src/v4/locales/is.ts +0 -124
  300. package/node_modules/zod/src/v4/locales/it.ts +0 -121
  301. package/node_modules/zod/src/v4/locales/ja.ts +0 -119
  302. package/node_modules/zod/src/v4/locales/ka.ts +0 -128
  303. package/node_modules/zod/src/v4/locales/kh.ts +0 -7
  304. package/node_modules/zod/src/v4/locales/km.ts +0 -124
  305. package/node_modules/zod/src/v4/locales/kn.ts +0 -126
  306. package/node_modules/zod/src/v4/locales/ko.ts +0 -126
  307. package/node_modules/zod/src/v4/locales/lt.ts +0 -243
  308. package/node_modules/zod/src/v4/locales/mk.ts +0 -123
  309. package/node_modules/zod/src/v4/locales/ms.ts +0 -120
  310. package/node_modules/zod/src/v4/locales/ne.ts +0 -128
  311. package/node_modules/zod/src/v4/locales/nl.ts +0 -126
  312. package/node_modules/zod/src/v4/locales/nn.ts +0 -121
  313. package/node_modules/zod/src/v4/locales/no.ts +0 -121
  314. package/node_modules/zod/src/v4/locales/ota.ts +0 -122
  315. package/node_modules/zod/src/v4/locales/pl.ts +0 -123
  316. package/node_modules/zod/src/v4/locales/ps.ts +0 -131
  317. package/node_modules/zod/src/v4/locales/pt-BR.ts +0 -161
  318. package/node_modules/zod/src/v4/locales/pt.ts +0 -159
  319. package/node_modules/zod/src/v4/locales/ro.ts +0 -132
  320. package/node_modules/zod/src/v4/locales/ru.ts +0 -188
  321. package/node_modules/zod/src/v4/locales/sk.ts +0 -123
  322. package/node_modules/zod/src/v4/locales/sl.ts +0 -123
  323. package/node_modules/zod/src/v4/locales/sv.ts +0 -124
  324. package/node_modules/zod/src/v4/locales/ta.ts +0 -123
  325. package/node_modules/zod/src/v4/locales/tg.ts +0 -135
  326. package/node_modules/zod/src/v4/locales/th.ts +0 -124
  327. package/node_modules/zod/src/v4/locales/tk.ts +0 -113
  328. package/node_modules/zod/src/v4/locales/tr.ts +0 -116
  329. package/node_modules/zod/src/v4/locales/ua.ts +0 -7
  330. package/node_modules/zod/src/v4/locales/uk.ts +0 -122
  331. package/node_modules/zod/src/v4/locales/ur.ts +0 -124
  332. package/node_modules/zod/src/v4/locales/uz.ts +0 -120
  333. package/node_modules/zod/src/v4/locales/vi.ts +0 -122
  334. package/node_modules/zod/src/v4/locales/yo.ts +0 -129
  335. package/node_modules/zod/src/v4/locales/zh-CN.ts +0 -121
  336. package/node_modules/zod/src/v4/locales/zh-TW.ts +0 -120
  337. package/node_modules/zod/src/v4/mini/checks.ts +0 -33
  338. package/node_modules/zod/src/v4/mini/coerce.ts +0 -27
  339. package/node_modules/zod/src/v4/mini/deep-partial.ts +0 -73
  340. package/node_modules/zod/src/v4/mini/external.ts +0 -52
  341. package/node_modules/zod/src/v4/mini/in-out.ts +0 -45
  342. package/node_modules/zod/src/v4/mini/index.ts +0 -3
  343. package/node_modules/zod/src/v4/mini/iso.ts +0 -66
  344. package/node_modules/zod/src/v4/mini/parse.ts +0 -16
  345. package/node_modules/zod/src/v4/mini/schemas.ts +0 -2051
  346. package/node_modules/zod/src/v4/mini/tests/apply.test.ts +0 -57
  347. package/node_modules/zod/src/v4/mini/tests/assignability.test.ts +0 -190
  348. package/node_modules/zod/src/v4/mini/tests/brand.test.ts +0 -94
  349. package/node_modules/zod/src/v4/mini/tests/checks.test.ts +0 -158
  350. package/node_modules/zod/src/v4/mini/tests/codec.test.ts +0 -582
  351. package/node_modules/zod/src/v4/mini/tests/computed.test.ts +0 -30
  352. package/node_modules/zod/src/v4/mini/tests/cyclic-data.test.ts +0 -84
  353. package/node_modules/zod/src/v4/mini/tests/deep-partial.test.ts +0 -54
  354. package/node_modules/zod/src/v4/mini/tests/error.test.ts +0 -41
  355. package/node_modules/zod/src/v4/mini/tests/functions.test.ts +0 -14
  356. package/node_modules/zod/src/v4/mini/tests/index.test.ts +0 -1146
  357. package/node_modules/zod/src/v4/mini/tests/number.test.ts +0 -109
  358. package/node_modules/zod/src/v4/mini/tests/object.test.ts +0 -292
  359. package/node_modules/zod/src/v4/mini/tests/prototypes.test.ts +0 -43
  360. package/node_modules/zod/src/v4/mini/tests/recursive-types.test.ts +0 -341
  361. package/node_modules/zod/src/v4/mini/tests/standard-schema.test.ts +0 -50
  362. package/node_modules/zod/src/v4/mini/tests/string.test.ts +0 -396
  363. package/node_modules/zod/src/v4-mini/index.ts +0 -3
  364. package/node_modules/zod/v3/ZodError.cjs +0 -167
  365. package/node_modules/zod/v3/ZodError.d.cts +0 -164
  366. package/node_modules/zod/v3/ZodError.d.ts +0 -164
  367. package/node_modules/zod/v3/ZodError.js +0 -143
  368. package/node_modules/zod/v3/errors.cjs +0 -36
  369. package/node_modules/zod/v3/errors.d.cts +0 -5
  370. package/node_modules/zod/v3/errors.d.ts +0 -5
  371. package/node_modules/zod/v3/errors.js +0 -9
  372. package/node_modules/zod/v3/external.cjs +0 -41
  373. package/node_modules/zod/v3/external.d.cts +0 -6
  374. package/node_modules/zod/v3/external.d.ts +0 -6
  375. package/node_modules/zod/v3/external.js +0 -6
  376. package/node_modules/zod/v3/helpers/enumUtil.cjs +0 -21
  377. package/node_modules/zod/v3/helpers/enumUtil.d.cts +0 -8
  378. package/node_modules/zod/v3/helpers/enumUtil.d.ts +0 -8
  379. package/node_modules/zod/v3/helpers/enumUtil.js +0 -1
  380. package/node_modules/zod/v3/helpers/errorUtil.cjs +0 -28
  381. package/node_modules/zod/v3/helpers/errorUtil.d.cts +0 -9
  382. package/node_modules/zod/v3/helpers/errorUtil.d.ts +0 -9
  383. package/node_modules/zod/v3/helpers/errorUtil.js +0 -6
  384. package/node_modules/zod/v3/helpers/parseUtil.cjs +0 -143
  385. package/node_modules/zod/v3/helpers/parseUtil.d.cts +0 -78
  386. package/node_modules/zod/v3/helpers/parseUtil.d.ts +0 -78
  387. package/node_modules/zod/v3/helpers/parseUtil.js +0 -109
  388. package/node_modules/zod/v3/helpers/partialUtil.cjs +0 -21
  389. package/node_modules/zod/v3/helpers/partialUtil.d.cts +0 -8
  390. package/node_modules/zod/v3/helpers/partialUtil.d.ts +0 -8
  391. package/node_modules/zod/v3/helpers/partialUtil.js +0 -1
  392. package/node_modules/zod/v3/helpers/typeAliases.cjs +0 -21
  393. package/node_modules/zod/v3/helpers/typeAliases.d.cts +0 -2
  394. package/node_modules/zod/v3/helpers/typeAliases.d.ts +0 -2
  395. package/node_modules/zod/v3/helpers/typeAliases.js +0 -1
  396. package/node_modules/zod/v3/helpers/util.cjs +0 -156
  397. package/node_modules/zod/v3/helpers/util.d.cts +0 -85
  398. package/node_modules/zod/v3/helpers/util.d.ts +0 -85
  399. package/node_modules/zod/v3/helpers/util.js +0 -133
  400. package/node_modules/zod/v3/index.cjs +0 -52
  401. package/node_modules/zod/v3/index.d.cts +0 -4
  402. package/node_modules/zod/v3/index.d.ts +0 -4
  403. package/node_modules/zod/v3/index.js +0 -4
  404. package/node_modules/zod/v3/locales/en.cjs +0 -112
  405. package/node_modules/zod/v3/locales/en.d.cts +0 -3
  406. package/node_modules/zod/v3/locales/en.d.ts +0 -3
  407. package/node_modules/zod/v3/locales/en.js +0 -109
  408. package/node_modules/zod/v3/package.json +0 -7
  409. package/node_modules/zod/v3/standard-schema.cjs +0 -21
  410. package/node_modules/zod/v3/standard-schema.d.cts +0 -102
  411. package/node_modules/zod/v3/standard-schema.d.ts +0 -102
  412. package/node_modules/zod/v3/standard-schema.js +0 -1
  413. package/node_modules/zod/v3/types.cjs +0 -3798
  414. package/node_modules/zod/v3/types.d.cts +0 -1034
  415. package/node_modules/zod/v3/types.d.ts +0 -1034
  416. package/node_modules/zod/v3/types.js +0 -3697
  417. package/node_modules/zod/v4/classic/checks.cjs +0 -53
  418. package/node_modules/zod/v4/classic/checks.d.cts +0 -1
  419. package/node_modules/zod/v4/classic/checks.d.ts +0 -1
  420. package/node_modules/zod/v4/classic/checks.js +0 -1
  421. package/node_modules/zod/v4/classic/coerce.cjs +0 -66
  422. package/node_modules/zod/v4/classic/coerce.d.cts +0 -17
  423. package/node_modules/zod/v4/classic/coerce.d.ts +0 -17
  424. package/node_modules/zod/v4/classic/coerce.js +0 -17
  425. package/node_modules/zod/v4/classic/compat.cjs +0 -80
  426. package/node_modules/zod/v4/classic/compat.d.cts +0 -48
  427. package/node_modules/zod/v4/classic/compat.d.ts +0 -48
  428. package/node_modules/zod/v4/classic/compat.js +0 -31
  429. package/node_modules/zod/v4/classic/deep-partial.cjs +0 -58
  430. package/node_modules/zod/v4/classic/deep-partial.d.cts +0 -14
  431. package/node_modules/zod/v4/classic/deep-partial.d.ts +0 -14
  432. package/node_modules/zod/v4/classic/deep-partial.js +0 -13
  433. package/node_modules/zod/v4/classic/errors.cjs +0 -102
  434. package/node_modules/zod/v4/classic/errors.d.cts +0 -29
  435. package/node_modules/zod/v4/classic/errors.d.ts +0 -29
  436. package/node_modules/zod/v4/classic/errors.js +0 -57
  437. package/node_modules/zod/v4/classic/external.cjs +0 -97
  438. package/node_modules/zod/v4/classic/external.d.cts +0 -19
  439. package/node_modules/zod/v4/classic/external.d.ts +0 -19
  440. package/node_modules/zod/v4/classic/external.js +0 -17
  441. package/node_modules/zod/v4/classic/from-json-schema.cjs +0 -926
  442. package/node_modules/zod/v4/classic/from-json-schema.d.cts +0 -12
  443. package/node_modules/zod/v4/classic/from-json-schema.d.ts +0 -12
  444. package/node_modules/zod/v4/classic/from-json-schema.js +0 -881
  445. package/node_modules/zod/v4/classic/in-out.cjs +0 -82
  446. package/node_modules/zod/v4/classic/in-out.d.cts +0 -8
  447. package/node_modules/zod/v4/classic/in-out.d.ts +0 -8
  448. package/node_modules/zod/v4/classic/in-out.js +0 -36
  449. package/node_modules/zod/v4/classic/index.cjs +0 -52
  450. package/node_modules/zod/v4/classic/index.d.cts +0 -3
  451. package/node_modules/zod/v4/classic/index.d.ts +0 -3
  452. package/node_modules/zod/v4/classic/index.js +0 -4
  453. package/node_modules/zod/v4/classic/iso.cjs +0 -68
  454. package/node_modules/zod/v4/classic/iso.d.cts +0 -7
  455. package/node_modules/zod/v4/classic/iso.d.ts +0 -7
  456. package/node_modules/zod/v4/classic/iso.js +0 -15
  457. package/node_modules/zod/v4/classic/package.json +0 -7
  458. package/node_modules/zod/v4/classic/parse.cjs +0 -63
  459. package/node_modules/zod/v4/classic/parse.d.cts +0 -44
  460. package/node_modules/zod/v4/classic/parse.d.ts +0 -44
  461. package/node_modules/zod/v4/classic/parse.js +0 -16
  462. package/node_modules/zod/v4/classic/schemas.cjs +0 -1676
  463. package/node_modules/zod/v4/classic/schemas.d.cts +0 -816
  464. package/node_modules/zod/v4/classic/schemas.d.ts +0 -816
  465. package/node_modules/zod/v4/classic/schemas.js +0 -1535
  466. package/node_modules/zod/v4/core/api.cjs +0 -1269
  467. package/node_modules/zod/v4/core/api.d.cts +0 -335
  468. package/node_modules/zod/v4/core/api.d.ts +0 -335
  469. package/node_modules/zod/v4/core/api.js +0 -1107
  470. package/node_modules/zod/v4/core/checks.cjs +0 -561
  471. package/node_modules/zod/v4/core/checks.d.cts +0 -294
  472. package/node_modules/zod/v4/core/checks.d.ts +0 -294
  473. package/node_modules/zod/v4/core/checks.js +0 -516
  474. package/node_modules/zod/v4/core/compile.cjs +0 -1908
  475. package/node_modules/zod/v4/core/compile.d.cts +0 -65
  476. package/node_modules/zod/v4/core/compile.d.ts +0 -65
  477. package/node_modules/zod/v4/core/compile.js +0 -1858
  478. package/node_modules/zod/v4/core/core.cjs +0 -167
  479. package/node_modules/zod/v4/core/core.d.cts +0 -82
  480. package/node_modules/zod/v4/core/core.d.ts +0 -82
  481. package/node_modules/zod/v4/core/core.js +0 -141
  482. package/node_modules/zod/v4/core/doc.cjs +0 -61
  483. package/node_modules/zod/v4/core/doc.d.cts +0 -16
  484. package/node_modules/zod/v4/core/doc.d.ts +0 -16
  485. package/node_modules/zod/v4/core/doc.js +0 -38
  486. package/node_modules/zod/v4/core/errors.cjs +0 -317
  487. package/node_modules/zod/v4/core/errors.d.cts +0 -225
  488. package/node_modules/zod/v4/core/errors.d.ts +0 -225
  489. package/node_modules/zod/v4/core/errors.js +0 -267
  490. package/node_modules/zod/v4/core/index.cjs +0 -70
  491. package/node_modules/zod/v4/core/index.d.cts +0 -19
  492. package/node_modules/zod/v4/core/index.d.ts +0 -19
  493. package/node_modules/zod/v4/core/index.js +0 -19
  494. package/node_modules/zod/v4/core/json-schema-generator.cjs +0 -122
  495. package/node_modules/zod/v4/core/json-schema-generator.d.cts +0 -65
  496. package/node_modules/zod/v4/core/json-schema-generator.d.ts +0 -65
  497. package/node_modules/zod/v4/core/json-schema-generator.js +0 -99
  498. package/node_modules/zod/v4/core/json-schema-processors.cjs +0 -929
  499. package/node_modules/zod/v4/core/json-schema-processors.d.cts +0 -65
  500. package/node_modules/zod/v4/core/json-schema-processors.d.ts +0 -65
  501. package/node_modules/zod/v4/core/json-schema-processors.js +0 -843
  502. package/node_modules/zod/v4/core/json-schema.cjs +0 -21
  503. package/node_modules/zod/v4/core/json-schema.d.cts +0 -89
  504. package/node_modules/zod/v4/core/json-schema.d.ts +0 -89
  505. package/node_modules/zod/v4/core/json-schema.js +0 -1
  506. package/node_modules/zod/v4/core/memoizer.cjs +0 -360
  507. package/node_modules/zod/v4/core/memoizer.d.cts +0 -15
  508. package/node_modules/zod/v4/core/memoizer.d.ts +0 -15
  509. package/node_modules/zod/v4/core/memoizer.js +0 -311
  510. package/node_modules/zod/v4/core/package.json +0 -7
  511. package/node_modules/zod/v4/core/parse.cjs +0 -233
  512. package/node_modules/zod/v4/core/parse.d.cts +0 -52
  513. package/node_modules/zod/v4/core/parse.d.ts +0 -52
  514. package/node_modules/zod/v4/core/parse.js +0 -175
  515. package/node_modules/zod/v4/core/regexes.cjs +0 -209
  516. package/node_modules/zod/v4/core/regexes.d.cts +0 -90
  517. package/node_modules/zod/v4/core/regexes.d.ts +0 -90
  518. package/node_modules/zod/v4/core/regexes.js +0 -156
  519. package/node_modules/zod/v4/core/registries.cjs +0 -75
  520. package/node_modules/zod/v4/core/registries.d.cts +0 -35
  521. package/node_modules/zod/v4/core/registries.d.ts +0 -35
  522. package/node_modules/zod/v4/core/registries.js +0 -51
  523. package/node_modules/zod/v4/core/schemas.cjs +0 -2669
  524. package/node_modules/zod/v4/core/schemas.d.cts +0 -1273
  525. package/node_modules/zod/v4/core/schemas.d.ts +0 -1273
  526. package/node_modules/zod/v4/core/schemas.js +0 -2606
  527. package/node_modules/zod/v4/core/standard-schema.cjs +0 -21
  528. package/node_modules/zod/v4/core/standard-schema.d.cts +0 -126
  529. package/node_modules/zod/v4/core/standard-schema.d.ts +0 -126
  530. package/node_modules/zod/v4/core/standard-schema.js +0 -1
  531. package/node_modules/zod/v4/core/to-json-schema.cjs +0 -681
  532. package/node_modules/zod/v4/core/to-json-schema.d.cts +0 -154
  533. package/node_modules/zod/v4/core/to-json-schema.d.ts +0 -154
  534. package/node_modules/zod/v4/core/to-json-schema.js +0 -651
  535. package/node_modules/zod/v4/core/util.cjs +0 -949
  536. package/node_modules/zod/v4/core/util.d.cts +0 -278
  537. package/node_modules/zod/v4/core/util.d.ts +0 -278
  538. package/node_modules/zod/v4/core/util.js +0 -859
  539. package/node_modules/zod/v4/core/versions.cjs +0 -27
  540. package/node_modules/zod/v4/core/versions.d.cts +0 -5
  541. package/node_modules/zod/v4/core/versions.d.ts +0 -5
  542. package/node_modules/zod/v4/core/versions.js +0 -5
  543. package/node_modules/zod/v4/core/visit.cjs +0 -214
  544. package/node_modules/zod/v4/core/visit.d.cts +0 -30
  545. package/node_modules/zod/v4/core/visit.d.ts +0 -30
  546. package/node_modules/zod/v4/core/visit.js +0 -169
  547. package/node_modules/zod/v4/index.cjs +0 -51
  548. package/node_modules/zod/v4/index.d.cts +0 -3
  549. package/node_modules/zod/v4/index.d.ts +0 -3
  550. package/node_modules/zod/v4/index.js +0 -4
  551. package/node_modules/zod/v4/locales/ar.cjs +0 -138
  552. package/node_modules/zod/v4/locales/ar.d.cts +0 -5
  553. package/node_modules/zod/v4/locales/ar.d.ts +0 -4
  554. package/node_modules/zod/v4/locales/ar.js +0 -111
  555. package/node_modules/zod/v4/locales/az.cjs +0 -137
  556. package/node_modules/zod/v4/locales/az.d.cts +0 -5
  557. package/node_modules/zod/v4/locales/az.d.ts +0 -4
  558. package/node_modules/zod/v4/locales/az.js +0 -110
  559. package/node_modules/zod/v4/locales/be.cjs +0 -195
  560. package/node_modules/zod/v4/locales/be.d.cts +0 -5
  561. package/node_modules/zod/v4/locales/be.d.ts +0 -4
  562. package/node_modules/zod/v4/locales/be.js +0 -168
  563. package/node_modules/zod/v4/locales/bg.cjs +0 -152
  564. package/node_modules/zod/v4/locales/bg.d.cts +0 -5
  565. package/node_modules/zod/v4/locales/bg.d.ts +0 -4
  566. package/node_modules/zod/v4/locales/bg.js +0 -125
  567. package/node_modules/zod/v4/locales/bn.cjs +0 -140
  568. package/node_modules/zod/v4/locales/bn.d.cts +0 -5
  569. package/node_modules/zod/v4/locales/bn.d.ts +0 -4
  570. package/node_modules/zod/v4/locales/bn.js +0 -113
  571. package/node_modules/zod/v4/locales/ca.cjs +0 -139
  572. package/node_modules/zod/v4/locales/ca.d.cts +0 -5
  573. package/node_modules/zod/v4/locales/ca.d.ts +0 -4
  574. package/node_modules/zod/v4/locales/ca.js +0 -112
  575. package/node_modules/zod/v4/locales/ckb.cjs +0 -160
  576. package/node_modules/zod/v4/locales/ckb.d.cts +0 -5
  577. package/node_modules/zod/v4/locales/ckb.d.ts +0 -4
  578. package/node_modules/zod/v4/locales/ckb.js +0 -133
  579. package/node_modules/zod/v4/locales/cs.cjs +0 -143
  580. package/node_modules/zod/v4/locales/cs.d.cts +0 -5
  581. package/node_modules/zod/v4/locales/cs.d.ts +0 -4
  582. package/node_modules/zod/v4/locales/cs.js +0 -116
  583. package/node_modules/zod/v4/locales/da.cjs +0 -147
  584. package/node_modules/zod/v4/locales/da.d.cts +0 -5
  585. package/node_modules/zod/v4/locales/da.d.ts +0 -4
  586. package/node_modules/zod/v4/locales/da.js +0 -120
  587. package/node_modules/zod/v4/locales/de.cjs +0 -140
  588. package/node_modules/zod/v4/locales/de.d.cts +0 -5
  589. package/node_modules/zod/v4/locales/de.d.ts +0 -4
  590. package/node_modules/zod/v4/locales/de.js +0 -113
  591. package/node_modules/zod/v4/locales/el.cjs +0 -139
  592. package/node_modules/zod/v4/locales/el.d.cts +0 -5
  593. package/node_modules/zod/v4/locales/el.d.ts +0 -4
  594. package/node_modules/zod/v4/locales/el.js +0 -112
  595. package/node_modules/zod/v4/locales/en.cjs +0 -152
  596. package/node_modules/zod/v4/locales/en.d.cts +0 -5
  597. package/node_modules/zod/v4/locales/en.d.ts +0 -4
  598. package/node_modules/zod/v4/locales/en.js +0 -125
  599. package/node_modules/zod/v4/locales/eo.cjs +0 -141
  600. package/node_modules/zod/v4/locales/eo.d.cts +0 -5
  601. package/node_modules/zod/v4/locales/eo.d.ts +0 -4
  602. package/node_modules/zod/v4/locales/eo.js +0 -114
  603. package/node_modules/zod/v4/locales/es.cjs +0 -163
  604. package/node_modules/zod/v4/locales/es.d.cts +0 -5
  605. package/node_modules/zod/v4/locales/es.d.ts +0 -4
  606. package/node_modules/zod/v4/locales/es.js +0 -136
  607. package/node_modules/zod/v4/locales/fa.cjs +0 -146
  608. package/node_modules/zod/v4/locales/fa.d.cts +0 -5
  609. package/node_modules/zod/v4/locales/fa.d.ts +0 -4
  610. package/node_modules/zod/v4/locales/fa.js +0 -119
  611. package/node_modules/zod/v4/locales/fi.cjs +0 -144
  612. package/node_modules/zod/v4/locales/fi.d.cts +0 -5
  613. package/node_modules/zod/v4/locales/fi.d.ts +0 -4
  614. package/node_modules/zod/v4/locales/fi.js +0 -117
  615. package/node_modules/zod/v4/locales/fr-CA.cjs +0 -139
  616. package/node_modules/zod/v4/locales/fr-CA.d.cts +0 -5
  617. package/node_modules/zod/v4/locales/fr-CA.d.ts +0 -4
  618. package/node_modules/zod/v4/locales/fr-CA.js +0 -112
  619. package/node_modules/zod/v4/locales/fr.cjs +0 -156
  620. package/node_modules/zod/v4/locales/fr.d.cts +0 -5
  621. package/node_modules/zod/v4/locales/fr.d.ts +0 -4
  622. package/node_modules/zod/v4/locales/fr.js +0 -129
  623. package/node_modules/zod/v4/locales/gu.cjs +0 -140
  624. package/node_modules/zod/v4/locales/gu.d.cts +0 -5
  625. package/node_modules/zod/v4/locales/gu.d.ts +0 -4
  626. package/node_modules/zod/v4/locales/gu.js +0 -113
  627. package/node_modules/zod/v4/locales/he.cjs +0 -248
  628. package/node_modules/zod/v4/locales/he.d.cts +0 -5
  629. package/node_modules/zod/v4/locales/he.d.ts +0 -4
  630. package/node_modules/zod/v4/locales/he.js +0 -221
  631. package/node_modules/zod/v4/locales/hi.cjs +0 -138
  632. package/node_modules/zod/v4/locales/hi.d.cts +0 -5
  633. package/node_modules/zod/v4/locales/hi.d.ts +0 -4
  634. package/node_modules/zod/v4/locales/hi.js +0 -111
  635. package/node_modules/zod/v4/locales/hr.cjs +0 -153
  636. package/node_modules/zod/v4/locales/hr.d.cts +0 -5
  637. package/node_modules/zod/v4/locales/hr.d.ts +0 -4
  638. package/node_modules/zod/v4/locales/hr.js +0 -126
  639. package/node_modules/zod/v4/locales/hu.cjs +0 -140
  640. package/node_modules/zod/v4/locales/hu.d.cts +0 -5
  641. package/node_modules/zod/v4/locales/hu.d.ts +0 -4
  642. package/node_modules/zod/v4/locales/hu.js +0 -113
  643. package/node_modules/zod/v4/locales/hy.cjs +0 -185
  644. package/node_modules/zod/v4/locales/hy.d.cts +0 -5
  645. package/node_modules/zod/v4/locales/hy.d.ts +0 -4
  646. package/node_modules/zod/v4/locales/hy.js +0 -158
  647. package/node_modules/zod/v4/locales/id.cjs +0 -138
  648. package/node_modules/zod/v4/locales/id.d.cts +0 -5
  649. package/node_modules/zod/v4/locales/id.d.ts +0 -4
  650. package/node_modules/zod/v4/locales/id.js +0 -111
  651. package/node_modules/zod/v4/locales/index.cjs +0 -152
  652. package/node_modules/zod/v4/locales/index.d.cts +0 -63
  653. package/node_modules/zod/v4/locales/index.d.ts +0 -63
  654. package/node_modules/zod/v4/locales/index.js +0 -63
  655. package/node_modules/zod/v4/locales/is.cjs +0 -141
  656. package/node_modules/zod/v4/locales/is.d.cts +0 -5
  657. package/node_modules/zod/v4/locales/is.d.ts +0 -4
  658. package/node_modules/zod/v4/locales/is.js +0 -114
  659. package/node_modules/zod/v4/locales/it.cjs +0 -140
  660. package/node_modules/zod/v4/locales/it.d.cts +0 -5
  661. package/node_modules/zod/v4/locales/it.d.ts +0 -4
  662. package/node_modules/zod/v4/locales/it.js +0 -113
  663. package/node_modules/zod/v4/locales/ja.cjs +0 -139
  664. package/node_modules/zod/v4/locales/ja.d.cts +0 -5
  665. package/node_modules/zod/v4/locales/ja.d.ts +0 -4
  666. package/node_modules/zod/v4/locales/ja.js +0 -112
  667. package/node_modules/zod/v4/locales/ka.cjs +0 -144
  668. package/node_modules/zod/v4/locales/ka.d.cts +0 -5
  669. package/node_modules/zod/v4/locales/ka.d.ts +0 -4
  670. package/node_modules/zod/v4/locales/ka.js +0 -117
  671. package/node_modules/zod/v4/locales/kh.cjs +0 -12
  672. package/node_modules/zod/v4/locales/kh.d.cts +0 -5
  673. package/node_modules/zod/v4/locales/kh.d.ts +0 -5
  674. package/node_modules/zod/v4/locales/kh.js +0 -5
  675. package/node_modules/zod/v4/locales/km.cjs +0 -142
  676. package/node_modules/zod/v4/locales/km.d.cts +0 -5
  677. package/node_modules/zod/v4/locales/km.d.ts +0 -4
  678. package/node_modules/zod/v4/locales/km.js +0 -115
  679. package/node_modules/zod/v4/locales/kn.cjs +0 -143
  680. package/node_modules/zod/v4/locales/kn.d.cts +0 -5
  681. package/node_modules/zod/v4/locales/kn.d.ts +0 -4
  682. package/node_modules/zod/v4/locales/kn.js +0 -116
  683. package/node_modules/zod/v4/locales/ko.cjs +0 -143
  684. package/node_modules/zod/v4/locales/ko.d.cts +0 -5
  685. package/node_modules/zod/v4/locales/ko.d.ts +0 -4
  686. package/node_modules/zod/v4/locales/ko.js +0 -116
  687. package/node_modules/zod/v4/locales/lt.cjs +0 -234
  688. package/node_modules/zod/v4/locales/lt.d.cts +0 -5
  689. package/node_modules/zod/v4/locales/lt.d.ts +0 -4
  690. package/node_modules/zod/v4/locales/lt.js +0 -207
  691. package/node_modules/zod/v4/locales/mk.cjs +0 -141
  692. package/node_modules/zod/v4/locales/mk.d.cts +0 -5
  693. package/node_modules/zod/v4/locales/mk.d.ts +0 -4
  694. package/node_modules/zod/v4/locales/mk.js +0 -114
  695. package/node_modules/zod/v4/locales/ms.cjs +0 -139
  696. package/node_modules/zod/v4/locales/ms.d.cts +0 -5
  697. package/node_modules/zod/v4/locales/ms.d.ts +0 -4
  698. package/node_modules/zod/v4/locales/ms.js +0 -112
  699. package/node_modules/zod/v4/locales/ne.cjs +0 -138
  700. package/node_modules/zod/v4/locales/ne.d.cts +0 -5
  701. package/node_modules/zod/v4/locales/ne.d.ts +0 -4
  702. package/node_modules/zod/v4/locales/ne.js +0 -111
  703. package/node_modules/zod/v4/locales/nl.cjs +0 -142
  704. package/node_modules/zod/v4/locales/nl.d.cts +0 -5
  705. package/node_modules/zod/v4/locales/nl.d.ts +0 -4
  706. package/node_modules/zod/v4/locales/nl.js +0 -115
  707. package/node_modules/zod/v4/locales/nn.cjs +0 -140
  708. package/node_modules/zod/v4/locales/nn.d.cts +0 -5
  709. package/node_modules/zod/v4/locales/nn.d.ts +0 -4
  710. package/node_modules/zod/v4/locales/nn.js +0 -113
  711. package/node_modules/zod/v4/locales/no.cjs +0 -140
  712. package/node_modules/zod/v4/locales/no.d.cts +0 -5
  713. package/node_modules/zod/v4/locales/no.d.ts +0 -4
  714. package/node_modules/zod/v4/locales/no.js +0 -113
  715. package/node_modules/zod/v4/locales/ota.cjs +0 -141
  716. package/node_modules/zod/v4/locales/ota.d.cts +0 -5
  717. package/node_modules/zod/v4/locales/ota.d.ts +0 -4
  718. package/node_modules/zod/v4/locales/ota.js +0 -114
  719. package/node_modules/zod/v4/locales/package.json +0 -7
  720. package/node_modules/zod/v4/locales/pl.cjs +0 -141
  721. package/node_modules/zod/v4/locales/pl.d.cts +0 -5
  722. package/node_modules/zod/v4/locales/pl.d.ts +0 -4
  723. package/node_modules/zod/v4/locales/pl.js +0 -114
  724. package/node_modules/zod/v4/locales/ps.cjs +0 -146
  725. package/node_modules/zod/v4/locales/ps.d.cts +0 -5
  726. package/node_modules/zod/v4/locales/ps.d.ts +0 -4
  727. package/node_modules/zod/v4/locales/ps.js +0 -119
  728. package/node_modules/zod/v4/locales/pt-BR.cjs +0 -170
  729. package/node_modules/zod/v4/locales/pt-BR.d.cts +0 -5
  730. package/node_modules/zod/v4/locales/pt-BR.d.ts +0 -4
  731. package/node_modules/zod/v4/locales/pt-BR.js +0 -143
  732. package/node_modules/zod/v4/locales/pt.cjs +0 -169
  733. package/node_modules/zod/v4/locales/pt.d.cts +0 -5
  734. package/node_modules/zod/v4/locales/pt.d.ts +0 -4
  735. package/node_modules/zod/v4/locales/pt.js +0 -142
  736. package/node_modules/zod/v4/locales/ro.cjs +0 -149
  737. package/node_modules/zod/v4/locales/ro.d.cts +0 -5
  738. package/node_modules/zod/v4/locales/ro.d.ts +0 -4
  739. package/node_modules/zod/v4/locales/ro.js +0 -122
  740. package/node_modules/zod/v4/locales/ru.cjs +0 -195
  741. package/node_modules/zod/v4/locales/ru.d.cts +0 -5
  742. package/node_modules/zod/v4/locales/ru.d.ts +0 -4
  743. package/node_modules/zod/v4/locales/ru.js +0 -168
  744. package/node_modules/zod/v4/locales/sk.cjs +0 -143
  745. package/node_modules/zod/v4/locales/sk.d.cts +0 -5
  746. package/node_modules/zod/v4/locales/sk.d.ts +0 -4
  747. package/node_modules/zod/v4/locales/sk.js +0 -116
  748. package/node_modules/zod/v4/locales/sl.cjs +0 -141
  749. package/node_modules/zod/v4/locales/sl.d.cts +0 -5
  750. package/node_modules/zod/v4/locales/sl.d.ts +0 -4
  751. package/node_modules/zod/v4/locales/sl.js +0 -114
  752. package/node_modules/zod/v4/locales/sv.cjs +0 -142
  753. package/node_modules/zod/v4/locales/sv.d.cts +0 -5
  754. package/node_modules/zod/v4/locales/sv.d.ts +0 -4
  755. package/node_modules/zod/v4/locales/sv.js +0 -115
  756. package/node_modules/zod/v4/locales/ta.cjs +0 -142
  757. package/node_modules/zod/v4/locales/ta.d.cts +0 -5
  758. package/node_modules/zod/v4/locales/ta.d.ts +0 -4
  759. package/node_modules/zod/v4/locales/ta.js +0 -115
  760. package/node_modules/zod/v4/locales/tg.cjs +0 -144
  761. package/node_modules/zod/v4/locales/tg.d.cts +0 -5
  762. package/node_modules/zod/v4/locales/tg.d.ts +0 -4
  763. package/node_modules/zod/v4/locales/tg.js +0 -117
  764. package/node_modules/zod/v4/locales/th.cjs +0 -142
  765. package/node_modules/zod/v4/locales/th.d.cts +0 -5
  766. package/node_modules/zod/v4/locales/th.d.ts +0 -4
  767. package/node_modules/zod/v4/locales/th.js +0 -115
  768. package/node_modules/zod/v4/locales/tk.cjs +0 -134
  769. package/node_modules/zod/v4/locales/tk.d.cts +0 -5
  770. package/node_modules/zod/v4/locales/tk.d.ts +0 -4
  771. package/node_modules/zod/v4/locales/tk.js +0 -107
  772. package/node_modules/zod/v4/locales/tr.cjs +0 -137
  773. package/node_modules/zod/v4/locales/tr.d.cts +0 -5
  774. package/node_modules/zod/v4/locales/tr.d.ts +0 -4
  775. package/node_modules/zod/v4/locales/tr.js +0 -110
  776. package/node_modules/zod/v4/locales/ua.cjs +0 -12
  777. package/node_modules/zod/v4/locales/ua.d.cts +0 -5
  778. package/node_modules/zod/v4/locales/ua.d.ts +0 -5
  779. package/node_modules/zod/v4/locales/ua.js +0 -5
  780. package/node_modules/zod/v4/locales/uk.cjs +0 -140
  781. package/node_modules/zod/v4/locales/uk.d.cts +0 -5
  782. package/node_modules/zod/v4/locales/uk.d.ts +0 -4
  783. package/node_modules/zod/v4/locales/uk.js +0 -113
  784. package/node_modules/zod/v4/locales/ur.cjs +0 -142
  785. package/node_modules/zod/v4/locales/ur.d.cts +0 -5
  786. package/node_modules/zod/v4/locales/ur.d.ts +0 -4
  787. package/node_modules/zod/v4/locales/ur.js +0 -115
  788. package/node_modules/zod/v4/locales/uz.cjs +0 -140
  789. package/node_modules/zod/v4/locales/uz.d.cts +0 -5
  790. package/node_modules/zod/v4/locales/uz.d.ts +0 -4
  791. package/node_modules/zod/v4/locales/uz.js +0 -113
  792. package/node_modules/zod/v4/locales/vi.cjs +0 -140
  793. package/node_modules/zod/v4/locales/vi.d.cts +0 -5
  794. package/node_modules/zod/v4/locales/vi.d.ts +0 -4
  795. package/node_modules/zod/v4/locales/vi.js +0 -113
  796. package/node_modules/zod/v4/locales/yo.cjs +0 -139
  797. package/node_modules/zod/v4/locales/yo.d.cts +0 -5
  798. package/node_modules/zod/v4/locales/yo.d.ts +0 -4
  799. package/node_modules/zod/v4/locales/yo.js +0 -112
  800. package/node_modules/zod/v4/locales/zh-CN.cjs +0 -141
  801. package/node_modules/zod/v4/locales/zh-CN.d.cts +0 -5
  802. package/node_modules/zod/v4/locales/zh-CN.d.ts +0 -4
  803. package/node_modules/zod/v4/locales/zh-CN.js +0 -114
  804. package/node_modules/zod/v4/locales/zh-TW.cjs +0 -139
  805. package/node_modules/zod/v4/locales/zh-TW.d.cts +0 -5
  806. package/node_modules/zod/v4/locales/zh-TW.d.ts +0 -4
  807. package/node_modules/zod/v4/locales/zh-TW.js +0 -112
  808. package/node_modules/zod/v4/mini/checks.cjs +0 -54
  809. package/node_modules/zod/v4/mini/checks.d.cts +0 -1
  810. package/node_modules/zod/v4/mini/checks.d.ts +0 -1
  811. package/node_modules/zod/v4/mini/checks.js +0 -1
  812. package/node_modules/zod/v4/mini/coerce.cjs +0 -71
  813. package/node_modules/zod/v4/mini/coerce.d.cts +0 -7
  814. package/node_modules/zod/v4/mini/coerce.d.ts +0 -7
  815. package/node_modules/zod/v4/mini/coerce.js +0 -22
  816. package/node_modules/zod/v4/mini/deep-partial.cjs +0 -58
  817. package/node_modules/zod/v4/mini/deep-partial.d.cts +0 -14
  818. package/node_modules/zod/v4/mini/deep-partial.d.ts +0 -14
  819. package/node_modules/zod/v4/mini/deep-partial.js +0 -13
  820. package/node_modules/zod/v4/mini/external.cjs +0 -95
  821. package/node_modules/zod/v4/mini/external.d.cts +0 -16
  822. package/node_modules/zod/v4/mini/external.d.ts +0 -16
  823. package/node_modules/zod/v4/mini/external.js +0 -16
  824. package/node_modules/zod/v4/mini/in-out.cjs +0 -82
  825. package/node_modules/zod/v4/mini/in-out.d.cts +0 -8
  826. package/node_modules/zod/v4/mini/in-out.d.ts +0 -8
  827. package/node_modules/zod/v4/mini/in-out.js +0 -36
  828. package/node_modules/zod/v4/mini/index.cjs +0 -51
  829. package/node_modules/zod/v4/mini/index.d.cts +0 -3
  830. package/node_modules/zod/v4/mini/index.d.ts +0 -3
  831. package/node_modules/zod/v4/mini/index.js +0 -3
  832. package/node_modules/zod/v4/mini/iso.cjs +0 -83
  833. package/node_modules/zod/v4/mini/iso.d.cts +0 -22
  834. package/node_modules/zod/v4/mini/iso.d.ts +0 -22
  835. package/node_modules/zod/v4/mini/iso.js +0 -34
  836. package/node_modules/zod/v4/mini/package.json +0 -7
  837. package/node_modules/zod/v4/mini/parse.cjs +0 -37
  838. package/node_modules/zod/v4/mini/parse.d.cts +0 -1
  839. package/node_modules/zod/v4/mini/parse.d.ts +0 -1
  840. package/node_modules/zod/v4/mini/parse.js +0 -1
  841. package/node_modules/zod/v4/mini/schemas.cjs +0 -1147
  842. package/node_modules/zod/v4/mini/schemas.d.cts +0 -480
  843. package/node_modules/zod/v4/mini/schemas.d.ts +0 -480
  844. package/node_modules/zod/v4/mini/schemas.js +0 -1002
  845. package/node_modules/zod/v4/package.json +0 -7
  846. package/node_modules/zod/v4-mini/index.cjs +0 -51
  847. package/node_modules/zod/v4-mini/index.d.cts +0 -3
  848. package/node_modules/zod/v4-mini/index.d.ts +0 -3
  849. package/node_modules/zod/v4-mini/index.js +0 -3
  850. package/node_modules/zod/v4-mini/package.json +0 -7
@@ -1,2669 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.$ZodObject = exports.$ZodArray = exports.$ZodDate = exports.$ZodVoid = exports.$ZodNever = exports.$ZodUnknown = exports.$ZodAny = exports.$ZodNull = exports.$ZodUndefined = exports.$ZodSymbol = exports.$ZodBigIntFormat = exports.$ZodBigInt = exports.$ZodBoolean = exports.$ZodNumberFormat = exports.$ZodNumber = exports.$ZodCustomStringFormat = exports.$ZodJWT = exports.$ZodIBAN = exports.$ZodCreditCard = exports.$ZodE164 = exports.$ZodBase64URL = exports.base64urlCharset = exports.$ZodBase64 = exports.base64Charset = exports.$ZodCIDRv6 = exports.$ZodCIDRv4 = exports.$ZodMAC = exports.$ZodIPv6 = exports.$ZodIPv4 = exports.$ZodISODuration = exports.$ZodISOTime = exports.$ZodISODate = exports.$ZodISODateTime = exports.$ZodKSUID = exports.$ZodXID = exports.$ZodULID = exports.$ZodCUID2 = exports.$ZodCUID = exports.$ZodNanoID = exports.$ZodEmoji = exports.$ZodURL = exports.URL_UNPARSEABLE = exports.URL_BAD_FORMAT = exports.$ZodEmail = exports.$ZodUUID = exports.$ZodGUID = exports.$ZodStringFormat = exports.$ZodString = exports.clone = exports.$ZodType = void 0;
27
- exports.$ZodCustom = exports.$ZodLazy = exports.$ZodPromise = exports.$ZodFunction = exports.$ZodTemplateLiteral = exports.$ZodReadonly = exports.$ZodPreprocess = exports.$ZodCodec = exports.$ZodPipe = exports.$ZodNaN = exports.$ZodCatch = exports.$ZodSuccess = exports.$ZodNonOptional = exports.$ZodPrefault = exports.$ZodDefault = exports.$ZodNullable = exports.$ZodExactOptional = exports.$ZodOptional = exports.$ZodTransform = exports.$ZodFile = exports.$ZodLiteral = exports.$ZodEnum = exports.$ZodSet = exports.$ZodMap = exports.$ZodRecord = exports.$ZodTuple = exports.$ZodIntersection = exports.$ZodDiscriminatedUnion = exports.$ZodXor = exports.$ZodUnion = exports.$ZodObjectJIT = void 0;
28
- exports.standardProps = standardProps;
29
- exports.canParseURL = canParseURL;
30
- exports.validateURL = validateURL;
31
- exports.parseURLObject = parseURLObject;
32
- exports.stripTabAndNewline = stripTabAndNewline;
33
- exports.urlHostnameOk = urlHostnameOk;
34
- exports.urlProtocolOk = urlProtocolOk;
35
- exports.isValidIPv6 = isValidIPv6;
36
- exports.isValidCIDRv6 = isValidCIDRv6;
37
- exports.isValidBase64 = isValidBase64;
38
- exports.isValidBase64URL = isValidBase64URL;
39
- exports.isValidCreditCard = isValidCreditCard;
40
- exports.isValidIBAN = isValidIBAN;
41
- exports.isValidJWT = isValidJWT;
42
- exports.getDiscriminatedOption = getDiscriminatedOption;
43
- exports.mergeValues = mergeValues;
44
- const checks = __importStar(require("./checks.cjs"));
45
- const core = __importStar(require("./core.cjs"));
46
- const doc_js_1 = require("./doc.cjs");
47
- const parse_js_1 = require("./parse.cjs");
48
- const regexes = __importStar(require("./regexes.cjs"));
49
- const util = __importStar(require("./util.cjs"));
50
- const versions_js_1 = require("./versions.cjs");
51
- exports.$ZodType = core.$constructor("$ZodType", (inst, def) => {
52
- var _a;
53
- inst ?? (inst = {});
54
- inst._zod.def = def; // set _def property
55
- inst._zod.bag = inst._zod.bag || {}; // initialize _bag object
56
- inst._zod.version = versions_js_1.version;
57
- const defChecks = inst._zod.def.checks;
58
- // if inst is itself a checks.$ZodCheck, run it as a check
59
- const checks = inst._zod.traits.has("$ZodCheck")
60
- ? [inst, ...(defChecks ?? [])]
61
- : defChecks?.length
62
- ? [...defChecks]
63
- : [];
64
- for (const ch of checks) {
65
- for (const fn of ch._zod.onattach) {
66
- fn(inst);
67
- }
68
- }
69
- if (checks.length === 0) {
70
- // deferred initializer inst._zod.parse is not yet defined
71
- (_a = inst._zod).deferred ?? (_a.deferred = []);
72
- inst._zod.deferred?.push(() => {
73
- inst._zod.run = inst._zod.parse;
74
- });
75
- }
76
- else {
77
- const runChecks = (payload, checks, ctx) => {
78
- if (payload.memo)
79
- return payload;
80
- let isAborted = util.aborted(payload);
81
- let asyncResult;
82
- for (const ch of checks) {
83
- if (ch._zod.def.when) {
84
- if (util.explicitlyAborted(payload))
85
- continue;
86
- const shouldRun = ch._zod.def.when(payload);
87
- if (!shouldRun)
88
- continue;
89
- }
90
- else if (isAborted) {
91
- continue;
92
- }
93
- const currLen = payload.issues.length;
94
- const _ = ch._zod.check(payload);
95
- if (_ instanceof Promise && ctx?.async === false) {
96
- throw new core.$ZodAsyncError();
97
- }
98
- if (asyncResult || _ instanceof Promise) {
99
- asyncResult = (asyncResult ?? Promise.resolve()).then(async () => {
100
- await _;
101
- const nextLen = payload.issues.length;
102
- if (nextLen === currLen)
103
- return;
104
- util.attachSchema(payload.issues, currLen, inst);
105
- if (!isAborted)
106
- isAborted = util.aborted(payload, currLen);
107
- });
108
- }
109
- else {
110
- const nextLen = payload.issues.length;
111
- if (nextLen === currLen)
112
- continue;
113
- util.attachSchema(payload.issues, currLen, inst);
114
- if (!isAborted)
115
- isAborted = util.aborted(payload, currLen);
116
- }
117
- }
118
- if (asyncResult) {
119
- return asyncResult.then(() => {
120
- return payload;
121
- });
122
- }
123
- return payload;
124
- };
125
- const handleCanaryResult = (canary, payload, ctx) => {
126
- // abort if the canary is aborted
127
- if (util.aborted(canary)) {
128
- canary.aborted = true;
129
- return canary;
130
- }
131
- // run checks first, then
132
- const checkResult = runChecks(payload, checks, ctx);
133
- if (checkResult instanceof Promise) {
134
- if (ctx.async === false)
135
- throw new core.$ZodAsyncError();
136
- return checkResult.then((checkResult) => inst._zod.parse(checkResult, ctx));
137
- }
138
- return inst._zod.parse(checkResult, ctx);
139
- };
140
- inst._zod.run = (payload, ctx) => {
141
- if (ctx.skipChecks) {
142
- return inst._zod.parse(payload, ctx);
143
- }
144
- if (ctx.direction === "backward") {
145
- // run canary initial pass (no checks)
146
- const canary = inst._zod.parse({ value: payload.value, issues: [] }, { ...ctx, skipChecks: true });
147
- if (canary instanceof Promise) {
148
- return canary.then((canary) => {
149
- return handleCanaryResult(canary, payload, ctx);
150
- });
151
- }
152
- return handleCanaryResult(canary, payload, ctx);
153
- }
154
- // forward
155
- const result = inst._zod.parse(payload, ctx);
156
- if (result instanceof Promise) {
157
- if (ctx.async === false)
158
- throw new core.$ZodAsyncError();
159
- return result.then((result) => runChecks(result, checks, ctx));
160
- }
161
- return runChecks(result, checks, ctx);
162
- };
163
- }
164
- }, {
165
- // Wrappers extend this by installing a richer factory over it; reading it eagerly would defeat the laziness.
166
- get "~standard"() {
167
- return util.hide(this, "~standard", standardProps(this));
168
- },
169
- set "~standard"(value) {
170
- util.own(this, "~standard", value);
171
- },
172
- });
173
- /** The Standard Schema surface for `inst`. Shared so wrappers can extend it without forcing it. */
174
- // a Standard Schema result only reports issues, so a failure finalizes them straight off the raw payload: no ZodError, and no lazy result to read through
175
- const toStandardResult = (r, ctx) => r.issues.length ? { issues: r.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())) } : { value: r.value };
176
- async function validateAsync(inst, value) {
177
- const ctx = { async: true };
178
- return toStandardResult((await inst._zod.run({ value, issues: [] }, ctx)), ctx);
179
- }
180
- function standardProps(inst) {
181
- return {
182
- validate: (value) => {
183
- const ctx = { async: false };
184
- try {
185
- const r = inst._zod.run({ value, issues: [] }, ctx);
186
- if (!(r instanceof Promise))
187
- return toStandardResult(r, ctx);
188
- }
189
- catch (_) { }
190
- // async function so a synchronously throwing check rejects instead of escaping validate
191
- return validateAsync(inst, value);
192
- },
193
- vendor: "zod",
194
- version: 1,
195
- };
196
- }
197
- var util_js_1 = require("./util.cjs");
198
- Object.defineProperty(exports, "clone", { enumerable: true, get: function () { return util_js_1.clone; } });
199
- exports.$ZodString = core.$constructor("$ZodString", (inst, def) => {
200
- exports.$ZodType.init(inst, def);
201
- // a format's own pattern, else unbounded; a template literal derives the check-aware form itself
202
- inst._zod.pattern = def.pattern ?? regexes.anyString;
203
- inst._zod.parse = (payload, _) => {
204
- if (def.coerce)
205
- try {
206
- payload.value = String(payload.value);
207
- }
208
- catch (_) { }
209
- if (typeof payload.value === "string")
210
- return payload;
211
- payload.issues.push({
212
- expected: "string",
213
- code: "invalid_type",
214
- input: payload.value,
215
- inst,
216
- });
217
- return payload;
218
- };
219
- });
220
- exports.$ZodStringFormat = core.$constructor("$ZodStringFormat", (inst, def) => {
221
- // check initialization must come first
222
- checks.$ZodCheckStringFormat.init(inst, def);
223
- exports.$ZodString.init(inst, def);
224
- });
225
- exports.$ZodGUID = core.$constructor("$ZodGUID", (inst, def) => {
226
- def.pattern ?? (def.pattern = regexes.guid);
227
- exports.$ZodStringFormat.init(inst, def);
228
- });
229
- exports.$ZodUUID = core.$constructor("$ZodUUID", (inst, def) => {
230
- if (def.version) {
231
- const versionMap = {
232
- v1: 1,
233
- v2: 2,
234
- v3: 3,
235
- v4: 4,
236
- v5: 5,
237
- v6: 6,
238
- v7: 7,
239
- v8: 8,
240
- };
241
- const v = versionMap[def.version];
242
- if (v === undefined)
243
- throw new Error(`Invalid UUID version: "${def.version}"`);
244
- def.pattern ?? (def.pattern = regexes.uuid(v));
245
- }
246
- else
247
- def.pattern ?? (def.pattern = regexes.uuid());
248
- exports.$ZodStringFormat.init(inst, def);
249
- });
250
- exports.$ZodEmail = core.$constructor("$ZodEmail", (inst, def) => {
251
- def.pattern ?? (def.pattern = regexes.email);
252
- exports.$ZodStringFormat.init(inst, def);
253
- });
254
- /** The `://` guard rejected the input before the URL constructor saw it. */
255
- exports.URL_BAD_FORMAT = 1;
256
- /** The URL parser rejected the input. */
257
- exports.URL_UNPARSEABLE = 2;
258
- function canParseURL(input) {
259
- try {
260
- if (typeof URL !== "undefined" && typeof URL.canParse === "function")
261
- return URL.canParse(input);
262
- new URL(input);
263
- return true;
264
- }
265
- catch {
266
- return false;
267
- }
268
- }
269
- function validateURL(trimmed, def) {
270
- if (!("normalize" in def) && !("hostname" in def) && !("protocol" in def)) {
271
- return canParseURL(trimmed) || exports.URL_UNPARSEABLE;
272
- }
273
- return parseURLObject(trimmed, def);
274
- }
275
- /** Parses a URL while preserving the non-normalizing HTTP guard. */
276
- function parseURLObject(trimmed, def) {
277
- // When normalize is off, require :// for http/https URLs. This prevents strings like "http:example.com" or "https:/path" from being silently accepted
278
- if (!def.normalize && def.protocol?.source === regexes.httpProtocol.source && !/^https?:\/\//i.test(trimmed)) {
279
- return exports.URL_BAD_FORMAT;
280
- }
281
- try {
282
- if (typeof URL !== "undefined") {
283
- const URLStatic = URL;
284
- if (typeof URLStatic.parse === "function")
285
- return URLStatic.parse(trimmed) ?? exports.URL_UNPARSEABLE;
286
- }
287
- // @ts-ignore
288
- return new URL(trimmed);
289
- }
290
- catch {
291
- return exports.URL_UNPARSEABLE;
292
- }
293
- }
294
- const asciiTabOrNewline = /[\t\n\r]/g;
295
- /** The URL parser deletes every ASCII tab, LF and CR from its input before it parses, so `new URL("https://exa\nmple.com")` reports on `example.com`. Applying the same deletion to the returned value closes the half of that divergence which can move the host; the parser's other rewrite, stripping C0 controls at the edges, cannot. */
296
- function stripTabAndNewline(value) {
297
- return value.replace(asciiTabOrNewline, "");
298
- }
299
- function urlHostnameOk(url, hostname) {
300
- hostname.lastIndex = 0;
301
- return hostname.test(url.hostname);
302
- }
303
- function urlProtocolOk(url, protocol) {
304
- protocol.lastIndex = 0;
305
- return protocol.test(url.protocol.endsWith(":") ? url.protocol.slice(0, -1) : url.protocol);
306
- }
307
- exports.$ZodURL = core.$constructor("$ZodURL", (inst, def) => {
308
- exports.$ZodStringFormat.init(inst, def);
309
- inst._zod.check = (payload) => {
310
- try {
311
- // Trim whitespace from input
312
- const trimmed = payload.value.trim();
313
- const url = validateURL(trimmed, def);
314
- if (url === exports.URL_BAD_FORMAT) {
315
- payload.issues.push({
316
- code: "invalid_format",
317
- format: "url",
318
- note: "Invalid URL format",
319
- input: payload.value,
320
- inst,
321
- continue: !def.abort,
322
- });
323
- return;
324
- }
325
- if (url === exports.URL_UNPARSEABLE) {
326
- payload.issues.push({
327
- code: "invalid_format",
328
- format: "url",
329
- input: payload.value,
330
- inst,
331
- continue: !def.abort,
332
- });
333
- return;
334
- }
335
- if (url === true) {
336
- payload.value = stripTabAndNewline(trimmed);
337
- return;
338
- }
339
- if (def.hostname && !urlHostnameOk(url, def.hostname)) {
340
- payload.issues.push({
341
- code: "invalid_format",
342
- format: "url",
343
- note: "Invalid hostname",
344
- pattern: def.hostname.source,
345
- input: payload.value,
346
- inst,
347
- continue: !def.abort,
348
- });
349
- }
350
- if (def.protocol && !urlProtocolOk(url, def.protocol)) {
351
- payload.issues.push({
352
- code: "invalid_format",
353
- format: "url",
354
- note: "Invalid protocol",
355
- pattern: def.protocol.source,
356
- input: payload.value,
357
- inst,
358
- continue: !def.abort,
359
- });
360
- }
361
- // Set the output value based on normalize flag
362
- payload.value = def.normalize ? url.href : stripTabAndNewline(trimmed);
363
- return;
364
- }
365
- catch (_) {
366
- payload.issues.push({
367
- code: "invalid_format",
368
- format: "url",
369
- input: payload.value,
370
- inst,
371
- continue: !def.abort,
372
- });
373
- }
374
- };
375
- });
376
- exports.$ZodEmoji = core.$constructor("$ZodEmoji", (inst, def) => {
377
- def.pattern ?? (def.pattern = regexes.emoji());
378
- exports.$ZodStringFormat.init(inst, def);
379
- });
380
- exports.$ZodNanoID = core.$constructor("$ZodNanoID", (inst, def) => {
381
- if (def.length !== undefined && (!Number.isInteger(def.length) || def.length < 1))
382
- throw new Error(`Invalid nanoid length: ${def.length}`);
383
- def.pattern ?? (def.pattern = def.length === undefined ? regexes.nanoid : regexes.nanoidOfLength(def.length));
384
- exports.$ZodStringFormat.init(inst, def);
385
- });
386
- /**
387
- * @deprecated CUID v1 is deprecated by its authors due to information leakage
388
- * (timestamps embedded in the id). Use {@link $ZodCUID2} instead.
389
- * See https://github.com/paralleldrive/cuid.
390
- */
391
- exports.$ZodCUID = core.$constructor("$ZodCUID", (inst, def) => {
392
- def.pattern ?? (def.pattern = regexes.cuid);
393
- exports.$ZodStringFormat.init(inst, def);
394
- });
395
- exports.$ZodCUID2 = core.$constructor("$ZodCUID2", (inst, def) => {
396
- def.pattern ?? (def.pattern = regexes.cuid2);
397
- exports.$ZodStringFormat.init(inst, def);
398
- });
399
- exports.$ZodULID = core.$constructor("$ZodULID", (inst, def) => {
400
- def.pattern ?? (def.pattern = regexes.ulid);
401
- exports.$ZodStringFormat.init(inst, def);
402
- });
403
- exports.$ZodXID = core.$constructor("$ZodXID", (inst, def) => {
404
- def.pattern ?? (def.pattern = regexes.xid);
405
- exports.$ZodStringFormat.init(inst, def);
406
- });
407
- exports.$ZodKSUID = core.$constructor("$ZodKSUID", (inst, def) => {
408
- def.pattern ?? (def.pattern = regexes.ksuid);
409
- exports.$ZodStringFormat.init(inst, def);
410
- });
411
- exports.$ZodISODateTime = core.$constructor("$ZodISODateTime", (inst, def) => {
412
- def.pattern ?? (def.pattern = regexes.datetime(def));
413
- exports.$ZodStringFormat.init(inst, def);
414
- });
415
- exports.$ZodISODate = core.$constructor("$ZodISODate", (inst, def) => {
416
- def.pattern ?? (def.pattern = regexes.date);
417
- exports.$ZodStringFormat.init(inst, def);
418
- });
419
- exports.$ZodISOTime = core.$constructor("$ZodISOTime", (inst, def) => {
420
- def.pattern ?? (def.pattern = regexes.time(def));
421
- exports.$ZodStringFormat.init(inst, def);
422
- });
423
- exports.$ZodISODuration = core.$constructor("$ZodISODuration", (inst, def) => {
424
- def.pattern ?? (def.pattern = regexes.duration);
425
- exports.$ZodStringFormat.init(inst, def);
426
- });
427
- exports.$ZodIPv4 = core.$constructor("$ZodIPv4", (inst, def) => {
428
- def.pattern ?? (def.pattern = regexes.ipv4);
429
- exports.$ZodStringFormat.init(inst, def);
430
- });
431
- /** An IPv6 address is written with hex digits, colons and dots, and nothing else. The guard is what makes the check below an IPv6 check: `new URL("http://[...]")` parses an authority, not an address, so `@` and `\` re-delimit it and `"::@1\\"` validates against the host `0.0.0.1`. The URL parser also deletes ASCII tab, LF and CR rather than failing, which is how `"::1\n"` validated as `::1`. */
432
- const ipv6Alphabet = /^[0-9a-fA-F:.]+$/;
433
- function isValidIPv6(value) {
434
- if (!ipv6Alphabet.test(value))
435
- return false;
436
- return canParseURL(`http://[${value}]`);
437
- }
438
- exports.$ZodIPv6 = core.$constructor("$ZodIPv6", (inst, def) => {
439
- def.pattern ?? (def.pattern = regexes.ipv6);
440
- exports.$ZodStringFormat.init(inst, def);
441
- inst._zod.check = (payload) => {
442
- if (!isValidIPv6(payload.value)) {
443
- payload.issues.push({
444
- code: "invalid_format",
445
- format: "ipv6",
446
- input: payload.value,
447
- inst,
448
- continue: !def.abort,
449
- });
450
- }
451
- };
452
- });
453
- exports.$ZodMAC = core.$constructor("$ZodMAC", (inst, def) => {
454
- def.pattern ?? (def.pattern = regexes.mac(def.delimiter));
455
- exports.$ZodStringFormat.init(inst, def);
456
- });
457
- exports.$ZodCIDRv4 = core.$constructor("$ZodCIDRv4", (inst, def) => {
458
- def.pattern ?? (def.pattern = regexes.cidrv4);
459
- exports.$ZodStringFormat.init(inst, def);
460
- });
461
- function isValidCIDRv6(value) {
462
- const parts = value.split("/");
463
- if (parts.length !== 2)
464
- return false;
465
- const [address, prefix] = parts;
466
- if (!prefix)
467
- return false;
468
- const prefixNum = Number(prefix);
469
- if (`${prefixNum}` !== prefix)
470
- return false;
471
- if (prefixNum < 0 || prefixNum > 128)
472
- return false;
473
- return isValidIPv6(address);
474
- }
475
- exports.$ZodCIDRv6 = core.$constructor("$ZodCIDRv6", (inst, def) => {
476
- def.pattern ?? (def.pattern = regexes.cidrv6); // not used for validation
477
- exports.$ZodStringFormat.init(inst, def);
478
- inst._zod.check = (payload) => {
479
- if (!isValidCIDRv6(payload.value)) {
480
- payload.issues.push({
481
- code: "invalid_format",
482
- format: "cidrv6",
483
- input: payload.value,
484
- inst,
485
- continue: !def.abort,
486
- });
487
- }
488
- };
489
- });
490
- ////////////////////////////// ZodBase64 //////////////////////////////
491
- function isValidBase64(data) {
492
- if (data === "")
493
- return true;
494
- // atob ignores whitespace, so reject it up front.
495
- if (/\s/.test(data))
496
- return false;
497
- if (data.length % 4 !== 0)
498
- return false;
499
- try {
500
- // @ts-ignore
501
- atob(data);
502
- return true;
503
- }
504
- catch {
505
- return false;
506
- }
507
- }
508
- // lax on purpose: the quantified regexes.base64 overflows the regex stack on multi-MB input and its leading ^$| alternation leaks through template-literal composition; isValidBase64 enforces length and padding
509
- exports.base64Charset = /^[0-9a-zA-Z+/]*={0,2}$/;
510
- exports.$ZodBase64 = core.$constructor("$ZodBase64", (inst, def) => {
511
- def.pattern ?? (def.pattern = exports.base64Charset);
512
- exports.$ZodStringFormat.init(inst, def);
513
- inst._zod.check = (payload) => {
514
- if (isValidBase64(payload.value))
515
- return;
516
- payload.issues.push({
517
- code: "invalid_format",
518
- format: "base64",
519
- input: payload.value,
520
- inst,
521
- continue: !def.abort,
522
- });
523
- };
524
- });
525
- ////////////////////////////// ZodBase64URL //////////////////////////////
526
- // lax on purpose: the quantified regexes.base64url overflows the regex stack on multi-MB input; isValidBase64 enforces length on the padded string
527
- exports.base64urlCharset = /^[A-Za-z0-9_-]*$/;
528
- function isValidBase64URL(data) {
529
- if (!exports.base64urlCharset.test(data))
530
- return false;
531
- const base64 = data.replace(/[-_]/g, (c) => (c === "-" ? "+" : "/"));
532
- const padded = base64.padEnd(Math.ceil(base64.length / 4) * 4, "=");
533
- return isValidBase64(padded);
534
- }
535
- exports.$ZodBase64URL = core.$constructor("$ZodBase64URL", (inst, def) => {
536
- def.pattern ?? (def.pattern = exports.base64urlCharset);
537
- exports.$ZodStringFormat.init(inst, def);
538
- inst._zod.check = (payload) => {
539
- if (isValidBase64URL(payload.value))
540
- return;
541
- payload.issues.push({
542
- code: "invalid_format",
543
- format: "base64url",
544
- input: payload.value,
545
- inst,
546
- continue: !def.abort,
547
- });
548
- };
549
- });
550
- exports.$ZodE164 = core.$constructor("$ZodE164", (inst, def) => {
551
- def.pattern ?? (def.pattern = regexes.e164);
552
- exports.$ZodStringFormat.init(inst, def);
553
- });
554
- ////////////////////////////// ZodCreditCard //////////////////////////////
555
- const CC_SANITIZE = /[- ]/g;
556
- /** Luhn checksum on a digit-only string. Adapted from valibot (MIT). */
557
- function isLuhnAlgo(digits) {
558
- let length = digits.length;
559
- let bit = 1;
560
- let sum = 0;
561
- while (length) {
562
- const value = digits.charCodeAt(--length) - 48;
563
- bit ^= 1;
564
- sum += bit ? [0, 2, 4, 6, 8, 1, 3, 5, 7, 9][value] : value;
565
- }
566
- return sum % 10 === 0;
567
- }
568
- function isValidCreditCard(input) {
569
- if (!regexes.creditCard.test(input))
570
- return false;
571
- return isLuhnAlgo(input.replace(CC_SANITIZE, ""));
572
- }
573
- exports.$ZodCreditCard = core.$constructor("$ZodCreditCard", (inst, def) => {
574
- // Shape only — the Luhn check below is not expressible as a pattern, so consumers of `pattern` (JSON Schema, template literals) get the length and separator rules alone.
575
- def.pattern ?? (def.pattern = regexes.creditCard);
576
- exports.$ZodStringFormat.init(inst, def);
577
- inst._zod.check = (payload) => {
578
- if (isValidCreditCard(payload.value))
579
- return;
580
- payload.issues.push({
581
- code: "invalid_format",
582
- format: "credit_card",
583
- input: payload.value,
584
- inst,
585
- continue: !def.abort,
586
- });
587
- };
588
- });
589
- ////////////////////////////// ZodIBAN //////////////////////////////
590
- // iso 7064 mod 97-10 checksum without BigInt
591
- function isIso7064Mod97(iban) {
592
- let remainder = 0;
593
- const len = iban.length;
594
- for (let i = 4; i < len; i++) {
595
- const code = iban.charCodeAt(i);
596
- remainder = (code >= 65 ? remainder * 100 + (code - 55) : remainder * 10 + (code - 48)) % 97;
597
- }
598
- for (let i = 0; i < 4; i++) {
599
- const code = iban.charCodeAt(i);
600
- remainder = (code >= 65 ? remainder * 100 + (code - 55) : remainder * 10 + (code - 48)) % 97;
601
- }
602
- return remainder === 1;
603
- }
604
- function isValidIBAN(input) {
605
- if (!regexes.iban.test(input))
606
- return false;
607
- return isIso7064Mod97(input);
608
- }
609
- exports.$ZodIBAN = core.$constructor("$ZodIBAN", (inst, def) => {
610
- // shape only — checksum is not expressible as a pattern
611
- def.pattern ?? (def.pattern = regexes.iban);
612
- exports.$ZodStringFormat.init(inst, def);
613
- inst._zod.check = (payload) => {
614
- if (isValidIBAN(payload.value))
615
- return;
616
- payload.issues.push({
617
- code: "invalid_format",
618
- format: "iban",
619
- input: payload.value,
620
- inst,
621
- continue: !def.abort,
622
- });
623
- };
624
- });
625
- ////////////////////////////// ZodJWT //////////////////////////////
626
- function isValidJWT(token, algorithm = null) {
627
- try {
628
- const tokensParts = token.split(".");
629
- if (tokensParts.length !== 3)
630
- return false;
631
- const [header] = tokensParts;
632
- if (!header)
633
- return false;
634
- // @ts-ignore
635
- const parsedHeader = JSON.parse(atob(header));
636
- if ("typ" in parsedHeader && parsedHeader?.typ !== "JWT")
637
- return false;
638
- if (!parsedHeader.alg)
639
- return false;
640
- if (algorithm && (!("alg" in parsedHeader) || parsedHeader.alg !== algorithm))
641
- return false;
642
- return true;
643
- }
644
- catch {
645
- return false;
646
- }
647
- }
648
- exports.$ZodJWT = core.$constructor("$ZodJWT", (inst, def) => {
649
- exports.$ZodStringFormat.init(inst, def);
650
- inst._zod.check = (payload) => {
651
- if (isValidJWT(payload.value, def.alg))
652
- return;
653
- payload.issues.push({
654
- code: "invalid_format",
655
- format: "jwt",
656
- input: payload.value,
657
- inst,
658
- continue: !def.abort,
659
- });
660
- };
661
- });
662
- exports.$ZodCustomStringFormat = core.$constructor("$ZodCustomStringFormat", (inst, def) => {
663
- exports.$ZodStringFormat.init(inst, def);
664
- inst._zod.check = (payload) => {
665
- if (def.fn(payload.value))
666
- return;
667
- payload.issues.push({
668
- code: "invalid_format",
669
- format: def.format,
670
- input: payload.value,
671
- inst,
672
- continue: !def.abort,
673
- });
674
- };
675
- });
676
- exports.$ZodNumber = core.$constructor("$ZodNumber", (inst, def) => {
677
- exports.$ZodType.init(inst, def);
678
- inst._zod.pattern = regexes.number;
679
- inst._zod.parse = (payload, _ctx) => {
680
- if (def.coerce)
681
- try {
682
- payload.value = Number(payload.value);
683
- }
684
- catch (_) { }
685
- const input = payload.value;
686
- if (typeof input === "number" && !Number.isNaN(input) && Number.isFinite(input)) {
687
- return payload;
688
- }
689
- const received = typeof input === "number"
690
- ? Number.isNaN(input)
691
- ? "NaN"
692
- : !Number.isFinite(input)
693
- ? String(input)
694
- : undefined
695
- : undefined;
696
- payload.issues.push({
697
- expected: "number",
698
- code: "invalid_type",
699
- input,
700
- inst,
701
- ...(received ? { received } : {}),
702
- });
703
- return payload;
704
- };
705
- });
706
- exports.$ZodNumberFormat = core.$constructor("$ZodNumberFormat", (inst, def) => {
707
- checks.$ZodCheckNumberFormat.init(inst, def);
708
- exports.$ZodNumber.init(inst, def); // no format checks
709
- });
710
- exports.$ZodBoolean = core.$constructor("$ZodBoolean", (inst, def) => {
711
- exports.$ZodType.init(inst, def);
712
- inst._zod.pattern = regexes.boolean;
713
- inst._zod.parse = (payload, _ctx) => {
714
- if (def.coerce)
715
- try {
716
- payload.value = Boolean(payload.value);
717
- }
718
- catch (_) { }
719
- const input = payload.value;
720
- if (typeof input === "boolean")
721
- return payload;
722
- payload.issues.push({
723
- expected: "boolean",
724
- code: "invalid_type",
725
- input,
726
- inst,
727
- });
728
- return payload;
729
- };
730
- });
731
- exports.$ZodBigInt = core.$constructor("$ZodBigInt", (inst, def) => {
732
- exports.$ZodType.init(inst, def);
733
- inst._zod.pattern = regexes.bigint;
734
- inst._zod.parse = (payload, _ctx) => {
735
- if (def.coerce)
736
- try {
737
- payload.value = BigInt(payload.value);
738
- }
739
- catch (_) { }
740
- if (typeof payload.value === "bigint")
741
- return payload;
742
- payload.issues.push({
743
- expected: "bigint",
744
- code: "invalid_type",
745
- input: payload.value,
746
- inst,
747
- });
748
- return payload;
749
- };
750
- });
751
- exports.$ZodBigIntFormat = core.$constructor("$ZodBigIntFormat", (inst, def) => {
752
- checks.$ZodCheckBigIntFormat.init(inst, def);
753
- exports.$ZodBigInt.init(inst, def); // no format checks
754
- });
755
- exports.$ZodSymbol = core.$constructor("$ZodSymbol", (inst, def) => {
756
- exports.$ZodType.init(inst, def);
757
- inst._zod.parse = (payload, _ctx) => {
758
- const input = payload.value;
759
- if (typeof input === "symbol")
760
- return payload;
761
- payload.issues.push({
762
- expected: "symbol",
763
- code: "invalid_type",
764
- input,
765
- inst,
766
- });
767
- return payload;
768
- };
769
- });
770
- exports.$ZodUndefined = core.$constructor("$ZodUndefined", (inst, def) => {
771
- exports.$ZodType.init(inst, def);
772
- inst._zod.pattern = regexes.undefined;
773
- inst._zod.values = new Set([undefined]);
774
- inst._zod.parse = (payload, _ctx) => {
775
- const input = payload.value;
776
- if (typeof input === "undefined")
777
- return payload;
778
- payload.issues.push({
779
- expected: "undefined",
780
- code: "invalid_type",
781
- input,
782
- inst,
783
- });
784
- return payload;
785
- };
786
- });
787
- exports.$ZodNull = core.$constructor("$ZodNull", (inst, def) => {
788
- exports.$ZodType.init(inst, def);
789
- inst._zod.pattern = regexes.null;
790
- inst._zod.values = new Set([null]);
791
- inst._zod.parse = (payload, _ctx) => {
792
- const input = payload.value;
793
- if (input === null)
794
- return payload;
795
- payload.issues.push({
796
- expected: "null",
797
- code: "invalid_type",
798
- input,
799
- inst,
800
- });
801
- return payload;
802
- };
803
- });
804
- exports.$ZodAny = core.$constructor("$ZodAny", (inst, def) => {
805
- exports.$ZodType.init(inst, def);
806
- inst._zod.parse = (payload) => payload;
807
- });
808
- exports.$ZodUnknown = core.$constructor("$ZodUnknown", (inst, def) => {
809
- exports.$ZodType.init(inst, def);
810
- inst._zod.parse = (payload) => payload;
811
- });
812
- exports.$ZodNever = core.$constructor("$ZodNever", (inst, def) => {
813
- exports.$ZodType.init(inst, def);
814
- inst._zod.parse = (payload, _ctx) => {
815
- payload.issues.push({
816
- expected: "never",
817
- code: "invalid_type",
818
- input: payload.value,
819
- inst,
820
- });
821
- return payload;
822
- };
823
- });
824
- exports.$ZodVoid = core.$constructor("$ZodVoid", (inst, def) => {
825
- exports.$ZodType.init(inst, def);
826
- inst._zod.parse = (payload, _ctx) => {
827
- const input = payload.value;
828
- if (typeof input === "undefined")
829
- return payload;
830
- payload.issues.push({
831
- expected: "void",
832
- code: "invalid_type",
833
- input,
834
- inst,
835
- });
836
- return payload;
837
- };
838
- });
839
- exports.$ZodDate = core.$constructor("$ZodDate", (inst, def) => {
840
- exports.$ZodType.init(inst, def);
841
- inst._zod.parse = (payload, _ctx) => {
842
- if (def.coerce) {
843
- try {
844
- payload.value = new Date(payload.value);
845
- }
846
- catch (_err) { }
847
- }
848
- const input = payload.value;
849
- const isDate = input instanceof Date;
850
- const isValidDate = isDate && !Number.isNaN(input.getTime());
851
- if (isValidDate)
852
- return payload;
853
- payload.issues.push({
854
- expected: "date",
855
- code: "invalid_type",
856
- input,
857
- ...(isDate ? { received: "Invalid Date" } : {}),
858
- inst,
859
- });
860
- return payload;
861
- };
862
- });
863
- function handleArrayResult(result, final, index) {
864
- if (result.issues.length) {
865
- final.issues.push(...util.prefixIssues(index, result.issues));
866
- }
867
- final.value[index] = result.value;
868
- }
869
- exports.$ZodArray = core.$constructor("$ZodArray", (inst, def) => {
870
- exports.$ZodType.init(inst, def);
871
- const memo = core.globalConfig.memoizer;
872
- memo?.attach(inst);
873
- inst._zod.parse = (payload, ctx) => {
874
- const input = payload.value;
875
- if (!Array.isArray(input)) {
876
- payload.issues.push({
877
- expected: "array",
878
- code: "invalid_type",
879
- input,
880
- inst,
881
- });
882
- return payload;
883
- }
884
- payload.value = memo ? memo.alloc(inst, payload, Array(input.length), ctx) : Array(input.length);
885
- const proms = [];
886
- const abortEarly = ctx?.abortEarly;
887
- for (let i = 0; i < input.length; i++) {
888
- const item = input[i];
889
- const result = def.element._zod.run({
890
- value: item,
891
- issues: [],
892
- }, ctx);
893
- if (result instanceof Promise) {
894
- proms.push(result.then((result) => handleArrayResult(result, payload, i)));
895
- }
896
- else {
897
- handleArrayResult(result, payload, i);
898
- // the element's payload is authoritative here, since handleArrayResult forwards every issue; an object's is not, because it drops a failed absent optional
899
- if (abortEarly && result.issues.length !== 0 && util.aborted(result))
900
- break;
901
- }
902
- }
903
- if (proms.length) {
904
- return Promise.all(proms).then(() => payload);
905
- }
906
- return payload; //handleArrayResultsAsync(parseResults, final);
907
- };
908
- });
909
- function handlePropertyResult(result, final, key, input, optin, optout) {
910
- const isPresent = key in input;
911
- const isOptionalOut = optout === "optional";
912
- // The middle rung means "absence permitted, nothing supplied in its place", so an absent key contributes nothing — whatever the schema made of `undefined` is invented, not substituted. Only `optional` reaches this with a value: `defaulted` substitutes, and a schema that isn't optional-out has to keep the key.
913
- if (!isPresent && isOptionalOut && optin === "optional") {
914
- return;
915
- }
916
- if (result.issues.length) {
917
- // For optional-in/out schemas, ignore errors on absent keys.
918
- if (optin !== undefined && isOptionalOut && !isPresent) {
919
- return;
920
- }
921
- final.issues.push(...util.prefixIssues(key, result.issues));
922
- }
923
- if (!isPresent && optin === undefined) {
924
- if (!result.issues.length) {
925
- final.issues.push({
926
- code: "invalid_type",
927
- expected: "nonoptional",
928
- input: undefined,
929
- path: [key],
930
- });
931
- }
932
- return;
933
- }
934
- if (result.value === undefined) {
935
- if (isPresent || (optin === "defaulted" && !isOptionalOut)) {
936
- final.value[key] = undefined;
937
- }
938
- }
939
- else {
940
- final.value[key] = result.value;
941
- }
942
- }
943
- // one shared instance; a fresh [] per schema cost 56 bytes retained
944
- const NO_SYMBOL_KEYS = [];
945
- function normalizeDef(def) {
946
- const keys = Object.keys(def.shape);
947
- const ownSymbols = Object.getOwnPropertySymbols(def.shape);
948
- const symbolKeys = ownSymbols.length ? ownSymbols : NO_SYMBOL_KEYS;
949
- // aliases `keys` when there are no symbols, so a string-only shape keeps one array
950
- const allKeys = symbolKeys.length ? [...keys, ...symbolKeys] : keys;
951
- for (const k of allKeys) {
952
- if (!def.shape?.[k]?._zod?.traits?.has("$ZodType")) {
953
- throw new Error(`Invalid element at key "${String(k)}": expected a Zod schema`);
954
- }
955
- }
956
- const okeys = util.optionalKeys(def.shape);
957
- return {
958
- ...def,
959
- allKeys,
960
- symbolKeys,
961
- // string-only: handleCatchall matches it against `for...in`, which never yields a symbol
962
- keySet: new Set(keys),
963
- numKeys: keys.length,
964
- optionalKeys: new Set(okeys),
965
- };
966
- }
967
- function handleCatchall(proms, input, payload, ctx, def, inst, abortEarly) {
968
- const unrecognized = [];
969
- const keySet = def.keySet;
970
- const _catchall = def.catchall._zod;
971
- const t = _catchall.def.type;
972
- const optin = _catchall.optin;
973
- const optout = _catchall.optout;
974
- // starts at 0, not the current length: the shape phase already ran and may have aborted
975
- let seen = 0;
976
- for (const key in input) {
977
- if (abortEarly && payload.issues.length !== seen) {
978
- if (util.aborted(payload, seen))
979
- break;
980
- seen = payload.issues.length;
981
- }
982
- // Must precede the __proto__ branch: a declared key is not unrecognized, even though the shape loop deliberately strips __proto__ from the parsed output.
983
- if (keySet.has(key))
984
- continue;
985
- // Don't copy an undeclared __proto__ into the result; assignment to a plain {} would replace the result prototype. But in strict mode it is still an unknown key, so report it before skipping.
986
- if (key === "__proto__") {
987
- if (t === "never")
988
- unrecognized.push(key);
989
- continue;
990
- }
991
- if (t === "never") {
992
- unrecognized.push(key);
993
- continue;
994
- }
995
- const r = _catchall.run({ value: input[key], issues: [] }, ctx);
996
- if (r instanceof Promise) {
997
- proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, optin, optout)));
998
- }
999
- else {
1000
- handlePropertyResult(r, payload, key, input, optin, optout);
1001
- }
1002
- }
1003
- if (unrecognized.length) {
1004
- payload.issues.push({
1005
- code: "unrecognized_keys",
1006
- keys: unrecognized,
1007
- input,
1008
- inst,
1009
- // Describes the shape of the input, not the validity of the parsed value, so it never aborts. The parse still fails; the schema's own checks just get to run first, and an enclosing intersection can reconcile the key against a sibling operand.
1010
- continue: true,
1011
- });
1012
- }
1013
- if (!proms.length)
1014
- return payload;
1015
- return Promise.all(proms).then(() => {
1016
- return payload;
1017
- });
1018
- }
1019
- exports.$ZodObject = core.$constructor("$ZodObject", (inst, def) => {
1020
- // requires cast because technically $ZodObject doesn't extend
1021
- exports.$ZodType.init(inst, def);
1022
- const desc = Object.getOwnPropertyDescriptor(def, "shape");
1023
- // a cloned def carries its source's accessor, which knows the shape it answers from; adopting that keeps the clone's keys readable without running it
1024
- const sh = desc?.get ? desc.get.raw : (def.shape ?? {});
1025
- if (sh) {
1026
- // Freezes the shape on first read, so its getters resolve once and every later read sees the same schemas.
1027
- const get = () => {
1028
- const newSh = { ...sh };
1029
- Object.defineProperty(def, "shape", { value: newSh });
1030
- get.raw = newSh;
1031
- return newSh;
1032
- };
1033
- get.raw = sh;
1034
- Object.defineProperty(def, "shape", { get });
1035
- }
1036
- const _normalized = util.cached(() => normalizeDef(def));
1037
- util.defineLazyInternal(inst, "propValues", (zod) => {
1038
- const shape = zod.def.shape;
1039
- const propValues = {};
1040
- for (const key in shape) {
1041
- const field = shape[key]._zod;
1042
- if (field.values) {
1043
- if (!Object.prototype.hasOwnProperty.call(propValues, key)) {
1044
- util.assignProp(propValues, key, new Set());
1045
- }
1046
- for (const v of field.values)
1047
- propValues[key].add(v);
1048
- // An omittable slot reads back as undefined at a discriminator lookup, so it has to claim undefined: two options that can both omit the key are not discriminable on it.
1049
- if (field.optin !== undefined)
1050
- propValues[key].add(undefined);
1051
- }
1052
- }
1053
- return propValues;
1054
- });
1055
- const isObject = util.isObject;
1056
- const catchall = def.catchall;
1057
- let value;
1058
- const memo = core.globalConfig.memoizer;
1059
- memo?.attach(inst);
1060
- inst._zod.parse = (payload, ctx) => {
1061
- value ?? (value = _normalized.value);
1062
- const input = payload.value;
1063
- if (!isObject(input)) {
1064
- payload.issues.push({
1065
- expected: "object",
1066
- code: "invalid_type",
1067
- input,
1068
- inst,
1069
- });
1070
- return payload;
1071
- }
1072
- payload.value = memo ? memo.alloc(inst, payload, {}, ctx) : {};
1073
- const proms = [];
1074
- const shape = value.shape;
1075
- const abortEarly = ctx?.abortEarly;
1076
- let seen = payload.issues.length;
1077
- for (const key of value.allKeys) {
1078
- if (abortEarly && payload.issues.length !== seen) {
1079
- if (util.aborted(payload, seen))
1080
- break;
1081
- seen = payload.issues.length;
1082
- }
1083
- if (key === "__proto__")
1084
- continue;
1085
- const el = shape[key];
1086
- const optin = el._zod.optin;
1087
- const optout = el._zod.optout;
1088
- const r = el._zod.run({ value: input[key], issues: [] }, ctx);
1089
- if (r instanceof Promise) {
1090
- proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, optin, optout)));
1091
- }
1092
- else {
1093
- handlePropertyResult(r, payload, key, input, optin, optout);
1094
- }
1095
- }
1096
- if (!catchall) {
1097
- return proms.length ? Promise.all(proms).then(() => payload) : payload;
1098
- }
1099
- return handleCatchall(proms, input, payload, ctx, _normalized.value, inst, abortEarly === true);
1100
- };
1101
- });
1102
- exports.$ZodObjectJIT = core.$constructor("$ZodObjectJIT", (inst, def) => {
1103
- // requires cast because technically $ZodObject doesn't extend
1104
- exports.$ZodObject.init(inst, def);
1105
- const superParse = inst._zod.parse;
1106
- const _normalized = util.cached(() => normalizeDef(def));
1107
- const memo = core.globalConfig.memoizer;
1108
- const generateFastpass = (shape) => {
1109
- const normalized = _normalized.value;
1110
- const syms = normalized.symbolKeys;
1111
- // a symbol has no source literal, so it is read as `syms[i]` off the closed-over scope
1112
- const doc = new doc_js_1.Doc(["payload", "ctx"], { shape, inst, memo, syms });
1113
- const parseStr = (k) => `shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`;
1114
- // prefixes in place, like util.prefixIssues. newResult must land before the early return: a catchall runs after this and would otherwise write onto the caller's input
1115
- const prefixStr = (id, k) => `
1116
- let ${id}_ab = false;
1117
- for (let i = 0; i < ${id}.issues.length; i++) {
1118
- const iss = ${id}.issues[i];
1119
- iss.path = iss.path ? [${k}, ...iss.path] : [${k}];
1120
- payload.issues.push(iss);
1121
- if (iss.continue !== true) ${id}_ab = true;
1122
- }
1123
- if (${id}_ab && ctx && ctx.abortEarly) {
1124
- payload.value = newResult;
1125
- return payload;
1126
- }`;
1127
- doc.write(`const input = payload.value;`);
1128
- const ids = Object.create(null);
1129
- let counter = 0;
1130
- for (const key of normalized.allKeys) {
1131
- ids[key] = `key_${counter++}`;
1132
- }
1133
- // A: preserve key order {
1134
- doc.write(memo ? `const newResult = memo.alloc(inst, payload, {}, ctx);` : `const newResult = {};`);
1135
- for (const key of normalized.allKeys) {
1136
- if (key === "__proto__")
1137
- continue;
1138
- const id = ids[key];
1139
- const k = typeof key === "symbol" ? `syms[${syms.indexOf(key)}]` : util.esc(key);
1140
- const isPresent = `${k} in input`;
1141
- const schema = shape[key];
1142
- const optin = schema?._zod?.optin;
1143
- const isOptionalIn = optin !== undefined;
1144
- const isOptionalOut = schema?._zod?.optout === "optional";
1145
- doc.write(`const ${id} = ${parseStr(k)};`);
1146
- if (isOptionalIn && isOptionalOut) {
1147
- // For optional-in/out schemas, ignore errors on absent keys — and, like the interpreted path, drop the value produced alongside them. The middle rung goes further: it permits absence without supplying anything in its place, so an absent key contributes nothing at all.
1148
- const assign = optin === "optional" ? `${id}_present` : `${id}.value !== undefined || ${id}_present`;
1149
- doc.write(`
1150
- const ${id}_present = ${isPresent};
1151
- if (!${id}.issues.length || ${id}_present) {
1152
- if (${id}.issues.length) {${prefixStr(id, k)}
1153
- }
1154
-
1155
- if (${assign}) {
1156
- newResult[${k}] = ${id}.value;
1157
- }
1158
- }
1159
-
1160
- `);
1161
- }
1162
- else if (!isOptionalIn) {
1163
- doc.write(`
1164
- const ${id}_present = ${isPresent};
1165
- if (${id}.issues.length) {${prefixStr(id, k)}
1166
- }
1167
- if (!${id}_present && !${id}.issues.length) {
1168
- payload.issues.push({
1169
- code: "invalid_type",
1170
- expected: "nonoptional",
1171
- input: undefined,
1172
- path: [${k}]
1173
- });
1174
- if (ctx && ctx.abortEarly) {
1175
- payload.value = newResult;
1176
- return payload;
1177
- }
1178
- }
1179
-
1180
- if (${id}_present) {
1181
- newResult[${k}] = ${id}.value;
1182
- }
1183
-
1184
- `);
1185
- }
1186
- else {
1187
- doc.write(`
1188
- if (${id}.issues.length) {${prefixStr(id, k)}
1189
- }
1190
- `);
1191
- if (optin === "defaulted") {
1192
- doc.write(`newResult[${k}] = ${id}.value;`);
1193
- }
1194
- else {
1195
- doc.write(`
1196
- if (${id}.value !== undefined || ${isPresent}) {
1197
- newResult[${k}] = ${id}.value;
1198
- }
1199
- `);
1200
- }
1201
- }
1202
- }
1203
- doc.write(`payload.value = newResult;`);
1204
- doc.write(`return payload;`);
1205
- // closing `shape` in is what pays: turbofan specializes the parser against that one shape object, so every `shape[k]._zod.run` folds to a known callee. as a parameter it stays a generic load and measures 13% slower even with the forwarding frame gone
1206
- return doc.compile();
1207
- };
1208
- let fastpass;
1209
- const isObject = util.isObject;
1210
- const jit = !core.globalConfig.jitless;
1211
- const allowsEval = util.allowsEval;
1212
- const fastEnabled = jit && allowsEval.value; // && !def.catchall;
1213
- const catchall = def.catchall;
1214
- let value;
1215
- inst._zod.parse = (payload, ctx) => {
1216
- value ?? (value = _normalized.value);
1217
- const input = payload.value;
1218
- if (!isObject(input)) {
1219
- payload.issues.push({
1220
- expected: "object",
1221
- code: "invalid_type",
1222
- input,
1223
- inst,
1224
- });
1225
- return payload;
1226
- }
1227
- if (jit && fastEnabled && ctx?.async === false && ctx.jitless !== true) {
1228
- // always synchronous
1229
- if (!fastpass)
1230
- fastpass = generateFastpass(def.shape);
1231
- payload = fastpass(payload, ctx);
1232
- if (!catchall)
1233
- return payload;
1234
- return handleCatchall([], input, payload, ctx, value, inst, ctx?.abortEarly === true);
1235
- }
1236
- return superParse(payload, ctx);
1237
- };
1238
- });
1239
- function handleUnionResults(results, final, inst, ctx) {
1240
- for (const result of results) {
1241
- if (result.issues.length === 0) {
1242
- final.value = result.value;
1243
- return final;
1244
- }
1245
- }
1246
- const nonaborted = results.filter((r) => !util.aborted(r));
1247
- if (nonaborted.length === 1) {
1248
- final.value = nonaborted[0].value;
1249
- return nonaborted[0];
1250
- }
1251
- final.issues.push({
1252
- code: "invalid_union",
1253
- input: final.value,
1254
- inst,
1255
- errors: results.map((result) => result.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config()))),
1256
- });
1257
- return final;
1258
- }
1259
- exports.$ZodUnion = core.$constructor("$ZodUnion", (inst, def) => {
1260
- exports.$ZodType.init(inst, def);
1261
- util.defineLazyInternal(inst, "optin", (zod) => zod.def.options.some((o) => o._zod.optin === "defaulted")
1262
- ? "defaulted"
1263
- : zod.def.options.some((o) => o._zod.optin !== undefined)
1264
- ? "optional"
1265
- : undefined);
1266
- util.defineLazyInternal(inst, "optout", (zod) => zod.def.options.some((o) => o._zod.optout === "optional") ? "optional" : undefined);
1267
- util.defineLazyInternal(inst, "values", (zod) => {
1268
- if (zod.def.options.every((o) => o._zod.values)) {
1269
- return new Set(zod.def.options.flatMap((option) => Array.from(option._zod.values)));
1270
- }
1271
- return undefined;
1272
- });
1273
- util.defineLazyInternal(inst, "pattern", (zod) => {
1274
- if (zod.def.options.every((o) => o._zod.pattern)) {
1275
- const patterns = zod.def.options.map((o) => o._zod.pattern);
1276
- return new RegExp(`^(${patterns.map((p) => util.cleanRegex(p.source)).join("|")})$`);
1277
- }
1278
- return undefined;
1279
- });
1280
- const first = def.options.length === 1 ? def.options[0]._zod.run : null;
1281
- inst._zod.parse = (payload, ctx) => {
1282
- if (first) {
1283
- return first(payload, ctx);
1284
- }
1285
- let async = false;
1286
- const results = [];
1287
- for (const option of def.options) {
1288
- const result = option._zod.run({
1289
- value: payload.value,
1290
- issues: [],
1291
- }, ctx);
1292
- if (result instanceof Promise) {
1293
- results.push(result);
1294
- async = true;
1295
- }
1296
- else {
1297
- if (result.issues.length === 0)
1298
- return result;
1299
- results.push(result);
1300
- }
1301
- }
1302
- if (!async)
1303
- return handleUnionResults(results, payload, inst, ctx);
1304
- return Promise.all(results).then((results) => {
1305
- return handleUnionResults(results, payload, inst, ctx);
1306
- });
1307
- };
1308
- });
1309
- function handleExclusiveUnionResults(results, final, inst, ctx) {
1310
- const matches = [];
1311
- for (let i = 0; i < results.length; i++) {
1312
- if (results[i].issues.length === 0)
1313
- matches.push(i);
1314
- }
1315
- if (matches.length === 1) {
1316
- final.value = results[matches[0]].value;
1317
- return final;
1318
- }
1319
- if (matches.length === 0) {
1320
- // No matches - same as regular union
1321
- final.issues.push({
1322
- code: "invalid_union",
1323
- input: final.value,
1324
- inst,
1325
- errors: results.map((result) => result.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config()))),
1326
- });
1327
- }
1328
- else {
1329
- // Multiple matches - exclusive union failure
1330
- final.issues.push({
1331
- code: "invalid_union",
1332
- input: final.value,
1333
- inst,
1334
- errors: [],
1335
- inclusive: false,
1336
- matches,
1337
- });
1338
- }
1339
- return final;
1340
- }
1341
- exports.$ZodXor = core.$constructor("$ZodXor", (inst, def) => {
1342
- exports.$ZodUnion.init(inst, def);
1343
- def.inclusive = false;
1344
- const first = def.options.length === 1 ? def.options[0]._zod.run : null;
1345
- inst._zod.parse = (payload, ctx) => {
1346
- if (first) {
1347
- return first(payload, ctx);
1348
- }
1349
- let async = false;
1350
- const results = [];
1351
- for (const option of def.options) {
1352
- const result = option._zod.run({
1353
- value: payload.value,
1354
- issues: [],
1355
- }, ctx);
1356
- if (result instanceof Promise) {
1357
- results.push(result);
1358
- async = true;
1359
- }
1360
- else {
1361
- results.push(result);
1362
- }
1363
- }
1364
- if (!async)
1365
- return handleExclusiveUnionResults(results, payload, inst, ctx);
1366
- return Promise.all(results).then((results) => {
1367
- return handleExclusiveUnionResults(results, payload, inst, ctx);
1368
- });
1369
- };
1370
- });
1371
- /** Returns the option whose discriminator claims `value`, or throws if ambiguous. */
1372
- function getDiscriminatedOption(union, value) {
1373
- const internals = union._zod;
1374
- let map = internals.bag.optionsMap;
1375
- if (!map) {
1376
- map = discriminatorMap(internals.def);
1377
- internals.bag.optionsMap = map;
1378
- }
1379
- const option = map.get(value);
1380
- if (option === null)
1381
- throw new Error(`Ambiguous discriminator value "${String(value)}"`);
1382
- return option;
1383
- }
1384
- function discriminatorMap(def) {
1385
- const map = new Map();
1386
- for (const option of def.options) {
1387
- const values = option._zod.propValues?.[def.discriminator];
1388
- if (!values || values.size === 0)
1389
- throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(option)}"`);
1390
- for (const value of values) {
1391
- if (map.has(value)) {
1392
- if (value !== undefined)
1393
- throw new Error(`Duplicate discriminator value "${String(value)}"`);
1394
- // keep the collision marked so a later member cannot reclaim it
1395
- map.set(value, null);
1396
- }
1397
- else {
1398
- map.set(value, option);
1399
- }
1400
- }
1401
- }
1402
- return map;
1403
- }
1404
- exports.$ZodDiscriminatedUnion =
1405
- /*@__PURE__*/
1406
- core.$constructor("$ZodDiscriminatedUnion", (inst, def) => {
1407
- def.inclusive = false;
1408
- exports.$ZodUnion.init(inst, def);
1409
- const _super = inst._zod.parse;
1410
- util.defineLazyInternal(inst, "propValues", (zod) => {
1411
- const propValues = {};
1412
- let undefinedCount = 0;
1413
- for (const option of zod.def.options) {
1414
- const pv = option._zod.propValues;
1415
- if (!pv || Object.keys(pv).length === 0)
1416
- throw new Error(`Invalid discriminated union option at index "${zod.def.options.indexOf(option)}"`);
1417
- if (pv[zod.def.discriminator]?.has(undefined))
1418
- undefinedCount++;
1419
- for (const [k, v] of Object.entries(pv)) {
1420
- if (!Object.prototype.hasOwnProperty.call(propValues, k)) {
1421
- util.assignProp(propValues, k, new Set());
1422
- }
1423
- for (const val of v) {
1424
- propValues[k].add(val);
1425
- }
1426
- }
1427
- }
1428
- if (!zod.def.unionFallback && undefinedCount > 1)
1429
- propValues[zod.def.discriminator]?.delete(undefined);
1430
- return propValues;
1431
- });
1432
- // Checked now rather than in the lookup map below, so an option that lacks the discriminator fails at the `discriminatedUnion` call instead of on the first object parsed. Options whose shape cannot be enumerated without resolving it — pipes and lazies — are left to the map.
1433
- def.options.forEach((option, i) => {
1434
- const propShape = util.rawShape(option._zod.def);
1435
- if (propShape && !Object.prototype.hasOwnProperty.call(propShape, def.discriminator)) {
1436
- throw new Error(`Invalid discriminated union option at index "${i}"`);
1437
- }
1438
- });
1439
- const disc = util.cached(() => discriminatorMap(def));
1440
- inst._zod.parse = (payload, ctx) => {
1441
- const input = payload.value;
1442
- if (!util.isObject(input)) {
1443
- payload.issues.push({
1444
- code: "invalid_type",
1445
- expected: "object",
1446
- input,
1447
- inst,
1448
- });
1449
- return payload;
1450
- }
1451
- const value = input?.[def.discriminator];
1452
- const opt = disc.value.get(value);
1453
- // forward metadata cannot choose an encoder for an absent tag
1454
- if (opt && (value !== undefined || ctx.direction !== "backward")) {
1455
- return opt._zod.run(payload, ctx);
1456
- }
1457
- // Fall back to union matching when the fast discriminator path fails:
1458
- // - explicitly enabled via unionFallback, or
1459
- // - during backward direction (encode), since codec-based discriminators have different values in forward vs backward directions
1460
- if (def.unionFallback || ctx.direction === "backward") {
1461
- return _super(payload, ctx);
1462
- }
1463
- // no matching discriminator
1464
- payload.issues.push({
1465
- code: "invalid_union",
1466
- errors: [],
1467
- note: "No matching discriminator",
1468
- discriminator: def.discriminator,
1469
- options: Array.from(disc.value.keys()).filter((value) => disc.value.get(value) !== null),
1470
- input,
1471
- path: [def.discriminator],
1472
- inst,
1473
- });
1474
- return payload;
1475
- };
1476
- });
1477
- exports.$ZodIntersection = core.$constructor("$ZodIntersection", (inst, def) => {
1478
- exports.$ZodType.init(inst, def);
1479
- inst._zod.parse = (payload, ctx) => {
1480
- const input = payload.value;
1481
- const left = def.left._zod.run({ value: input, issues: [] }, ctx);
1482
- const right = def.right._zod.run({ value: input, issues: [] }, ctx);
1483
- const async = left instanceof Promise || right instanceof Promise;
1484
- if (async) {
1485
- return Promise.all([left, right]).then(([left, right]) => {
1486
- return handleIntersectionResults(payload, left, right);
1487
- });
1488
- }
1489
- return handleIntersectionResults(payload, left, right);
1490
- };
1491
- });
1492
- function mergeValues(a, b) {
1493
- // const aType = parse.t(a);
1494
- // const bType = parse.t(b);
1495
- if (a === b) {
1496
- return { valid: true, data: a };
1497
- }
1498
- if (a instanceof Date && b instanceof Date && +a === +b) {
1499
- return { valid: true, data: a };
1500
- }
1501
- if (util.isPlainObject(a) && util.isPlainObject(b)) {
1502
- const bKeys = Object.keys(b);
1503
- const sharedKeys = Object.keys(a).filter((key) => bKeys.indexOf(key) !== -1);
1504
- const newObj = { ...a, ...b };
1505
- if (Object.prototype.hasOwnProperty.call(newObj, "__proto__"))
1506
- delete newObj.__proto__;
1507
- for (const key of sharedKeys) {
1508
- if (key === "__proto__")
1509
- continue;
1510
- const sharedValue = mergeValues(a[key], b[key]);
1511
- if (!sharedValue.valid) {
1512
- return {
1513
- valid: false,
1514
- mergeErrorPath: [key, ...sharedValue.mergeErrorPath],
1515
- };
1516
- }
1517
- newObj[key] = sharedValue.data;
1518
- }
1519
- return { valid: true, data: newObj };
1520
- }
1521
- if (Array.isArray(a) && Array.isArray(b)) {
1522
- if (a.length !== b.length) {
1523
- return { valid: false, mergeErrorPath: [] };
1524
- }
1525
- const newArray = [];
1526
- for (let index = 0; index < a.length; index++) {
1527
- const itemA = a[index];
1528
- const itemB = b[index];
1529
- const sharedValue = mergeValues(itemA, itemB);
1530
- if (!sharedValue.valid) {
1531
- return {
1532
- valid: false,
1533
- mergeErrorPath: [index, ...sharedValue.mergeErrorPath],
1534
- };
1535
- }
1536
- newArray.push(sharedValue.data);
1537
- }
1538
- return { valid: true, data: newArray };
1539
- }
1540
- return { valid: false, mergeErrorPath: [] };
1541
- }
1542
- function handleIntersectionResults(result, left, right) {
1543
- // Track which side(s) reject each key. A key rejection is reported only when BOTH sides reject it, so a key owned by one branch survives the other's key schema. strictObject reports these as unrecognized_keys; a record with an open key schema reports one invalid_key per key.
1544
- const unrecKeys = new Map();
1545
- let unrecIssue;
1546
- const keyIssues = new Map();
1547
- const collect = (iss, side) => {
1548
- let keys;
1549
- if (iss.code === "unrecognized_keys" && !iss.path?.length) {
1550
- unrecIssue ?? (unrecIssue = iss);
1551
- keys = iss.keys;
1552
- }
1553
- else if (iss.code === "invalid_key" && iss.origin === "record" && iss.path?.length === 1) {
1554
- const k = String(iss.path[0]);
1555
- if (!keyIssues.has(k))
1556
- keyIssues.set(k, iss);
1557
- keys = [k];
1558
- }
1559
- else {
1560
- return false;
1561
- }
1562
- for (const k of keys) {
1563
- if (!unrecKeys.has(k))
1564
- unrecKeys.set(k, {});
1565
- unrecKeys.get(k)[side] = true;
1566
- }
1567
- return true;
1568
- };
1569
- for (const iss of left.issues) {
1570
- if (!collect(iss, "l"))
1571
- result.issues.push(iss);
1572
- }
1573
- for (const iss of right.issues) {
1574
- if (!collect(iss, "r"))
1575
- result.issues.push(iss);
1576
- }
1577
- // Report only keys rejected by BOTH sides
1578
- const bothKeys = [...unrecKeys].filter(([, f]) => f.l && f.r).map(([k]) => k);
1579
- if (bothKeys.length) {
1580
- const aggregated = unrecIssue ? bothKeys.filter((k) => unrecIssue.keys.includes(k)) : [];
1581
- if (aggregated.length)
1582
- result.issues.push({ ...unrecIssue, keys: aggregated });
1583
- for (const k of bothKeys) {
1584
- if (!aggregated.includes(k) && keyIssues.has(k))
1585
- result.issues.push(keyIssues.get(k));
1586
- }
1587
- }
1588
- const merged = mergeValues(left.value, right.value);
1589
- if (!merged.valid) {
1590
- if (util.aborted(result))
1591
- return result;
1592
- throw new Error(`Unmergable intersection. Error path: ` + `${JSON.stringify(merged.mergeErrorPath)}`);
1593
- }
1594
- result.value = merged.data;
1595
- return result;
1596
- }
1597
- exports.$ZodTuple = core.$constructor("$ZodTuple", (inst, def) => {
1598
- exports.$ZodType.init(inst, def);
1599
- const items = def.items;
1600
- const memo = core.globalConfig.memoizer;
1601
- memo?.attach(inst);
1602
- inst._zod.parse = (payload, ctx) => {
1603
- const input = payload.value;
1604
- if (!Array.isArray(input)) {
1605
- payload.issues.push({
1606
- input,
1607
- inst,
1608
- expected: "tuple",
1609
- code: "invalid_type",
1610
- });
1611
- return payload;
1612
- }
1613
- payload.value = memo ? memo.alloc(inst, payload, [], ctx) : [];
1614
- const proms = [];
1615
- const optinStart = getTupleOptStart(items, "optin");
1616
- const optoutStart = getTupleOptStart(items, "optout");
1617
- if (!def.rest) {
1618
- if (input.length < optinStart) {
1619
- payload.issues.push({
1620
- code: "too_small",
1621
- minimum: optinStart,
1622
- inclusive: true,
1623
- input,
1624
- inst,
1625
- origin: "array",
1626
- });
1627
- return payload;
1628
- }
1629
- if (input.length > items.length) {
1630
- payload.issues.push({
1631
- code: "too_big",
1632
- maximum: items.length,
1633
- inclusive: true,
1634
- input,
1635
- inst,
1636
- origin: "array",
1637
- });
1638
- }
1639
- }
1640
- // Run every item in parallel, collecting results into an indexed array. The post-processing in `handleTupleResults` walks them in order so it can decide whether an absent optional-output error can truncate the tail or must be reported to preserve required output.
1641
- const itemResults = new Array(items.length);
1642
- // only tracked when there is a rest loop to skip
1643
- const abortEarly = def.rest ? ctx?.abortEarly : undefined;
1644
- let itemAborted = false;
1645
- for (let i = 0; i < items.length; i++) {
1646
- const r = items[i]._zod.run({ value: input[i], issues: [] }, ctx);
1647
- if (r instanceof Promise) {
1648
- proms.push(r.then((rr) => {
1649
- itemResults[i] = rr;
1650
- }));
1651
- }
1652
- else {
1653
- itemResults[i] = r;
1654
- if (abortEarly && !itemAborted && r.issues.length)
1655
- itemAborted = util.aborted(r);
1656
- }
1657
- }
1658
- // sound because rest is non-empty exactly when every fixed index is present, the one case handleTupleResults cannot discard an item's issues
1659
- if (def.rest && !itemAborted) {
1660
- let i = items.length - 1;
1661
- const rest = input.slice(items.length);
1662
- let seen = payload.issues.length;
1663
- for (const el of rest) {
1664
- if (abortEarly && payload.issues.length !== seen) {
1665
- if (util.aborted(payload, seen))
1666
- break;
1667
- seen = payload.issues.length;
1668
- }
1669
- i++;
1670
- const result = def.rest._zod.run({ value: el, issues: [] }, ctx);
1671
- if (result instanceof Promise) {
1672
- proms.push(result.then((r) => handleTupleResult(r, payload, i)));
1673
- }
1674
- else {
1675
- handleTupleResult(result, payload, i);
1676
- }
1677
- }
1678
- }
1679
- if (proms.length) {
1680
- return Promise.all(proms).then(() => handleTupleResults(itemResults, payload, items, input, optoutStart));
1681
- }
1682
- return handleTupleResults(itemResults, payload, items, input, optoutStart);
1683
- };
1684
- });
1685
- function getTupleOptStart(items, key) {
1686
- for (let i = items.length - 1; i >= 0; i--) {
1687
- // optin is a three-rung ladder so any rung above `undefined` permits an absent slot; optout stays two-valued.
1688
- const omittable = key === "optin" ? items[i]._zod.optin !== undefined : items[i]._zod.optout === "optional";
1689
- if (!omittable)
1690
- return i + 1;
1691
- }
1692
- return 0;
1693
- }
1694
- function handleTupleResult(result, final, index) {
1695
- if (result.issues.length) {
1696
- final.issues.push(...util.prefixIssues(index, result.issues));
1697
- }
1698
- final.value[index] = result.value;
1699
- }
1700
- function handleTupleResults(itemResults, final, items, input, optoutStart) {
1701
- // Walk results in order. Mirror $ZodObject's swallow-on-absent-optional rule, but only after `optoutStart`: the first index where the output tuple tail can be absent.
1702
- for (let i = 0; i < items.length; i++) {
1703
- const r = itemResults[i];
1704
- const isPresent = i < input.length;
1705
- // The array analog of `handlePropertyResult`'s absent-key early return: the middle rung permits absence without supplying anything in its place, so the tail truncates here instead of materializing whatever the item made of `undefined`.
1706
- if (!isPresent && i >= optoutStart && items[i]._zod.optin === "optional") {
1707
- final.value.length = i;
1708
- break;
1709
- }
1710
- if (r.issues.length) {
1711
- if (!isPresent && i >= optoutStart) {
1712
- final.value.length = i;
1713
- break;
1714
- }
1715
- final.issues.push(...util.prefixIssues(i, r.issues));
1716
- }
1717
- final.value[i] = r.value;
1718
- }
1719
- // Drop trailing slots that produced `undefined` for absent input
1720
- // (the array analog of an absent optional key on an object). The
1721
- // `i >= input.length` floor is critical: an explicit `undefined`
1722
- // *inside* the input must be preserved even when the schema is
1723
- // optional-out (e.g. `z.string().or(z.undefined())` accepting an
1724
- // explicit undefined value).
1725
- for (let i = final.value.length - 1; i >= input.length; i--) {
1726
- if (items[i]._zod.optout === "optional" && final.value[i] === undefined) {
1727
- final.value.length = i;
1728
- }
1729
- else {
1730
- break;
1731
- }
1732
- }
1733
- return final;
1734
- }
1735
- exports.$ZodRecord = core.$constructor("$ZodRecord", (inst, def) => {
1736
- exports.$ZodType.init(inst, def);
1737
- const memo = core.globalConfig.memoizer;
1738
- memo?.attach(inst);
1739
- inst._zod.parse = (payload, ctx) => {
1740
- const input = payload.value;
1741
- if (!util.isPlainObject(input)) {
1742
- payload.issues.push({
1743
- expected: "record",
1744
- code: "invalid_type",
1745
- input,
1746
- inst,
1747
- });
1748
- return payload;
1749
- }
1750
- // no guard in either loop below: a record's invalid_key aborts but an enclosing intersection can reconcile it, so a stopped loop hides keys the sibling does not own and the intersection then rejects nothing
1751
- const proms = [];
1752
- const values = def.keyType._zod.values;
1753
- if (values && !def.partial) {
1754
- payload.value = memo ? memo.alloc(inst, payload, {}, ctx) : {};
1755
- const recordKeys = new Set();
1756
- for (const key of values) {
1757
- if (typeof key === "string" || typeof key === "number" || typeof key === "symbol") {
1758
- recordKeys.add(typeof key === "number" ? key.toString() : key);
1759
- // A declared __proto__ is stripped but is not an unrecognized key.
1760
- if (key === "__proto__")
1761
- continue;
1762
- const keyResult = def.keyType._zod.run({ value: key, issues: [] }, ctx);
1763
- if (keyResult instanceof Promise) {
1764
- throw new Error("Async schemas not supported in object keys currently");
1765
- }
1766
- if (keyResult.issues.length) {
1767
- payload.issues.push({
1768
- code: "invalid_key",
1769
- origin: "record",
1770
- issues: keyResult.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())),
1771
- input: key,
1772
- path: [key],
1773
- inst,
1774
- });
1775
- continue;
1776
- }
1777
- const outKey = keyResult.value;
1778
- if (outKey === "__proto__")
1779
- continue;
1780
- const result = def.valueType._zod.run({ value: input[key], issues: [] }, ctx);
1781
- if (result instanceof Promise) {
1782
- proms.push(result.then((result) => {
1783
- if (result.issues.length) {
1784
- payload.issues.push(...util.prefixIssues(key, result.issues));
1785
- }
1786
- payload.value[outKey] = result.value;
1787
- }));
1788
- }
1789
- else {
1790
- if (result.issues.length) {
1791
- payload.issues.push(...util.prefixIssues(key, result.issues));
1792
- }
1793
- payload.value[outKey] = result.value;
1794
- }
1795
- }
1796
- }
1797
- let unrecognized;
1798
- for (const key in input) {
1799
- if (!recordKeys.has(key)) {
1800
- if (def.mode === "loose") {
1801
- // skip __proto__ so it can't replace the result prototype via the assignment setter on the plain {} we build into
1802
- if (key === "__proto__")
1803
- continue;
1804
- payload.value[key] = input[key];
1805
- }
1806
- else {
1807
- unrecognized = unrecognized ?? [];
1808
- unrecognized.push(key);
1809
- }
1810
- }
1811
- }
1812
- if (unrecognized && unrecognized.length > 0) {
1813
- payload.issues.push({
1814
- code: "unrecognized_keys",
1815
- input,
1816
- inst,
1817
- keys: unrecognized,
1818
- continue: true,
1819
- });
1820
- }
1821
- }
1822
- else {
1823
- payload.value = memo ? memo.alloc(inst, payload, {}, ctx) : {};
1824
- // An enumerable key schema declares which keys the record owns, so a key outside the set is unrecognized. A non-enumerable one (regex, refine) is a constraint every key must satisfy, so a failing key is invalid. Only the former is reconcilable against the other side of an intersection.
1825
- let unrecognized;
1826
- // Reflect.ownKeys for Symbol-key support; filter non-enumerable to match z.object()
1827
- for (const key of Reflect.ownKeys(input)) {
1828
- if (key === "__proto__")
1829
- continue;
1830
- if (!Object.prototype.propertyIsEnumerable.call(input, key))
1831
- continue;
1832
- let keyResult = def.keyType._zod.run({ value: key, issues: [] }, ctx);
1833
- if (keyResult instanceof Promise) {
1834
- throw new Error("Async schemas not supported in object keys currently");
1835
- }
1836
- // Numeric string fallback: if key is a numeric string and failed, retry with Number(key). This handles z.number(), z.literal([1, 2, 3]), and unions containing numeric literals
1837
- const checkNumericKey = typeof key === "string" && regexes.number.test(key) && keyResult.issues.length;
1838
- if (checkNumericKey) {
1839
- const retryResult = def.keyType._zod.run({ value: Number(key), issues: [] }, ctx);
1840
- if (retryResult instanceof Promise) {
1841
- throw new Error("Async schemas not supported in object keys currently");
1842
- }
1843
- if (retryResult.issues.length === 0) {
1844
- keyResult = retryResult;
1845
- }
1846
- }
1847
- if (keyResult.issues.length) {
1848
- if (def.mode === "loose") {
1849
- // Pass through unchanged
1850
- payload.value[key] = input[key];
1851
- }
1852
- else if (values) {
1853
- unrecognized = unrecognized ?? [];
1854
- unrecognized.push(key);
1855
- }
1856
- else {
1857
- // Default "strict" behavior: error on invalid key
1858
- payload.issues.push({
1859
- code: "invalid_key",
1860
- origin: "record",
1861
- issues: keyResult.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())),
1862
- input: key,
1863
- path: [key],
1864
- inst,
1865
- });
1866
- }
1867
- continue;
1868
- }
1869
- // the guard above tests the raw input key, but the key schema can normalize an ordinary key into __proto__; re-check the key we actually write under
1870
- const outKey = keyResult.value;
1871
- if (outKey === "__proto__")
1872
- continue;
1873
- const result = def.valueType._zod.run({ value: input[key], issues: [] }, ctx);
1874
- if (result instanceof Promise) {
1875
- proms.push(result.then((result) => {
1876
- if (result.issues.length) {
1877
- payload.issues.push(...util.prefixIssues(key, result.issues));
1878
- }
1879
- payload.value[outKey] = result.value;
1880
- }));
1881
- }
1882
- else {
1883
- if (result.issues.length) {
1884
- payload.issues.push(...util.prefixIssues(key, result.issues));
1885
- }
1886
- payload.value[outKey] = result.value;
1887
- }
1888
- }
1889
- if (unrecognized && unrecognized.length > 0) {
1890
- payload.issues.push({
1891
- code: "unrecognized_keys",
1892
- input,
1893
- inst,
1894
- keys: unrecognized,
1895
- continue: true,
1896
- });
1897
- }
1898
- }
1899
- if (proms.length) {
1900
- return Promise.all(proms).then(() => payload);
1901
- }
1902
- return payload;
1903
- };
1904
- });
1905
- exports.$ZodMap = core.$constructor("$ZodMap", (inst, def) => {
1906
- exports.$ZodType.init(inst, def);
1907
- const memo = core.globalConfig.memoizer;
1908
- memo?.attach(inst);
1909
- inst._zod.parse = (payload, ctx) => {
1910
- const input = payload.value;
1911
- if (!(input instanceof Map)) {
1912
- payload.issues.push({
1913
- expected: "map",
1914
- code: "invalid_type",
1915
- input,
1916
- inst,
1917
- });
1918
- return payload;
1919
- }
1920
- const proms = [];
1921
- payload.value = memo ? memo.alloc(inst, payload, new Map(), ctx) : new Map();
1922
- const abortEarly = ctx?.abortEarly;
1923
- let seen = payload.issues.length;
1924
- for (const [key, value] of input) {
1925
- if (abortEarly && payload.issues.length !== seen) {
1926
- if (util.aborted(payload, seen))
1927
- break;
1928
- seen = payload.issues.length;
1929
- }
1930
- const keyResult = def.keyType._zod.run({ value: key, issues: [] }, ctx);
1931
- const valueResult = def.valueType._zod.run({ value: value, issues: [] }, ctx);
1932
- if (keyResult instanceof Promise || valueResult instanceof Promise) {
1933
- proms.push(Promise.all([keyResult, valueResult]).then(([keyResult, valueResult]) => {
1934
- handleMapResult(keyResult, valueResult, payload, key, input, inst, ctx);
1935
- }));
1936
- }
1937
- else {
1938
- handleMapResult(keyResult, valueResult, payload, key, input, inst, ctx);
1939
- }
1940
- }
1941
- if (proms.length)
1942
- return Promise.all(proms).then(() => payload);
1943
- return payload;
1944
- };
1945
- });
1946
- function handleMapResult(keyResult, valueResult, final, key, input, inst, ctx) {
1947
- if (keyResult.issues.length) {
1948
- if (util.propertyKeyTypes.has(typeof key)) {
1949
- final.issues.push(...util.prefixIssues(key, keyResult.issues));
1950
- }
1951
- else {
1952
- final.issues.push({
1953
- code: "invalid_key",
1954
- origin: "map",
1955
- input,
1956
- inst,
1957
- issues: keyResult.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())),
1958
- });
1959
- }
1960
- }
1961
- if (valueResult.issues.length) {
1962
- if (util.propertyKeyTypes.has(typeof key)) {
1963
- final.issues.push(...util.prefixIssues(key, valueResult.issues));
1964
- }
1965
- else {
1966
- final.issues.push({
1967
- origin: "map",
1968
- code: "invalid_element",
1969
- input,
1970
- inst,
1971
- key: key,
1972
- issues: valueResult.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())),
1973
- });
1974
- }
1975
- }
1976
- final.value.set(keyResult.value, valueResult.value);
1977
- }
1978
- exports.$ZodSet = core.$constructor("$ZodSet", (inst, def) => {
1979
- exports.$ZodType.init(inst, def);
1980
- const memo = core.globalConfig.memoizer;
1981
- memo?.attach(inst);
1982
- inst._zod.parse = (payload, ctx) => {
1983
- const input = payload.value;
1984
- if (!(input instanceof Set)) {
1985
- payload.issues.push({
1986
- input,
1987
- inst,
1988
- expected: "set",
1989
- code: "invalid_type",
1990
- });
1991
- return payload;
1992
- }
1993
- const proms = [];
1994
- payload.value = memo ? memo.alloc(inst, payload, new Set(), ctx) : new Set();
1995
- const abortEarly = ctx?.abortEarly;
1996
- let seen = payload.issues.length;
1997
- for (const item of input) {
1998
- if (abortEarly && payload.issues.length !== seen) {
1999
- if (util.aborted(payload, seen))
2000
- break;
2001
- seen = payload.issues.length;
2002
- }
2003
- const result = def.valueType._zod.run({ value: item, issues: [] }, ctx);
2004
- if (result instanceof Promise) {
2005
- proms.push(result.then((result) => handleSetResult(result, payload)));
2006
- }
2007
- else
2008
- handleSetResult(result, payload);
2009
- }
2010
- if (proms.length)
2011
- return Promise.all(proms).then(() => payload);
2012
- return payload;
2013
- };
2014
- });
2015
- function handleSetResult(result, final) {
2016
- if (result.issues.length) {
2017
- final.issues.push(...result.issues);
2018
- }
2019
- final.value.add(result.value);
2020
- }
2021
- exports.$ZodEnum = core.$constructor("$ZodEnum", (inst, def) => {
2022
- exports.$ZodType.init(inst, def);
2023
- const values = util.getEnumValues(def.entries);
2024
- const valuesSet = new Set(values);
2025
- inst._zod.values = valuesSet;
2026
- util.defineLazyInternal(inst, "pattern", (zod) => {
2027
- const patternValues = util.getEnumValues(zod.def.entries).filter((k) => util.propertyKeyTypes.has(typeof k));
2028
- // unmatchable fallback, RE2-safe: an empty alternation would compile to /^()$/, which matches ""
2029
- return new RegExp(patternValues.length ? `^(${patternValues.map((o) => util.escapeRegex(o.toString())).join("|")})$` : "^[^\\s\\S]$");
2030
- });
2031
- inst._zod.parse = (payload, _ctx) => {
2032
- const input = payload.value;
2033
- if (valuesSet.has(input)) {
2034
- return payload;
2035
- }
2036
- payload.issues.push({
2037
- code: "invalid_value",
2038
- values,
2039
- input,
2040
- inst,
2041
- });
2042
- return payload;
2043
- };
2044
- });
2045
- exports.$ZodLiteral = core.$constructor("$ZodLiteral", (inst, def) => {
2046
- exports.$ZodType.init(inst, def);
2047
- const values = new Set(def.values);
2048
- inst._zod.values = values;
2049
- util.defineLazyInternal(inst, "pattern", (zod) => {
2050
- const vals = zod.def.values;
2051
- // unmatchable fallback, RE2-safe: an empty alternation would compile to /^()$/, which matches ""
2052
- return new RegExp(vals.length
2053
- ? `^(${vals
2054
- .map((o) => typeof o === "string" ? util.escapeRegex(o) : o ? util.escapeRegex(o.toString()) : String(o))
2055
- .join("|")})$`
2056
- : "^[^\\s\\S]$");
2057
- });
2058
- inst._zod.parse = (payload, _ctx) => {
2059
- const input = payload.value;
2060
- if (values.has(input)) {
2061
- return payload;
2062
- }
2063
- payload.issues.push({
2064
- code: "invalid_value",
2065
- values: def.values,
2066
- input,
2067
- inst,
2068
- });
2069
- return payload;
2070
- };
2071
- });
2072
- exports.$ZodFile = core.$constructor("$ZodFile", (inst, def) => {
2073
- exports.$ZodType.init(inst, def);
2074
- inst._zod.parse = (payload, _ctx) => {
2075
- const input = payload.value;
2076
- // @ts-ignore
2077
- if (input instanceof File)
2078
- return payload;
2079
- payload.issues.push({
2080
- expected: "file",
2081
- code: "invalid_type",
2082
- input,
2083
- inst,
2084
- });
2085
- return payload;
2086
- };
2087
- });
2088
- exports.$ZodTransform = core.$constructor("$ZodTransform", (inst, def) => {
2089
- exports.$ZodType.init(inst, def);
2090
- inst._zod.optin = "optional";
2091
- core.globalConfig.memoizer?.guard(inst);
2092
- inst._zod.parse = (payload, ctx) => {
2093
- if (ctx.direction === "backward") {
2094
- throw new core.$ZodEncodeError(inst.constructor.name);
2095
- }
2096
- const _out = def.transform(payload.value, payload);
2097
- if (ctx.async) {
2098
- const output = _out instanceof Promise ? _out : Promise.resolve(_out);
2099
- return output.then((output) => {
2100
- payload.value = output;
2101
- return payload;
2102
- });
2103
- }
2104
- if (_out instanceof Promise) {
2105
- throw new core.$ZodAsyncError();
2106
- }
2107
- payload.value = _out;
2108
- return payload;
2109
- };
2110
- });
2111
- function handleOptionalResult(payload, result) {
2112
- // A substituting schema that still failed has no usable answer; yield undefined. Its issues are simply dropped: it ran on a payload of its own, so there is no shared array to truncate and nothing of the caller's to lose with it.
2113
- payload.value = result.issues.length ? undefined : result.value;
2114
- return payload;
2115
- }
2116
- exports.$ZodOptional = core.$constructor("$ZodOptional", (inst, def) => {
2117
- exports.$ZodType.init(inst, def);
2118
- // .optional() propagates absence rather than substituting for it, so a defaulted inner keeps its rung.
2119
- util.defineLazyInternal(inst, "optin", (zod) => zod.def.innerType._zod.optin === "defaulted" ? "defaulted" : "optional");
2120
- inst._zod.optout = "optional";
2121
- util.defineLazyInternal(inst, "values", (zod) => {
2122
- const values = zod.def.innerType._zod.values;
2123
- return values ? new Set([...values, undefined]) : undefined;
2124
- });
2125
- util.defineLazyInternal(inst, "pattern", (zod) => {
2126
- const pattern = zod.def.innerType._zod.pattern;
2127
- return pattern ? new RegExp(`^(${util.cleanRegex(pattern.source)})?$`) : undefined;
2128
- });
2129
- inst._zod.parse = (payload, ctx) => {
2130
- if (payload.value === undefined) {
2131
- // Only the top rung substitutes a value for absence; everything else leaves it intact, which is what .optional() means.
2132
- if (def.innerType._zod.optin !== "defaulted")
2133
- return payload;
2134
- // Its own payload, for the same reason $ZodCatch gets one: a pipe forwards an unrecognized key through the caller's issues array, and this must not read that as the substituting schema failing and drop it.
2135
- const result = def.innerType._zod.run({ value: payload.value, issues: [] }, ctx);
2136
- if (result instanceof Promise)
2137
- return result.then((result) => handleOptionalResult(payload, result));
2138
- return handleOptionalResult(payload, result);
2139
- }
2140
- return def.innerType._zod.run(payload, ctx);
2141
- };
2142
- });
2143
- exports.$ZodExactOptional = core.$constructor("$ZodExactOptional", (inst, def) => {
2144
- // Call parent init - inherits optin/optout = "optional"
2145
- exports.$ZodOptional.init(inst, def);
2146
- // Override values/pattern to NOT add undefined
2147
- util.defineLazyInternal(inst, "values", (zod) => zod.def.innerType._zod.values);
2148
- util.defineLazyInternal(inst, "pattern", (zod) => zod.def.innerType._zod.pattern);
2149
- // Override parse to just delegate (no undefined handling)
2150
- inst._zod.parse = (payload, ctx) => {
2151
- return def.innerType._zod.run(payload, ctx);
2152
- };
2153
- });
2154
- exports.$ZodNullable = core.$constructor("$ZodNullable", (inst, def) => {
2155
- exports.$ZodType.init(inst, def);
2156
- util.defineLazyInternal(inst, "optin", (zod) => zod.def.innerType._zod.optin);
2157
- util.defineLazyInternal(inst, "optout", (zod) => zod.def.innerType._zod.optout);
2158
- util.defineLazyInternal(inst, "pattern", (zod) => {
2159
- const pattern = zod.def.innerType._zod.pattern;
2160
- return pattern ? new RegExp(`^(${util.cleanRegex(pattern.source)}|null)$`) : undefined;
2161
- });
2162
- util.defineLazyInternal(inst, "values", (zod) => {
2163
- return zod.def.innerType._zod.values ? new Set([...zod.def.innerType._zod.values, null]) : undefined;
2164
- });
2165
- inst._zod.parse = (payload, ctx) => {
2166
- // Forward direction (decode): allow null to pass through
2167
- if (payload.value === null)
2168
- return payload;
2169
- return def.innerType._zod.run(payload, ctx);
2170
- };
2171
- });
2172
- exports.$ZodDefault = core.$constructor("$ZodDefault", (inst, def) => {
2173
- exports.$ZodType.init(inst, def);
2174
- // inst._zod.qin = "true";
2175
- inst._zod.optin = "defaulted";
2176
- util.defineLazyInternal(inst, "values", (zod) => zod.def.innerType._zod.values);
2177
- inst._zod.parse = (payload, ctx) => {
2178
- if (ctx.direction === "backward") {
2179
- return def.innerType._zod.run(payload, ctx);
2180
- }
2181
- // Forward direction (decode): apply defaults for undefined input
2182
- if (payload.value === undefined) {
2183
- payload.value = def.defaultValue;
2184
- /**
2185
- * $ZodDefault returns the default value immediately in forward direction.
2186
- * It doesn't pass the default value into the validator ("prefault"). There's no reason to pass the default value through validation. The validity of the default is enforced by TypeScript statically. Otherwise, it's the responsibility of the user to ensure the default is valid. In the case of pipes with divergent in/out types, you can specify the default on the `in` schema of your ZodPipe to set a "prefault" for the pipe. */
2187
- return payload;
2188
- }
2189
- // Forward direction: continue with default handling
2190
- const result = def.innerType._zod.run(payload, ctx);
2191
- if (result instanceof Promise) {
2192
- return result.then((result) => handleDefaultResult(result, def));
2193
- }
2194
- return handleDefaultResult(result, def);
2195
- };
2196
- });
2197
- function handleDefaultResult(payload, def) {
2198
- if (payload.value === undefined) {
2199
- payload.value = def.defaultValue;
2200
- }
2201
- return payload;
2202
- }
2203
- exports.$ZodPrefault = core.$constructor("$ZodPrefault", (inst, def) => {
2204
- exports.$ZodType.init(inst, def);
2205
- inst._zod.optin = "defaulted";
2206
- util.defineLazyInternal(inst, "values", (zod) => zod.def.innerType._zod.values);
2207
- inst._zod.parse = (payload, ctx) => {
2208
- if (ctx.direction === "backward") {
2209
- return def.innerType._zod.run(payload, ctx);
2210
- }
2211
- // Forward direction (decode): apply prefault for undefined input
2212
- if (payload.value === undefined) {
2213
- payload.value = def.defaultValue;
2214
- }
2215
- return def.innerType._zod.run(payload, ctx);
2216
- };
2217
- });
2218
- exports.$ZodNonOptional = core.$constructor("$ZodNonOptional", (inst, def) => {
2219
- exports.$ZodType.init(inst, def);
2220
- util.defineLazyInternal(inst, "values", (zod) => {
2221
- const v = zod.def.innerType._zod.values;
2222
- return v ? new Set([...v].filter((x) => x !== undefined)) : undefined;
2223
- });
2224
- inst._zod.parse = (payload, ctx) => {
2225
- const result = def.innerType._zod.run(payload, ctx);
2226
- if (result instanceof Promise) {
2227
- return result.then((result) => handleNonOptionalResult(result, inst));
2228
- }
2229
- return handleNonOptionalResult(result, inst);
2230
- };
2231
- });
2232
- function handleNonOptionalResult(payload, inst) {
2233
- if (!payload.issues.length && payload.value === undefined) {
2234
- payload.issues.push({
2235
- code: "invalid_type",
2236
- expected: "nonoptional",
2237
- input: payload.value,
2238
- inst,
2239
- });
2240
- }
2241
- return payload;
2242
- }
2243
- exports.$ZodSuccess = core.$constructor("$ZodSuccess", (inst, def) => {
2244
- exports.$ZodType.init(inst, def);
2245
- inst._zod.parse = (payload, ctx) => {
2246
- if (ctx.direction === "backward") {
2247
- throw new core.$ZodEncodeError("ZodSuccess");
2248
- }
2249
- const result = def.innerType._zod.run(payload, ctx);
2250
- if (result instanceof Promise) {
2251
- return result.then((result) => {
2252
- payload.value = result.issues.length === 0;
2253
- return payload;
2254
- });
2255
- }
2256
- payload.value = result.issues.length === 0;
2257
- return payload;
2258
- };
2259
- });
2260
- function handleCatchResult(payload, result, def, ctx) {
2261
- if (!result.issues.length) {
2262
- payload.value = result.value;
2263
- // The value carries up, so the flag describing it has to carry with it: a back-edge into a node still being parsed must not be frozen by an enclosing readonly, and its checks belong to the node itself. Guarded so the ordinary case adds no own property.
2264
- if (result.memo)
2265
- payload.memo = true;
2266
- return payload;
2267
- }
2268
- // Spread the inner's own payload, not ours: `value` has to stay the input the catch was handed, and the inner ran on a payload of its own so its issues are already private to this call.
2269
- payload.value = def.catchValue({
2270
- ...result,
2271
- value: payload.value,
2272
- error: {
2273
- issues: result.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())),
2274
- },
2275
- input: payload.value,
2276
- });
2277
- return payload;
2278
- }
2279
- exports.$ZodCatch = core.$constructor("$ZodCatch", (inst, def) => {
2280
- exports.$ZodType.init(inst, def);
2281
- util.defineLazyInternal(inst, "optin", (zod) => zod.def.innerType._zod.optin === "defaulted" ? "defaulted" : "optional");
2282
- util.defineLazyInternal(inst, "optout", (zod) => zod.def.innerType._zod.optout);
2283
- util.defineLazyInternal(inst, "values", (zod) => zod.def.innerType._zod.values);
2284
- inst._zod.parse = (payload, ctx) => {
2285
- if (ctx.direction === "backward") {
2286
- return def.innerType._zod.run(payload, ctx);
2287
- }
2288
- // Forward direction (decode): apply catch logic
2289
- const result = def.innerType._zod.run({ value: payload.value, issues: [] }, ctx);
2290
- if (result instanceof Promise) {
2291
- return result.then((result) => handleCatchResult(payload, result, def, ctx));
2292
- }
2293
- return handleCatchResult(payload, result, def, ctx);
2294
- };
2295
- });
2296
- exports.$ZodNaN = core.$constructor("$ZodNaN", (inst, def) => {
2297
- exports.$ZodType.init(inst, def);
2298
- inst._zod.parse = (payload, _ctx) => {
2299
- if (typeof payload.value !== "number" || !Number.isNaN(payload.value)) {
2300
- payload.issues.push({
2301
- input: payload.value,
2302
- inst,
2303
- expected: "nan",
2304
- code: "invalid_type",
2305
- });
2306
- return payload;
2307
- }
2308
- return payload;
2309
- };
2310
- });
2311
- exports.$ZodPipe = core.$constructor("$ZodPipe", (inst, def) => {
2312
- exports.$ZodType.init(inst, def);
2313
- util.defineLazyInternal(inst, "values", (zod) => zod.def.in._zod.values);
2314
- util.defineLazyInternal(inst, "optin", (zod) => zod.def.in._zod.optin);
2315
- util.defineLazyInternal(inst, "optout", (zod) => zod.def.out._zod.optout);
2316
- util.defineLazyInternal(inst, "propValues", (zod) => zod.def.in._zod.propValues);
2317
- inst._zod.parse = (payload, ctx) => {
2318
- if (ctx.direction === "backward") {
2319
- const right = def.out._zod.run(payload, ctx);
2320
- if (right instanceof Promise) {
2321
- return right.then((right) => handlePipeResult(right, def.in, ctx));
2322
- }
2323
- return handlePipeResult(right, def.in, ctx);
2324
- }
2325
- const left = def.in._zod.run(payload, ctx);
2326
- if (left instanceof Promise) {
2327
- return left.then((left) => handlePipeResult(left, def.out, ctx));
2328
- }
2329
- return handlePipeResult(left, def.out, ctx);
2330
- };
2331
- });
2332
- function handlePipeResult(left, next, ctx) {
2333
- // Any issue stops the pipe, so a failing refinement never feeds its transform. An unrecognized key is the exception: it describes the input's extra properties, not the value being piped, and an enclosing intersection may yet reconcile it.
2334
- if (left.issues.some((iss) => iss.code !== "unrecognized_keys")) {
2335
- // prevent further checks
2336
- left.aborted = true;
2337
- return left;
2338
- }
2339
- return next._zod.run({ value: left.value, issues: left.issues }, ctx);
2340
- }
2341
- exports.$ZodCodec = core.$constructor("$ZodCodec", (inst, def) => {
2342
- exports.$ZodType.init(inst, def);
2343
- util.defineLazyInternal(inst, "values", (zod) => zod.def.in._zod.values);
2344
- util.defineLazyInternal(inst, "optin", (zod) => zod.def.in._zod.optin);
2345
- util.defineLazyInternal(inst, "optout", (zod) => zod.def.out._zod.optout);
2346
- util.defineLazyInternal(inst, "propValues", (zod) => zod.def.in._zod.propValues);
2347
- inst._zod.parse = (payload, ctx) => {
2348
- const direction = ctx.direction || "forward";
2349
- if (direction === "forward") {
2350
- const left = def.in._zod.run(payload, ctx);
2351
- if (left instanceof Promise) {
2352
- return left.then((left) => handleCodecAResult(left, def, ctx));
2353
- }
2354
- return handleCodecAResult(left, def, ctx);
2355
- }
2356
- else {
2357
- const right = def.out._zod.run(payload, ctx);
2358
- if (right instanceof Promise) {
2359
- return right.then((right) => handleCodecAResult(right, def, ctx));
2360
- }
2361
- return handleCodecAResult(right, def, ctx);
2362
- }
2363
- };
2364
- });
2365
- function handleCodecAResult(result, def, ctx) {
2366
- if (result.issues.length) {
2367
- // prevent further checks
2368
- result.aborted = true;
2369
- return result;
2370
- }
2371
- const direction = ctx.direction || "forward";
2372
- if (direction === "forward") {
2373
- const transformed = def.transform(result.value, result);
2374
- if (transformed instanceof Promise) {
2375
- return transformed.then((value) => handleCodecTxResult(result, value, def.out, ctx));
2376
- }
2377
- return handleCodecTxResult(result, transformed, def.out, ctx);
2378
- }
2379
- else {
2380
- const transformed = def.reverseTransform(result.value, result);
2381
- if (transformed instanceof Promise) {
2382
- return transformed.then((value) => handleCodecTxResult(result, value, def.in, ctx));
2383
- }
2384
- return handleCodecTxResult(result, transformed, def.in, ctx);
2385
- }
2386
- }
2387
- function handleCodecTxResult(left, value, nextSchema, ctx) {
2388
- // Check if transform added any issues
2389
- if (left.issues.length) {
2390
- left.aborted = true;
2391
- return left;
2392
- }
2393
- return nextSchema._zod.run({ value, issues: left.issues }, ctx);
2394
- }
2395
- exports.$ZodPreprocess = core.$constructor("$ZodPreprocess", (inst, def) => {
2396
- exports.$ZodPipe.init(inst, def);
2397
- });
2398
- exports.$ZodReadonly = core.$constructor("$ZodReadonly", (inst, def) => {
2399
- exports.$ZodType.init(inst, def);
2400
- util.defineLazyInternal(inst, "propValues", (zod) => zod.def.innerType._zod.propValues);
2401
- util.defineLazyInternal(inst, "values", (zod) => zod.def.innerType._zod.values);
2402
- util.defineLazyInternal(inst, "optin", (zod) => zod.def.innerType?._zod?.optin);
2403
- util.defineLazyInternal(inst, "optout", (zod) => zod.def.innerType?._zod?.optout);
2404
- inst._zod.parse = (payload, ctx) => {
2405
- if (ctx.direction === "backward") {
2406
- return def.innerType._zod.run(payload, ctx);
2407
- }
2408
- const result = def.innerType._zod.run(payload, ctx);
2409
- if (result instanceof Promise) {
2410
- return result.then(handleReadonlyResult);
2411
- }
2412
- return handleReadonlyResult(result);
2413
- };
2414
- });
2415
- function handleReadonlyResult(payload) {
2416
- // A repeat visit hands back a node that is still being built; freezing it here would make the rest of its keys fail to assign.
2417
- if (!payload.memo)
2418
- payload.value = Object.freeze(payload.value);
2419
- return payload;
2420
- }
2421
- // a leaf's pattern source with its own checks folded in: the last pattern-carrying check wins, else length bounds narrow the catch-all, else an integer format narrows the number form. the fold lives here instead of on `_zod.pattern` so a bundle without template literals never pays for it
2422
- function leafPattern(schema) {
2423
- const def = schema._zod.def;
2424
- let pattern = def.pattern;
2425
- let isInt = !!def.format?.includes("int");
2426
- let minimum;
2427
- let maximum;
2428
- for (const ch of def.checks ?? []) {
2429
- const d = ch._zod.def;
2430
- if (d.pattern)
2431
- pattern = d.pattern;
2432
- isInt || (isInt = !!d.format?.includes("int"));
2433
- const lo = d.minimum ?? d.length;
2434
- const hi = d.maximum ?? d.length;
2435
- if (lo !== undefined && (minimum === undefined || lo > minimum))
2436
- minimum = lo;
2437
- if (hi !== undefined && (maximum === undefined || hi < maximum))
2438
- maximum = hi;
2439
- }
2440
- if (pattern)
2441
- return pattern.source;
2442
- // an empty range matches nothing at runtime, and `{8,5}` is not a legal quantifier
2443
- if (minimum !== undefined && maximum !== undefined && minimum > maximum)
2444
- return "(?!)";
2445
- if (minimum !== undefined || maximum !== undefined)
2446
- return regexes.string({ minimum, maximum }).source;
2447
- const own = schema._zod.pattern;
2448
- return (isInt && own === regexes.number ? regexes.integer : own)?.source;
2449
- }
2450
- // a part's pattern source. a wrapper's pattern embeds its inner pattern's source verbatim, so the folded form is substituted in place without knowing the wrapper's own composition; a union's options are joined the way the union builds its own pattern
2451
- function partPattern(schema) {
2452
- const def = schema._zod.def;
2453
- const own = schema._zod.pattern?.source;
2454
- // lazy resolves its inner on the internals, not the def
2455
- const inner = def.innerType ?? schema._zod.innerType;
2456
- if (inner) {
2457
- const before = inner._zod.pattern?.source;
2458
- const after = partPattern(inner);
2459
- if (own && before && after && after !== before) {
2460
- return own.replace(util.cleanRegex(before), () => util.cleanRegex(after));
2461
- }
2462
- return own;
2463
- }
2464
- if (def.options) {
2465
- const sources = def.options.map(partPattern);
2466
- if (sources.every(Boolean))
2467
- return `^(${sources.map((s) => util.cleanRegex(s)).join("|")})$`;
2468
- }
2469
- return leafPattern(schema);
2470
- }
2471
- exports.$ZodTemplateLiteral = core.$constructor("$ZodTemplateLiteral", (inst, def) => {
2472
- exports.$ZodType.init(inst, def);
2473
- const regexParts = [];
2474
- for (const part of def.parts) {
2475
- if (typeof part === "object" && part !== null) {
2476
- // is Zod schema
2477
- const source = partPattern(part);
2478
- if (!source) {
2479
- throw new Error(`Invalid template literal part, no pattern found: ${[...part._zod.traits].shift()}`);
2480
- }
2481
- regexParts.push(util.cleanRegex(source));
2482
- }
2483
- else if (part === null || util.primitiveTypes.has(typeof part)) {
2484
- regexParts.push(util.escapeRegex(`${part}`));
2485
- }
2486
- else {
2487
- throw new Error(`Invalid template literal part: ${part}`);
2488
- }
2489
- }
2490
- inst._zod.pattern = new RegExp(`^${regexParts.join("")}$`);
2491
- inst._zod.parse = (payload, _ctx) => {
2492
- if (typeof payload.value !== "string") {
2493
- payload.issues.push({
2494
- input: payload.value,
2495
- inst,
2496
- expected: "string",
2497
- code: "invalid_type",
2498
- });
2499
- return payload;
2500
- }
2501
- inst._zod.pattern.lastIndex = 0;
2502
- if (!inst._zod.pattern.test(payload.value)) {
2503
- payload.issues.push({
2504
- input: payload.value,
2505
- inst,
2506
- code: "invalid_format",
2507
- format: def.format ?? "template_literal",
2508
- pattern: inst._zod.pattern.source,
2509
- });
2510
- return payload;
2511
- }
2512
- return payload;
2513
- };
2514
- });
2515
- exports.$ZodFunction = core.$constructor("$ZodFunction", (inst, def) => {
2516
- exports.$ZodType.init(inst, def);
2517
- // Defined, not assigned: the classic prototype exposes `_def` as a getter with no setter.
2518
- Object.defineProperty(inst, "_def", { value: def });
2519
- inst._zod.def = def;
2520
- inst.implement = (func) => {
2521
- if (typeof func !== "function") {
2522
- throw new Error("implement() must be called with a function");
2523
- }
2524
- // Defined inline so the closure stays anonymous: binding it to a `const` first names it, which costs 256 bytes per implemented function.
2525
- return Object.defineProperty(function (...args) {
2526
- const parsedArgs = inst._def.input ? (0, parse_js_1.parse)(inst._def.input, args) : args;
2527
- const result = Reflect.apply(func, this, parsedArgs);
2528
- if (inst._def.output) {
2529
- return (0, parse_js_1.parse)(inst._def.output, result);
2530
- }
2531
- return result;
2532
- }, "_zod", { value: inst._zod, enumerable: false });
2533
- };
2534
- inst.implementAsync = (func) => {
2535
- if (typeof func !== "function") {
2536
- throw new Error("implementAsync() must be called with a function");
2537
- }
2538
- return Object.defineProperty(async function (...args) {
2539
- const parsedArgs = inst._def.input ? await (0, parse_js_1.parseAsync)(inst._def.input, args) : args;
2540
- const result = await Reflect.apply(func, this, parsedArgs);
2541
- if (inst._def.output) {
2542
- return await (0, parse_js_1.parseAsync)(inst._def.output, result);
2543
- }
2544
- return result;
2545
- }, "_zod", { value: inst._zod, enumerable: false });
2546
- };
2547
- inst._zod.parse = (payload, _ctx) => {
2548
- if (typeof payload.value !== "function") {
2549
- payload.issues.push({
2550
- code: "invalid_type",
2551
- expected: "function",
2552
- input: payload.value,
2553
- inst,
2554
- });
2555
- return payload;
2556
- }
2557
- // Check if output is a promise type to determine if we should use async implementation
2558
- const hasPromiseOutput = inst._def.output && inst._def.output._zod.def.type === "promise";
2559
- if (hasPromiseOutput) {
2560
- payload.value = inst.implementAsync(payload.value);
2561
- }
2562
- else {
2563
- payload.value = inst.implement(payload.value);
2564
- }
2565
- return payload;
2566
- };
2567
- inst.input = (...args) => {
2568
- const F = inst.constructor;
2569
- if (Array.isArray(args[0])) {
2570
- return new F({
2571
- type: "function",
2572
- input: new exports.$ZodTuple({
2573
- type: "tuple",
2574
- items: args[0],
2575
- rest: args[1],
2576
- }),
2577
- output: inst._def.output,
2578
- });
2579
- }
2580
- return new F({
2581
- type: "function",
2582
- input: args[0],
2583
- output: inst._def.output,
2584
- });
2585
- };
2586
- inst.output = (output) => {
2587
- const F = inst.constructor;
2588
- return new F({
2589
- type: "function",
2590
- input: inst._def.input,
2591
- output,
2592
- });
2593
- };
2594
- return inst;
2595
- });
2596
- exports.$ZodPromise = core.$constructor("$ZodPromise", (inst, def) => {
2597
- exports.$ZodType.init(inst, def);
2598
- inst._zod.parse = (payload, ctx) => {
2599
- return Promise.resolve(payload.value).then((inner) => def.innerType._zod.run({ value: inner, issues: [] }, ctx));
2600
- };
2601
- });
2602
- exports.$ZodLazy = core.$constructor("$ZodLazy", (inst, def) => {
2603
- exports.$ZodType.init(inst, def);
2604
- // Cache the resolved inner type on the shared `def` so all clones of this lazy (e.g. via `.describe()`/`.meta()`) share the same inner instance, preserving identity for cycle detection on recursive schemas.
2605
- util.defineLazy(inst._zod, "innerType", () => {
2606
- const d = def;
2607
- if (!d._cachedInner)
2608
- d._cachedInner = def.getter();
2609
- return d._cachedInner;
2610
- });
2611
- util.defineLazyInternal(inst, "pattern", (zod) => zod.innerType?._zod?.pattern);
2612
- util.defineLazyInternal(inst, "propValues", (zod) => zod.innerType?._zod?.propValues);
2613
- util.defineLazyInternal(inst, "optin", (zod) => zod.innerType?._zod?.optin ?? undefined);
2614
- util.defineLazyInternal(inst, "optout", (zod) => zod.innerType?._zod?.optout ?? undefined);
2615
- inst._zod.parse = (payload, ctx) => {
2616
- const inner = inst._zod.innerType;
2617
- return inner._zod.run(payload, ctx);
2618
- };
2619
- });
2620
- exports.$ZodCustom = core.$constructor("$ZodCustom", (inst, def) => {
2621
- checks.$ZodCheck.init(inst, def);
2622
- exports.$ZodType.init(inst, def);
2623
- inst._zod.parse = (payload, _) => {
2624
- return payload;
2625
- };
2626
- inst._zod.check = (payload) => {
2627
- const input = payload.value;
2628
- const r = def.fn(input);
2629
- if (r instanceof Promise) {
2630
- return r.then((r) => handleRefineResult(r, payload, input, inst));
2631
- }
2632
- handleRefineResult(r, payload, input, inst);
2633
- return;
2634
- };
2635
- });
2636
- function handleRefineResult(result, payload, input, inst) {
2637
- if (!result) {
2638
- const _iss = {
2639
- code: "custom",
2640
- input,
2641
- inst, // incorporates params.error into issue reporting
2642
- path: [...(inst._zod.def.path ?? [])], // incorporates params.error into issue reporting
2643
- continue: !inst._zod.def.abort,
2644
- // params: inst._zod.def.params,
2645
- };
2646
- if (inst._zod.def.params)
2647
- _iss.params = inst._zod.def.params;
2648
- payload.issues.push(util.issue(_iss));
2649
- }
2650
- }
2651
-
2652
- // seal-cjs-exports
2653
- (function () {
2654
- var keys = Object.getOwnPropertyNames(exports);
2655
- for (var i = 0; i < keys.length; i++) {
2656
- var desc = Object.getOwnPropertyDescriptor(exports, keys[i]);
2657
- if (!desc || !desc.get || !desc.configurable) continue;
2658
- var value;
2659
- try {
2660
- value = desc.get();
2661
- } catch (e) {
2662
- continue;
2663
- }
2664
- // a circular require may not have settled this one yet, so leave it live
2665
- if (value === undefined) continue;
2666
- Object.defineProperty(exports, keys[i], { value: value, writable: false, enumerable: desc.enumerable, configurable: false });
2667
- }
2668
- Object.freeze(exports);
2669
- })();