claude-scope 0.1.6 → 0.1.8

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 (747) hide show
  1. package/dist/data/stdin-provider.d.ts +1 -1
  2. package/dist/data/stdin-provider.d.ts.map +1 -1
  3. package/dist/data/stdin-provider.js +7 -18
  4. package/dist/data/stdin-provider.js.map +1 -1
  5. package/dist/schemas/stdin-schema.d.ts +80 -119
  6. package/dist/schemas/stdin-schema.d.ts.map +1 -1
  7. package/dist/schemas/stdin-schema.js +35 -68
  8. package/dist/schemas/stdin-schema.js.map +1 -1
  9. package/dist/validation/combinators.d.ts +10 -0
  10. package/dist/validation/combinators.d.ts.map +1 -0
  11. package/dist/validation/combinators.js +49 -0
  12. package/dist/validation/combinators.js.map +1 -0
  13. package/dist/validation/core.d.ts +30 -0
  14. package/dist/validation/core.d.ts.map +1 -0
  15. package/dist/validation/core.js +2 -0
  16. package/dist/validation/core.js.map +1 -0
  17. package/dist/validation/index.d.ts +4 -0
  18. package/dist/validation/index.d.ts.map +1 -0
  19. package/dist/validation/index.js +4 -0
  20. package/dist/validation/index.js.map +1 -0
  21. package/dist/validation/result.d.ts +5 -0
  22. package/dist/validation/result.d.ts.map +1 -0
  23. package/dist/validation/result.js +11 -0
  24. package/dist/validation/result.js.map +1 -0
  25. package/dist/validation/validators.d.ts +7 -0
  26. package/dist/validation/validators.d.ts.map +1 -0
  27. package/dist/validation/validators.js +41 -0
  28. package/dist/validation/validators.js.map +1 -0
  29. package/package.json +4 -6
  30. package/dist/core/stdin-data-widget.d.ts +0 -85
  31. package/dist/core/stdin-data-widget.d.ts.map +0 -1
  32. package/dist/core/stdin-data-widget.js +0 -75
  33. package/dist/core/stdin-data-widget.js.map +0 -1
  34. package/dist/providers/stdin-provider.d.ts +0 -44
  35. package/dist/providers/stdin-provider.d.ts.map +0 -1
  36. package/dist/providers/stdin-provider.js +0 -83
  37. package/dist/providers/stdin-provider.js.map +0 -1
  38. package/dist/utils/colors.d.ts +0 -52
  39. package/dist/utils/colors.d.ts.map +0 -1
  40. package/dist/utils/colors.js +0 -54
  41. package/dist/utils/colors.js.map +0 -1
  42. package/dist/utils/formatters.d.ts +0 -56
  43. package/dist/utils/formatters.d.ts.map +0 -1
  44. package/dist/utils/formatters.js +0 -114
  45. package/dist/utils/formatters.js.map +0 -1
  46. package/dist/widgets/git-changes-widget.d.ts +0 -16
  47. package/dist/widgets/git-changes-widget.d.ts.map +0 -1
  48. package/dist/widgets/git-changes-widget.js +0 -37
  49. package/dist/widgets/git-changes-widget.js.map +0 -1
  50. package/dist/widgets/git-widget.d.ts +0 -35
  51. package/dist/widgets/git-widget.d.ts.map +0 -1
  52. package/dist/widgets/git-widget.js +0 -51
  53. package/dist/widgets/git-widget.js.map +0 -1
  54. package/node_modules/zod/LICENSE +0 -21
  55. package/node_modules/zod/README.md +0 -208
  56. package/node_modules/zod/index.cjs +0 -33
  57. package/node_modules/zod/index.d.cts +0 -4
  58. package/node_modules/zod/index.d.ts +0 -4
  59. package/node_modules/zod/index.js +0 -4
  60. package/node_modules/zod/locales/index.cjs +0 -17
  61. package/node_modules/zod/locales/index.d.cts +0 -1
  62. package/node_modules/zod/locales/index.d.ts +0 -1
  63. package/node_modules/zod/locales/index.js +0 -1
  64. package/node_modules/zod/locales/package.json +0 -6
  65. package/node_modules/zod/mini/index.cjs +0 -17
  66. package/node_modules/zod/mini/index.d.cts +0 -1
  67. package/node_modules/zod/mini/index.d.ts +0 -1
  68. package/node_modules/zod/mini/index.js +0 -1
  69. package/node_modules/zod/mini/package.json +0 -6
  70. package/node_modules/zod/package.json +0 -135
  71. package/node_modules/zod/src/index.ts +0 -4
  72. package/node_modules/zod/src/locales/index.ts +0 -1
  73. package/node_modules/zod/src/mini/index.ts +0 -1
  74. package/node_modules/zod/src/v3/ZodError.ts +0 -330
  75. package/node_modules/zod/src/v3/benchmarks/datetime.ts +0 -58
  76. package/node_modules/zod/src/v3/benchmarks/discriminatedUnion.ts +0 -80
  77. package/node_modules/zod/src/v3/benchmarks/index.ts +0 -59
  78. package/node_modules/zod/src/v3/benchmarks/ipv4.ts +0 -57
  79. package/node_modules/zod/src/v3/benchmarks/object.ts +0 -69
  80. package/node_modules/zod/src/v3/benchmarks/primitives.ts +0 -162
  81. package/node_modules/zod/src/v3/benchmarks/realworld.ts +0 -63
  82. package/node_modules/zod/src/v3/benchmarks/string.ts +0 -55
  83. package/node_modules/zod/src/v3/benchmarks/union.ts +0 -80
  84. package/node_modules/zod/src/v3/errors.ts +0 -13
  85. package/node_modules/zod/src/v3/external.ts +0 -6
  86. package/node_modules/zod/src/v3/helpers/enumUtil.ts +0 -17
  87. package/node_modules/zod/src/v3/helpers/errorUtil.ts +0 -8
  88. package/node_modules/zod/src/v3/helpers/parseUtil.ts +0 -176
  89. package/node_modules/zod/src/v3/helpers/partialUtil.ts +0 -34
  90. package/node_modules/zod/src/v3/helpers/typeAliases.ts +0 -2
  91. package/node_modules/zod/src/v3/helpers/util.ts +0 -224
  92. package/node_modules/zod/src/v3/index.ts +0 -4
  93. package/node_modules/zod/src/v3/locales/en.ts +0 -124
  94. package/node_modules/zod/src/v3/standard-schema.ts +0 -113
  95. package/node_modules/zod/src/v3/tests/Mocker.ts +0 -54
  96. package/node_modules/zod/src/v3/tests/all-errors.test.ts +0 -157
  97. package/node_modules/zod/src/v3/tests/anyunknown.test.ts +0 -28
  98. package/node_modules/zod/src/v3/tests/array.test.ts +0 -71
  99. package/node_modules/zod/src/v3/tests/async-parsing.test.ts +0 -388
  100. package/node_modules/zod/src/v3/tests/async-refinements.test.ts +0 -46
  101. package/node_modules/zod/src/v3/tests/base.test.ts +0 -29
  102. package/node_modules/zod/src/v3/tests/bigint.test.ts +0 -55
  103. package/node_modules/zod/src/v3/tests/branded.test.ts +0 -53
  104. package/node_modules/zod/src/v3/tests/catch.test.ts +0 -220
  105. package/node_modules/zod/src/v3/tests/coerce.test.ts +0 -133
  106. package/node_modules/zod/src/v3/tests/complex.test.ts +0 -70
  107. package/node_modules/zod/src/v3/tests/custom.test.ts +0 -31
  108. package/node_modules/zod/src/v3/tests/date.test.ts +0 -32
  109. package/node_modules/zod/src/v3/tests/deepmasking.test.ts +0 -186
  110. package/node_modules/zod/src/v3/tests/default.test.ts +0 -112
  111. package/node_modules/zod/src/v3/tests/description.test.ts +0 -33
  112. package/node_modules/zod/src/v3/tests/discriminated-unions.test.ts +0 -315
  113. package/node_modules/zod/src/v3/tests/enum.test.ts +0 -80
  114. package/node_modules/zod/src/v3/tests/error.test.ts +0 -551
  115. package/node_modules/zod/src/v3/tests/firstparty.test.ts +0 -87
  116. package/node_modules/zod/src/v3/tests/firstpartyschematypes.test.ts +0 -21
  117. package/node_modules/zod/src/v3/tests/function.test.ts +0 -261
  118. package/node_modules/zod/src/v3/tests/generics.test.ts +0 -48
  119. package/node_modules/zod/src/v3/tests/instanceof.test.ts +0 -37
  120. package/node_modules/zod/src/v3/tests/intersection.test.ts +0 -110
  121. package/node_modules/zod/src/v3/tests/language-server.source.ts +0 -76
  122. package/node_modules/zod/src/v3/tests/language-server.test.ts +0 -207
  123. package/node_modules/zod/src/v3/tests/literal.test.ts +0 -36
  124. package/node_modules/zod/src/v3/tests/map.test.ts +0 -110
  125. package/node_modules/zod/src/v3/tests/masking.test.ts +0 -4
  126. package/node_modules/zod/src/v3/tests/mocker.test.ts +0 -19
  127. package/node_modules/zod/src/v3/tests/nan.test.ts +0 -24
  128. package/node_modules/zod/src/v3/tests/nativeEnum.test.ts +0 -87
  129. package/node_modules/zod/src/v3/tests/nullable.test.ts +0 -42
  130. package/node_modules/zod/src/v3/tests/number.test.ts +0 -176
  131. package/node_modules/zod/src/v3/tests/object-augmentation.test.ts +0 -29
  132. package/node_modules/zod/src/v3/tests/object-in-es5-env.test.ts +0 -29
  133. package/node_modules/zod/src/v3/tests/object.test.ts +0 -434
  134. package/node_modules/zod/src/v3/tests/optional.test.ts +0 -42
  135. package/node_modules/zod/src/v3/tests/parseUtil.test.ts +0 -23
  136. package/node_modules/zod/src/v3/tests/parser.test.ts +0 -41
  137. package/node_modules/zod/src/v3/tests/partials.test.ts +0 -243
  138. package/node_modules/zod/src/v3/tests/pickomit.test.ts +0 -111
  139. package/node_modules/zod/src/v3/tests/pipeline.test.ts +0 -29
  140. package/node_modules/zod/src/v3/tests/preprocess.test.ts +0 -186
  141. package/node_modules/zod/src/v3/tests/primitive.test.ts +0 -440
  142. package/node_modules/zod/src/v3/tests/promise.test.ts +0 -90
  143. package/node_modules/zod/src/v3/tests/readonly.test.ts +0 -194
  144. package/node_modules/zod/src/v3/tests/record.test.ts +0 -171
  145. package/node_modules/zod/src/v3/tests/recursive.test.ts +0 -197
  146. package/node_modules/zod/src/v3/tests/refine.test.ts +0 -313
  147. package/node_modules/zod/src/v3/tests/safeparse.test.ts +0 -27
  148. package/node_modules/zod/src/v3/tests/set.test.ts +0 -142
  149. package/node_modules/zod/src/v3/tests/standard-schema.test.ts +0 -83
  150. package/node_modules/zod/src/v3/tests/string.test.ts +0 -916
  151. package/node_modules/zod/src/v3/tests/transformer.test.ts +0 -233
  152. package/node_modules/zod/src/v3/tests/tuple.test.ts +0 -90
  153. package/node_modules/zod/src/v3/tests/unions.test.ts +0 -57
  154. package/node_modules/zod/src/v3/tests/validations.test.ts +0 -133
  155. package/node_modules/zod/src/v3/tests/void.test.ts +0 -15
  156. package/node_modules/zod/src/v3/types.ts +0 -5138
  157. package/node_modules/zod/src/v4/classic/checks.ts +0 -32
  158. package/node_modules/zod/src/v4/classic/coerce.ts +0 -27
  159. package/node_modules/zod/src/v4/classic/compat.ts +0 -70
  160. package/node_modules/zod/src/v4/classic/errors.ts +0 -82
  161. package/node_modules/zod/src/v4/classic/external.ts +0 -51
  162. package/node_modules/zod/src/v4/classic/from-json-schema.ts +0 -643
  163. package/node_modules/zod/src/v4/classic/index.ts +0 -5
  164. package/node_modules/zod/src/v4/classic/iso.ts +0 -90
  165. package/node_modules/zod/src/v4/classic/parse.ts +0 -82
  166. package/node_modules/zod/src/v4/classic/schemas.ts +0 -2409
  167. package/node_modules/zod/src/v4/classic/tests/anyunknown.test.ts +0 -26
  168. package/node_modules/zod/src/v4/classic/tests/apply.test.ts +0 -59
  169. package/node_modules/zod/src/v4/classic/tests/array.test.ts +0 -264
  170. package/node_modules/zod/src/v4/classic/tests/assignability.test.ts +0 -210
  171. package/node_modules/zod/src/v4/classic/tests/async-parsing.test.ts +0 -381
  172. package/node_modules/zod/src/v4/classic/tests/async-refinements.test.ts +0 -68
  173. package/node_modules/zod/src/v4/classic/tests/base.test.ts +0 -7
  174. package/node_modules/zod/src/v4/classic/tests/bigint.test.ts +0 -54
  175. package/node_modules/zod/src/v4/classic/tests/brand.test.ts +0 -106
  176. package/node_modules/zod/src/v4/classic/tests/catch.test.ts +0 -276
  177. package/node_modules/zod/src/v4/classic/tests/coalesce.test.ts +0 -20
  178. package/node_modules/zod/src/v4/classic/tests/codec-examples.test.ts +0 -573
  179. package/node_modules/zod/src/v4/classic/tests/codec.test.ts +0 -562
  180. package/node_modules/zod/src/v4/classic/tests/coerce.test.ts +0 -160
  181. package/node_modules/zod/src/v4/classic/tests/continuability.test.ts +0 -374
  182. package/node_modules/zod/src/v4/classic/tests/custom.test.ts +0 -40
  183. package/node_modules/zod/src/v4/classic/tests/date.test.ts +0 -62
  184. package/node_modules/zod/src/v4/classic/tests/datetime.test.ts +0 -302
  185. package/node_modules/zod/src/v4/classic/tests/default.test.ts +0 -365
  186. package/node_modules/zod/src/v4/classic/tests/describe-meta-checks.test.ts +0 -27
  187. package/node_modules/zod/src/v4/classic/tests/description.test.ts +0 -32
  188. package/node_modules/zod/src/v4/classic/tests/discriminated-unions.test.ts +0 -661
  189. package/node_modules/zod/src/v4/classic/tests/enum.test.ts +0 -285
  190. package/node_modules/zod/src/v4/classic/tests/error-utils.test.ts +0 -595
  191. package/node_modules/zod/src/v4/classic/tests/error.test.ts +0 -711
  192. package/node_modules/zod/src/v4/classic/tests/file.test.ts +0 -96
  193. package/node_modules/zod/src/v4/classic/tests/firstparty.test.ts +0 -179
  194. package/node_modules/zod/src/v4/classic/tests/fix-json-issue.test.ts +0 -26
  195. package/node_modules/zod/src/v4/classic/tests/from-json-schema.test.ts +0 -734
  196. package/node_modules/zod/src/v4/classic/tests/function.test.ts +0 -360
  197. package/node_modules/zod/src/v4/classic/tests/generics.test.ts +0 -72
  198. package/node_modules/zod/src/v4/classic/tests/hash.test.ts +0 -68
  199. package/node_modules/zod/src/v4/classic/tests/index.test.ts +0 -939
  200. package/node_modules/zod/src/v4/classic/tests/instanceof.test.ts +0 -60
  201. package/node_modules/zod/src/v4/classic/tests/intersection.test.ts +0 -198
  202. package/node_modules/zod/src/v4/classic/tests/json.test.ts +0 -109
  203. package/node_modules/zod/src/v4/classic/tests/lazy.test.ts +0 -227
  204. package/node_modules/zod/src/v4/classic/tests/literal.test.ts +0 -117
  205. package/node_modules/zod/src/v4/classic/tests/map.test.ts +0 -330
  206. package/node_modules/zod/src/v4/classic/tests/nan.test.ts +0 -21
  207. package/node_modules/zod/src/v4/classic/tests/nested-refine.test.ts +0 -168
  208. package/node_modules/zod/src/v4/classic/tests/nonoptional.test.ts +0 -101
  209. package/node_modules/zod/src/v4/classic/tests/nullable.test.ts +0 -22
  210. package/node_modules/zod/src/v4/classic/tests/number.test.ts +0 -270
  211. package/node_modules/zod/src/v4/classic/tests/object.test.ts +0 -640
  212. package/node_modules/zod/src/v4/classic/tests/optional.test.ts +0 -223
  213. package/node_modules/zod/src/v4/classic/tests/partial.test.ts +0 -427
  214. package/node_modules/zod/src/v4/classic/tests/pickomit.test.ts +0 -211
  215. package/node_modules/zod/src/v4/classic/tests/pipe.test.ts +0 -101
  216. package/node_modules/zod/src/v4/classic/tests/prefault.test.ts +0 -74
  217. package/node_modules/zod/src/v4/classic/tests/preprocess.test.ts +0 -282
  218. package/node_modules/zod/src/v4/classic/tests/primitive.test.ts +0 -175
  219. package/node_modules/zod/src/v4/classic/tests/promise.test.ts +0 -81
  220. package/node_modules/zod/src/v4/classic/tests/prototypes.test.ts +0 -23
  221. package/node_modules/zod/src/v4/classic/tests/readonly.test.ts +0 -252
  222. package/node_modules/zod/src/v4/classic/tests/record.test.ts +0 -600
  223. package/node_modules/zod/src/v4/classic/tests/recursive-types.test.ts +0 -582
  224. package/node_modules/zod/src/v4/classic/tests/refine.test.ts +0 -570
  225. package/node_modules/zod/src/v4/classic/tests/registries.test.ts +0 -243
  226. package/node_modules/zod/src/v4/classic/tests/set.test.ts +0 -181
  227. package/node_modules/zod/src/v4/classic/tests/standard-schema.test.ts +0 -134
  228. package/node_modules/zod/src/v4/classic/tests/string-formats.test.ts +0 -125
  229. package/node_modules/zod/src/v4/classic/tests/string.test.ts +0 -1175
  230. package/node_modules/zod/src/v4/classic/tests/stringbool.test.ts +0 -106
  231. package/node_modules/zod/src/v4/classic/tests/template-literal.test.ts +0 -771
  232. package/node_modules/zod/src/v4/classic/tests/to-json-schema-methods.test.ts +0 -438
  233. package/node_modules/zod/src/v4/classic/tests/to-json-schema.test.ts +0 -2975
  234. package/node_modules/zod/src/v4/classic/tests/transform.test.ts +0 -361
  235. package/node_modules/zod/src/v4/classic/tests/tuple.test.ts +0 -183
  236. package/node_modules/zod/src/v4/classic/tests/union.test.ts +0 -219
  237. package/node_modules/zod/src/v4/classic/tests/url.test.ts +0 -13
  238. package/node_modules/zod/src/v4/classic/tests/validations.test.ts +0 -283
  239. package/node_modules/zod/src/v4/classic/tests/void.test.ts +0 -12
  240. package/node_modules/zod/src/v4/core/api.ts +0 -1798
  241. package/node_modules/zod/src/v4/core/checks.ts +0 -1293
  242. package/node_modules/zod/src/v4/core/config.ts +0 -15
  243. package/node_modules/zod/src/v4/core/core.ts +0 -138
  244. package/node_modules/zod/src/v4/core/doc.ts +0 -44
  245. package/node_modules/zod/src/v4/core/errors.ts +0 -448
  246. package/node_modules/zod/src/v4/core/index.ts +0 -16
  247. package/node_modules/zod/src/v4/core/json-schema-generator.ts +0 -126
  248. package/node_modules/zod/src/v4/core/json-schema-processors.ts +0 -667
  249. package/node_modules/zod/src/v4/core/json-schema.ts +0 -147
  250. package/node_modules/zod/src/v4/core/parse.ts +0 -195
  251. package/node_modules/zod/src/v4/core/regexes.ts +0 -183
  252. package/node_modules/zod/src/v4/core/registries.ts +0 -105
  253. package/node_modules/zod/src/v4/core/schemas.ts +0 -4543
  254. package/node_modules/zod/src/v4/core/standard-schema.ts +0 -159
  255. package/node_modules/zod/src/v4/core/tests/extend.test.ts +0 -59
  256. package/node_modules/zod/src/v4/core/tests/index.test.ts +0 -46
  257. package/node_modules/zod/src/v4/core/tests/locales/be.test.ts +0 -124
  258. package/node_modules/zod/src/v4/core/tests/locales/en.test.ts +0 -22
  259. package/node_modules/zod/src/v4/core/tests/locales/es.test.ts +0 -181
  260. package/node_modules/zod/src/v4/core/tests/locales/he.test.ts +0 -379
  261. package/node_modules/zod/src/v4/core/tests/locales/nl.test.ts +0 -46
  262. package/node_modules/zod/src/v4/core/tests/locales/ru.test.ts +0 -128
  263. package/node_modules/zod/src/v4/core/tests/locales/tr.test.ts +0 -69
  264. package/node_modules/zod/src/v4/core/tests/locales/uz.test.ts +0 -83
  265. package/node_modules/zod/src/v4/core/tests/record-constructor.test.ts +0 -67
  266. package/node_modules/zod/src/v4/core/tests/recursive-tuples.test.ts +0 -45
  267. package/node_modules/zod/src/v4/core/to-json-schema.ts +0 -613
  268. package/node_modules/zod/src/v4/core/util.ts +0 -966
  269. package/node_modules/zod/src/v4/core/versions.ts +0 -5
  270. package/node_modules/zod/src/v4/core/zsf.ts +0 -323
  271. package/node_modules/zod/src/v4/index.ts +0 -4
  272. package/node_modules/zod/src/v4/locales/ar.ts +0 -115
  273. package/node_modules/zod/src/v4/locales/az.ts +0 -111
  274. package/node_modules/zod/src/v4/locales/be.ts +0 -176
  275. package/node_modules/zod/src/v4/locales/bg.ts +0 -128
  276. package/node_modules/zod/src/v4/locales/ca.ts +0 -116
  277. package/node_modules/zod/src/v4/locales/cs.ts +0 -118
  278. package/node_modules/zod/src/v4/locales/da.ts +0 -123
  279. package/node_modules/zod/src/v4/locales/de.ts +0 -116
  280. package/node_modules/zod/src/v4/locales/en.ts +0 -119
  281. package/node_modules/zod/src/v4/locales/eo.ts +0 -118
  282. package/node_modules/zod/src/v4/locales/es.ts +0 -141
  283. package/node_modules/zod/src/v4/locales/fa.ts +0 -126
  284. package/node_modules/zod/src/v4/locales/fi.ts +0 -121
  285. package/node_modules/zod/src/v4/locales/fr-CA.ts +0 -116
  286. package/node_modules/zod/src/v4/locales/fr.ts +0 -116
  287. package/node_modules/zod/src/v4/locales/he.ts +0 -246
  288. package/node_modules/zod/src/v4/locales/hu.ts +0 -117
  289. package/node_modules/zod/src/v4/locales/hy.ts +0 -164
  290. package/node_modules/zod/src/v4/locales/id.ts +0 -115
  291. package/node_modules/zod/src/v4/locales/index.ts +0 -49
  292. package/node_modules/zod/src/v4/locales/is.ts +0 -119
  293. package/node_modules/zod/src/v4/locales/it.ts +0 -116
  294. package/node_modules/zod/src/v4/locales/ja.ts +0 -114
  295. package/node_modules/zod/src/v4/locales/ka.ts +0 -123
  296. package/node_modules/zod/src/v4/locales/kh.ts +0 -7
  297. package/node_modules/zod/src/v4/locales/km.ts +0 -119
  298. package/node_modules/zod/src/v4/locales/ko.ts +0 -121
  299. package/node_modules/zod/src/v4/locales/lt.ts +0 -239
  300. package/node_modules/zod/src/v4/locales/mk.ts +0 -118
  301. package/node_modules/zod/src/v4/locales/ms.ts +0 -115
  302. package/node_modules/zod/src/v4/locales/nl.ts +0 -121
  303. package/node_modules/zod/src/v4/locales/no.ts +0 -116
  304. package/node_modules/zod/src/v4/locales/ota.ts +0 -117
  305. package/node_modules/zod/src/v4/locales/pl.ts +0 -118
  306. package/node_modules/zod/src/v4/locales/ps.ts +0 -126
  307. package/node_modules/zod/src/v4/locales/pt.ts +0 -116
  308. package/node_modules/zod/src/v4/locales/ru.ts +0 -176
  309. package/node_modules/zod/src/v4/locales/sl.ts +0 -118
  310. package/node_modules/zod/src/v4/locales/sv.ts +0 -119
  311. package/node_modules/zod/src/v4/locales/ta.ts +0 -118
  312. package/node_modules/zod/src/v4/locales/th.ts +0 -119
  313. package/node_modules/zod/src/v4/locales/tr.ts +0 -111
  314. package/node_modules/zod/src/v4/locales/ua.ts +0 -7
  315. package/node_modules/zod/src/v4/locales/uk.ts +0 -117
  316. package/node_modules/zod/src/v4/locales/ur.ts +0 -119
  317. package/node_modules/zod/src/v4/locales/uz.ts +0 -116
  318. package/node_modules/zod/src/v4/locales/vi.ts +0 -117
  319. package/node_modules/zod/src/v4/locales/yo.ts +0 -124
  320. package/node_modules/zod/src/v4/locales/zh-CN.ts +0 -116
  321. package/node_modules/zod/src/v4/locales/zh-TW.ts +0 -115
  322. package/node_modules/zod/src/v4/mini/checks.ts +0 -32
  323. package/node_modules/zod/src/v4/mini/coerce.ts +0 -27
  324. package/node_modules/zod/src/v4/mini/external.ts +0 -40
  325. package/node_modules/zod/src/v4/mini/index.ts +0 -3
  326. package/node_modules/zod/src/v4/mini/iso.ts +0 -66
  327. package/node_modules/zod/src/v4/mini/parse.ts +0 -14
  328. package/node_modules/zod/src/v4/mini/schemas.ts +0 -1916
  329. package/node_modules/zod/src/v4/mini/tests/apply.test.ts +0 -24
  330. package/node_modules/zod/src/v4/mini/tests/assignability.test.ts +0 -129
  331. package/node_modules/zod/src/v4/mini/tests/brand.test.ts +0 -94
  332. package/node_modules/zod/src/v4/mini/tests/checks.test.ts +0 -144
  333. package/node_modules/zod/src/v4/mini/tests/codec.test.ts +0 -529
  334. package/node_modules/zod/src/v4/mini/tests/computed.test.ts +0 -36
  335. package/node_modules/zod/src/v4/mini/tests/error.test.ts +0 -22
  336. package/node_modules/zod/src/v4/mini/tests/functions.test.ts +0 -5
  337. package/node_modules/zod/src/v4/mini/tests/index.test.ts +0 -963
  338. package/node_modules/zod/src/v4/mini/tests/number.test.ts +0 -95
  339. package/node_modules/zod/src/v4/mini/tests/object.test.ts +0 -227
  340. package/node_modules/zod/src/v4/mini/tests/prototypes.test.ts +0 -43
  341. package/node_modules/zod/src/v4/mini/tests/recursive-types.test.ts +0 -275
  342. package/node_modules/zod/src/v4/mini/tests/standard-schema.test.ts +0 -50
  343. package/node_modules/zod/src/v4/mini/tests/string.test.ts +0 -347
  344. package/node_modules/zod/src/v4-mini/index.ts +0 -1
  345. package/node_modules/zod/v3/ZodError.cjs +0 -138
  346. package/node_modules/zod/v3/ZodError.d.cts +0 -164
  347. package/node_modules/zod/v3/ZodError.d.ts +0 -164
  348. package/node_modules/zod/v3/ZodError.js +0 -133
  349. package/node_modules/zod/v3/errors.cjs +0 -17
  350. package/node_modules/zod/v3/errors.d.cts +0 -5
  351. package/node_modules/zod/v3/errors.d.ts +0 -5
  352. package/node_modules/zod/v3/errors.js +0 -9
  353. package/node_modules/zod/v3/external.cjs +0 -22
  354. package/node_modules/zod/v3/external.d.cts +0 -6
  355. package/node_modules/zod/v3/external.d.ts +0 -6
  356. package/node_modules/zod/v3/external.js +0 -6
  357. package/node_modules/zod/v3/helpers/enumUtil.cjs +0 -2
  358. package/node_modules/zod/v3/helpers/enumUtil.d.cts +0 -8
  359. package/node_modules/zod/v3/helpers/enumUtil.d.ts +0 -8
  360. package/node_modules/zod/v3/helpers/enumUtil.js +0 -1
  361. package/node_modules/zod/v3/helpers/errorUtil.cjs +0 -9
  362. package/node_modules/zod/v3/helpers/errorUtil.d.cts +0 -9
  363. package/node_modules/zod/v3/helpers/errorUtil.d.ts +0 -9
  364. package/node_modules/zod/v3/helpers/errorUtil.js +0 -6
  365. package/node_modules/zod/v3/helpers/parseUtil.cjs +0 -124
  366. package/node_modules/zod/v3/helpers/parseUtil.d.cts +0 -78
  367. package/node_modules/zod/v3/helpers/parseUtil.d.ts +0 -78
  368. package/node_modules/zod/v3/helpers/parseUtil.js +0 -109
  369. package/node_modules/zod/v3/helpers/partialUtil.cjs +0 -2
  370. package/node_modules/zod/v3/helpers/partialUtil.d.cts +0 -8
  371. package/node_modules/zod/v3/helpers/partialUtil.d.ts +0 -8
  372. package/node_modules/zod/v3/helpers/partialUtil.js +0 -1
  373. package/node_modules/zod/v3/helpers/typeAliases.cjs +0 -2
  374. package/node_modules/zod/v3/helpers/typeAliases.d.cts +0 -2
  375. package/node_modules/zod/v3/helpers/typeAliases.d.ts +0 -2
  376. package/node_modules/zod/v3/helpers/typeAliases.js +0 -1
  377. package/node_modules/zod/v3/helpers/util.cjs +0 -137
  378. package/node_modules/zod/v3/helpers/util.d.cts +0 -85
  379. package/node_modules/zod/v3/helpers/util.d.ts +0 -85
  380. package/node_modules/zod/v3/helpers/util.js +0 -133
  381. package/node_modules/zod/v3/index.cjs +0 -33
  382. package/node_modules/zod/v3/index.d.cts +0 -4
  383. package/node_modules/zod/v3/index.d.ts +0 -4
  384. package/node_modules/zod/v3/index.js +0 -4
  385. package/node_modules/zod/v3/locales/en.cjs +0 -112
  386. package/node_modules/zod/v3/locales/en.d.cts +0 -3
  387. package/node_modules/zod/v3/locales/en.d.ts +0 -3
  388. package/node_modules/zod/v3/locales/en.js +0 -109
  389. package/node_modules/zod/v3/package.json +0 -6
  390. package/node_modules/zod/v3/standard-schema.cjs +0 -2
  391. package/node_modules/zod/v3/standard-schema.d.cts +0 -102
  392. package/node_modules/zod/v3/standard-schema.d.ts +0 -102
  393. package/node_modules/zod/v3/standard-schema.js +0 -1
  394. package/node_modules/zod/v3/types.cjs +0 -3777
  395. package/node_modules/zod/v3/types.d.cts +0 -1034
  396. package/node_modules/zod/v3/types.d.ts +0 -1034
  397. package/node_modules/zod/v3/types.js +0 -3695
  398. package/node_modules/zod/v4/classic/checks.cjs +0 -33
  399. package/node_modules/zod/v4/classic/checks.d.cts +0 -1
  400. package/node_modules/zod/v4/classic/checks.d.ts +0 -1
  401. package/node_modules/zod/v4/classic/checks.js +0 -1
  402. package/node_modules/zod/v4/classic/coerce.cjs +0 -47
  403. package/node_modules/zod/v4/classic/coerce.d.cts +0 -17
  404. package/node_modules/zod/v4/classic/coerce.d.ts +0 -17
  405. package/node_modules/zod/v4/classic/coerce.js +0 -17
  406. package/node_modules/zod/v4/classic/compat.cjs +0 -61
  407. package/node_modules/zod/v4/classic/compat.d.cts +0 -50
  408. package/node_modules/zod/v4/classic/compat.d.ts +0 -50
  409. package/node_modules/zod/v4/classic/compat.js +0 -31
  410. package/node_modules/zod/v4/classic/errors.cjs +0 -74
  411. package/node_modules/zod/v4/classic/errors.d.cts +0 -30
  412. package/node_modules/zod/v4/classic/errors.d.ts +0 -30
  413. package/node_modules/zod/v4/classic/errors.js +0 -48
  414. package/node_modules/zod/v4/classic/external.cjs +0 -73
  415. package/node_modules/zod/v4/classic/external.d.cts +0 -15
  416. package/node_modules/zod/v4/classic/external.d.ts +0 -15
  417. package/node_modules/zod/v4/classic/external.js +0 -20
  418. package/node_modules/zod/v4/classic/from-json-schema.cjs +0 -610
  419. package/node_modules/zod/v4/classic/from-json-schema.d.cts +0 -12
  420. package/node_modules/zod/v4/classic/from-json-schema.d.ts +0 -12
  421. package/node_modules/zod/v4/classic/from-json-schema.js +0 -584
  422. package/node_modules/zod/v4/classic/index.cjs +0 -33
  423. package/node_modules/zod/v4/classic/index.d.cts +0 -4
  424. package/node_modules/zod/v4/classic/index.d.ts +0 -4
  425. package/node_modules/zod/v4/classic/index.js +0 -4
  426. package/node_modules/zod/v4/classic/iso.cjs +0 -60
  427. package/node_modules/zod/v4/classic/iso.d.cts +0 -22
  428. package/node_modules/zod/v4/classic/iso.d.ts +0 -22
  429. package/node_modules/zod/v4/classic/iso.js +0 -30
  430. package/node_modules/zod/v4/classic/package.json +0 -6
  431. package/node_modules/zod/v4/classic/parse.cjs +0 -41
  432. package/node_modules/zod/v4/classic/parse.d.cts +0 -31
  433. package/node_modules/zod/v4/classic/parse.d.ts +0 -31
  434. package/node_modules/zod/v4/classic/parse.js +0 -15
  435. package/node_modules/zod/v4/classic/schemas.cjs +0 -1272
  436. package/node_modules/zod/v4/classic/schemas.d.cts +0 -739
  437. package/node_modules/zod/v4/classic/schemas.d.ts +0 -739
  438. package/node_modules/zod/v4/classic/schemas.js +0 -1157
  439. package/node_modules/zod/v4/core/api.cjs +0 -1222
  440. package/node_modules/zod/v4/core/api.d.cts +0 -304
  441. package/node_modules/zod/v4/core/api.d.ts +0 -304
  442. package/node_modules/zod/v4/core/api.js +0 -1082
  443. package/node_modules/zod/v4/core/checks.cjs +0 -601
  444. package/node_modules/zod/v4/core/checks.d.cts +0 -278
  445. package/node_modules/zod/v4/core/checks.d.ts +0 -278
  446. package/node_modules/zod/v4/core/checks.js +0 -575
  447. package/node_modules/zod/v4/core/core.cjs +0 -83
  448. package/node_modules/zod/v4/core/core.d.cts +0 -70
  449. package/node_modules/zod/v4/core/core.d.ts +0 -70
  450. package/node_modules/zod/v4/core/core.js +0 -76
  451. package/node_modules/zod/v4/core/doc.cjs +0 -39
  452. package/node_modules/zod/v4/core/doc.d.cts +0 -14
  453. package/node_modules/zod/v4/core/doc.d.ts +0 -14
  454. package/node_modules/zod/v4/core/doc.js +0 -35
  455. package/node_modules/zod/v4/core/errors.cjs +0 -213
  456. package/node_modules/zod/v4/core/errors.d.cts +0 -220
  457. package/node_modules/zod/v4/core/errors.d.ts +0 -220
  458. package/node_modules/zod/v4/core/errors.js +0 -182
  459. package/node_modules/zod/v4/core/index.cjs +0 -47
  460. package/node_modules/zod/v4/core/index.d.cts +0 -16
  461. package/node_modules/zod/v4/core/index.d.ts +0 -16
  462. package/node_modules/zod/v4/core/index.js +0 -16
  463. package/node_modules/zod/v4/core/json-schema-generator.cjs +0 -99
  464. package/node_modules/zod/v4/core/json-schema-generator.d.cts +0 -65
  465. package/node_modules/zod/v4/core/json-schema-generator.d.ts +0 -65
  466. package/node_modules/zod/v4/core/json-schema-generator.js +0 -95
  467. package/node_modules/zod/v4/core/json-schema-processors.cjs +0 -648
  468. package/node_modules/zod/v4/core/json-schema-processors.d.cts +0 -49
  469. package/node_modules/zod/v4/core/json-schema-processors.d.ts +0 -49
  470. package/node_modules/zod/v4/core/json-schema-processors.js +0 -605
  471. package/node_modules/zod/v4/core/json-schema.cjs +0 -2
  472. package/node_modules/zod/v4/core/json-schema.d.cts +0 -88
  473. package/node_modules/zod/v4/core/json-schema.d.ts +0 -88
  474. package/node_modules/zod/v4/core/json-schema.js +0 -1
  475. package/node_modules/zod/v4/core/package.json +0 -6
  476. package/node_modules/zod/v4/core/parse.cjs +0 -131
  477. package/node_modules/zod/v4/core/parse.d.cts +0 -49
  478. package/node_modules/zod/v4/core/parse.d.ts +0 -49
  479. package/node_modules/zod/v4/core/parse.js +0 -93
  480. package/node_modules/zod/v4/core/regexes.cjs +0 -166
  481. package/node_modules/zod/v4/core/regexes.d.cts +0 -79
  482. package/node_modules/zod/v4/core/regexes.d.ts +0 -79
  483. package/node_modules/zod/v4/core/regexes.js +0 -133
  484. package/node_modules/zod/v4/core/registries.cjs +0 -56
  485. package/node_modules/zod/v4/core/registries.d.cts +0 -35
  486. package/node_modules/zod/v4/core/registries.d.ts +0 -35
  487. package/node_modules/zod/v4/core/registries.js +0 -51
  488. package/node_modules/zod/v4/core/schemas.cjs +0 -2126
  489. package/node_modules/zod/v4/core/schemas.d.cts +0 -1146
  490. package/node_modules/zod/v4/core/schemas.d.ts +0 -1146
  491. package/node_modules/zod/v4/core/schemas.js +0 -2095
  492. package/node_modules/zod/v4/core/standard-schema.cjs +0 -2
  493. package/node_modules/zod/v4/core/standard-schema.d.cts +0 -126
  494. package/node_modules/zod/v4/core/standard-schema.d.ts +0 -126
  495. package/node_modules/zod/v4/core/standard-schema.js +0 -1
  496. package/node_modules/zod/v4/core/to-json-schema.cjs +0 -446
  497. package/node_modules/zod/v4/core/to-json-schema.d.cts +0 -114
  498. package/node_modules/zod/v4/core/to-json-schema.d.ts +0 -114
  499. package/node_modules/zod/v4/core/to-json-schema.js +0 -437
  500. package/node_modules/zod/v4/core/util.cjs +0 -710
  501. package/node_modules/zod/v4/core/util.d.cts +0 -199
  502. package/node_modules/zod/v4/core/util.d.ts +0 -199
  503. package/node_modules/zod/v4/core/util.js +0 -651
  504. package/node_modules/zod/v4/core/versions.cjs +0 -8
  505. package/node_modules/zod/v4/core/versions.d.cts +0 -5
  506. package/node_modules/zod/v4/core/versions.d.ts +0 -5
  507. package/node_modules/zod/v4/core/versions.js +0 -5
  508. package/node_modules/zod/v4/index.cjs +0 -22
  509. package/node_modules/zod/v4/index.d.cts +0 -3
  510. package/node_modules/zod/v4/index.d.ts +0 -3
  511. package/node_modules/zod/v4/index.js +0 -3
  512. package/node_modules/zod/v4/locales/ar.cjs +0 -133
  513. package/node_modules/zod/v4/locales/ar.d.cts +0 -5
  514. package/node_modules/zod/v4/locales/ar.d.ts +0 -4
  515. package/node_modules/zod/v4/locales/ar.js +0 -106
  516. package/node_modules/zod/v4/locales/az.cjs +0 -132
  517. package/node_modules/zod/v4/locales/az.d.cts +0 -5
  518. package/node_modules/zod/v4/locales/az.d.ts +0 -4
  519. package/node_modules/zod/v4/locales/az.js +0 -105
  520. package/node_modules/zod/v4/locales/be.cjs +0 -183
  521. package/node_modules/zod/v4/locales/be.d.cts +0 -5
  522. package/node_modules/zod/v4/locales/be.d.ts +0 -4
  523. package/node_modules/zod/v4/locales/be.js +0 -156
  524. package/node_modules/zod/v4/locales/bg.cjs +0 -147
  525. package/node_modules/zod/v4/locales/bg.d.cts +0 -5
  526. package/node_modules/zod/v4/locales/bg.d.ts +0 -4
  527. package/node_modules/zod/v4/locales/bg.js +0 -120
  528. package/node_modules/zod/v4/locales/ca.cjs +0 -134
  529. package/node_modules/zod/v4/locales/ca.d.cts +0 -5
  530. package/node_modules/zod/v4/locales/ca.d.ts +0 -4
  531. package/node_modules/zod/v4/locales/ca.js +0 -107
  532. package/node_modules/zod/v4/locales/cs.cjs +0 -138
  533. package/node_modules/zod/v4/locales/cs.d.cts +0 -5
  534. package/node_modules/zod/v4/locales/cs.d.ts +0 -4
  535. package/node_modules/zod/v4/locales/cs.js +0 -111
  536. package/node_modules/zod/v4/locales/da.cjs +0 -142
  537. package/node_modules/zod/v4/locales/da.d.cts +0 -5
  538. package/node_modules/zod/v4/locales/da.d.ts +0 -4
  539. package/node_modules/zod/v4/locales/da.js +0 -115
  540. package/node_modules/zod/v4/locales/de.cjs +0 -135
  541. package/node_modules/zod/v4/locales/de.d.cts +0 -5
  542. package/node_modules/zod/v4/locales/de.d.ts +0 -4
  543. package/node_modules/zod/v4/locales/de.js +0 -108
  544. package/node_modules/zod/v4/locales/en.cjs +0 -136
  545. package/node_modules/zod/v4/locales/en.d.cts +0 -5
  546. package/node_modules/zod/v4/locales/en.d.ts +0 -4
  547. package/node_modules/zod/v4/locales/en.js +0 -109
  548. package/node_modules/zod/v4/locales/eo.cjs +0 -136
  549. package/node_modules/zod/v4/locales/eo.d.cts +0 -5
  550. package/node_modules/zod/v4/locales/eo.d.ts +0 -4
  551. package/node_modules/zod/v4/locales/eo.js +0 -109
  552. package/node_modules/zod/v4/locales/es.cjs +0 -159
  553. package/node_modules/zod/v4/locales/es.d.cts +0 -5
  554. package/node_modules/zod/v4/locales/es.d.ts +0 -4
  555. package/node_modules/zod/v4/locales/es.js +0 -132
  556. package/node_modules/zod/v4/locales/fa.cjs +0 -141
  557. package/node_modules/zod/v4/locales/fa.d.cts +0 -5
  558. package/node_modules/zod/v4/locales/fa.d.ts +0 -4
  559. package/node_modules/zod/v4/locales/fa.js +0 -114
  560. package/node_modules/zod/v4/locales/fi.cjs +0 -139
  561. package/node_modules/zod/v4/locales/fi.d.cts +0 -5
  562. package/node_modules/zod/v4/locales/fi.d.ts +0 -4
  563. package/node_modules/zod/v4/locales/fi.js +0 -112
  564. package/node_modules/zod/v4/locales/fr-CA.cjs +0 -134
  565. package/node_modules/zod/v4/locales/fr-CA.d.cts +0 -5
  566. package/node_modules/zod/v4/locales/fr-CA.d.ts +0 -4
  567. package/node_modules/zod/v4/locales/fr-CA.js +0 -107
  568. package/node_modules/zod/v4/locales/fr.cjs +0 -135
  569. package/node_modules/zod/v4/locales/fr.d.cts +0 -5
  570. package/node_modules/zod/v4/locales/fr.d.ts +0 -4
  571. package/node_modules/zod/v4/locales/fr.js +0 -108
  572. package/node_modules/zod/v4/locales/he.cjs +0 -241
  573. package/node_modules/zod/v4/locales/he.d.cts +0 -5
  574. package/node_modules/zod/v4/locales/he.d.ts +0 -4
  575. package/node_modules/zod/v4/locales/he.js +0 -214
  576. package/node_modules/zod/v4/locales/hu.cjs +0 -135
  577. package/node_modules/zod/v4/locales/hu.d.cts +0 -5
  578. package/node_modules/zod/v4/locales/hu.d.ts +0 -4
  579. package/node_modules/zod/v4/locales/hu.js +0 -108
  580. package/node_modules/zod/v4/locales/hy.cjs +0 -174
  581. package/node_modules/zod/v4/locales/hy.d.cts +0 -5
  582. package/node_modules/zod/v4/locales/hy.d.ts +0 -4
  583. package/node_modules/zod/v4/locales/hy.js +0 -147
  584. package/node_modules/zod/v4/locales/id.cjs +0 -133
  585. package/node_modules/zod/v4/locales/id.d.cts +0 -5
  586. package/node_modules/zod/v4/locales/id.d.ts +0 -4
  587. package/node_modules/zod/v4/locales/id.js +0 -106
  588. package/node_modules/zod/v4/locales/index.cjs +0 -104
  589. package/node_modules/zod/v4/locales/index.d.cts +0 -49
  590. package/node_modules/zod/v4/locales/index.d.ts +0 -49
  591. package/node_modules/zod/v4/locales/index.js +0 -49
  592. package/node_modules/zod/v4/locales/is.cjs +0 -136
  593. package/node_modules/zod/v4/locales/is.d.cts +0 -5
  594. package/node_modules/zod/v4/locales/is.d.ts +0 -4
  595. package/node_modules/zod/v4/locales/is.js +0 -109
  596. package/node_modules/zod/v4/locales/it.cjs +0 -135
  597. package/node_modules/zod/v4/locales/it.d.cts +0 -5
  598. package/node_modules/zod/v4/locales/it.d.ts +0 -4
  599. package/node_modules/zod/v4/locales/it.js +0 -108
  600. package/node_modules/zod/v4/locales/ja.cjs +0 -134
  601. package/node_modules/zod/v4/locales/ja.d.cts +0 -5
  602. package/node_modules/zod/v4/locales/ja.d.ts +0 -4
  603. package/node_modules/zod/v4/locales/ja.js +0 -107
  604. package/node_modules/zod/v4/locales/ka.cjs +0 -139
  605. package/node_modules/zod/v4/locales/ka.d.cts +0 -5
  606. package/node_modules/zod/v4/locales/ka.d.ts +0 -4
  607. package/node_modules/zod/v4/locales/ka.js +0 -112
  608. package/node_modules/zod/v4/locales/kh.cjs +0 -12
  609. package/node_modules/zod/v4/locales/kh.d.cts +0 -5
  610. package/node_modules/zod/v4/locales/kh.d.ts +0 -5
  611. package/node_modules/zod/v4/locales/kh.js +0 -5
  612. package/node_modules/zod/v4/locales/km.cjs +0 -137
  613. package/node_modules/zod/v4/locales/km.d.cts +0 -5
  614. package/node_modules/zod/v4/locales/km.d.ts +0 -4
  615. package/node_modules/zod/v4/locales/km.js +0 -110
  616. package/node_modules/zod/v4/locales/ko.cjs +0 -138
  617. package/node_modules/zod/v4/locales/ko.d.cts +0 -5
  618. package/node_modules/zod/v4/locales/ko.d.ts +0 -4
  619. package/node_modules/zod/v4/locales/ko.js +0 -111
  620. package/node_modules/zod/v4/locales/lt.cjs +0 -230
  621. package/node_modules/zod/v4/locales/lt.d.cts +0 -5
  622. package/node_modules/zod/v4/locales/lt.d.ts +0 -4
  623. package/node_modules/zod/v4/locales/lt.js +0 -203
  624. package/node_modules/zod/v4/locales/mk.cjs +0 -136
  625. package/node_modules/zod/v4/locales/mk.d.cts +0 -5
  626. package/node_modules/zod/v4/locales/mk.d.ts +0 -4
  627. package/node_modules/zod/v4/locales/mk.js +0 -109
  628. package/node_modules/zod/v4/locales/ms.cjs +0 -134
  629. package/node_modules/zod/v4/locales/ms.d.cts +0 -5
  630. package/node_modules/zod/v4/locales/ms.d.ts +0 -4
  631. package/node_modules/zod/v4/locales/ms.js +0 -107
  632. package/node_modules/zod/v4/locales/nl.cjs +0 -137
  633. package/node_modules/zod/v4/locales/nl.d.cts +0 -5
  634. package/node_modules/zod/v4/locales/nl.d.ts +0 -4
  635. package/node_modules/zod/v4/locales/nl.js +0 -110
  636. package/node_modules/zod/v4/locales/no.cjs +0 -135
  637. package/node_modules/zod/v4/locales/no.d.cts +0 -5
  638. package/node_modules/zod/v4/locales/no.d.ts +0 -4
  639. package/node_modules/zod/v4/locales/no.js +0 -108
  640. package/node_modules/zod/v4/locales/ota.cjs +0 -136
  641. package/node_modules/zod/v4/locales/ota.d.cts +0 -5
  642. package/node_modules/zod/v4/locales/ota.d.ts +0 -4
  643. package/node_modules/zod/v4/locales/ota.js +0 -109
  644. package/node_modules/zod/v4/locales/package.json +0 -6
  645. package/node_modules/zod/v4/locales/pl.cjs +0 -136
  646. package/node_modules/zod/v4/locales/pl.d.cts +0 -5
  647. package/node_modules/zod/v4/locales/pl.d.ts +0 -4
  648. package/node_modules/zod/v4/locales/pl.js +0 -109
  649. package/node_modules/zod/v4/locales/ps.cjs +0 -141
  650. package/node_modules/zod/v4/locales/ps.d.cts +0 -5
  651. package/node_modules/zod/v4/locales/ps.d.ts +0 -4
  652. package/node_modules/zod/v4/locales/ps.js +0 -114
  653. package/node_modules/zod/v4/locales/pt.cjs +0 -135
  654. package/node_modules/zod/v4/locales/pt.d.cts +0 -5
  655. package/node_modules/zod/v4/locales/pt.d.ts +0 -4
  656. package/node_modules/zod/v4/locales/pt.js +0 -108
  657. package/node_modules/zod/v4/locales/ru.cjs +0 -183
  658. package/node_modules/zod/v4/locales/ru.d.cts +0 -5
  659. package/node_modules/zod/v4/locales/ru.d.ts +0 -4
  660. package/node_modules/zod/v4/locales/ru.js +0 -156
  661. package/node_modules/zod/v4/locales/sl.cjs +0 -136
  662. package/node_modules/zod/v4/locales/sl.d.cts +0 -5
  663. package/node_modules/zod/v4/locales/sl.d.ts +0 -4
  664. package/node_modules/zod/v4/locales/sl.js +0 -109
  665. package/node_modules/zod/v4/locales/sv.cjs +0 -137
  666. package/node_modules/zod/v4/locales/sv.d.cts +0 -5
  667. package/node_modules/zod/v4/locales/sv.d.ts +0 -4
  668. package/node_modules/zod/v4/locales/sv.js +0 -110
  669. package/node_modules/zod/v4/locales/ta.cjs +0 -137
  670. package/node_modules/zod/v4/locales/ta.d.cts +0 -5
  671. package/node_modules/zod/v4/locales/ta.d.ts +0 -4
  672. package/node_modules/zod/v4/locales/ta.js +0 -110
  673. package/node_modules/zod/v4/locales/th.cjs +0 -137
  674. package/node_modules/zod/v4/locales/th.d.cts +0 -5
  675. package/node_modules/zod/v4/locales/th.d.ts +0 -4
  676. package/node_modules/zod/v4/locales/th.js +0 -110
  677. package/node_modules/zod/v4/locales/tr.cjs +0 -132
  678. package/node_modules/zod/v4/locales/tr.d.cts +0 -5
  679. package/node_modules/zod/v4/locales/tr.d.ts +0 -4
  680. package/node_modules/zod/v4/locales/tr.js +0 -105
  681. package/node_modules/zod/v4/locales/ua.cjs +0 -12
  682. package/node_modules/zod/v4/locales/ua.d.cts +0 -5
  683. package/node_modules/zod/v4/locales/ua.d.ts +0 -5
  684. package/node_modules/zod/v4/locales/ua.js +0 -5
  685. package/node_modules/zod/v4/locales/uk.cjs +0 -135
  686. package/node_modules/zod/v4/locales/uk.d.cts +0 -5
  687. package/node_modules/zod/v4/locales/uk.d.ts +0 -4
  688. package/node_modules/zod/v4/locales/uk.js +0 -108
  689. package/node_modules/zod/v4/locales/ur.cjs +0 -137
  690. package/node_modules/zod/v4/locales/ur.d.cts +0 -5
  691. package/node_modules/zod/v4/locales/ur.d.ts +0 -4
  692. package/node_modules/zod/v4/locales/ur.js +0 -110
  693. package/node_modules/zod/v4/locales/uz.cjs +0 -136
  694. package/node_modules/zod/v4/locales/uz.d.cts +0 -5
  695. package/node_modules/zod/v4/locales/uz.d.ts +0 -4
  696. package/node_modules/zod/v4/locales/uz.js +0 -109
  697. package/node_modules/zod/v4/locales/vi.cjs +0 -135
  698. package/node_modules/zod/v4/locales/vi.d.cts +0 -5
  699. package/node_modules/zod/v4/locales/vi.d.ts +0 -4
  700. package/node_modules/zod/v4/locales/vi.js +0 -108
  701. package/node_modules/zod/v4/locales/yo.cjs +0 -134
  702. package/node_modules/zod/v4/locales/yo.d.cts +0 -5
  703. package/node_modules/zod/v4/locales/yo.d.ts +0 -4
  704. package/node_modules/zod/v4/locales/yo.js +0 -107
  705. package/node_modules/zod/v4/locales/zh-CN.cjs +0 -136
  706. package/node_modules/zod/v4/locales/zh-CN.d.cts +0 -5
  707. package/node_modules/zod/v4/locales/zh-CN.d.ts +0 -4
  708. package/node_modules/zod/v4/locales/zh-CN.js +0 -109
  709. package/node_modules/zod/v4/locales/zh-TW.cjs +0 -134
  710. package/node_modules/zod/v4/locales/zh-TW.d.cts +0 -5
  711. package/node_modules/zod/v4/locales/zh-TW.d.ts +0 -4
  712. package/node_modules/zod/v4/locales/zh-TW.js +0 -107
  713. package/node_modules/zod/v4/mini/checks.cjs +0 -34
  714. package/node_modules/zod/v4/mini/checks.d.cts +0 -1
  715. package/node_modules/zod/v4/mini/checks.d.ts +0 -1
  716. package/node_modules/zod/v4/mini/checks.js +0 -1
  717. package/node_modules/zod/v4/mini/coerce.cjs +0 -52
  718. package/node_modules/zod/v4/mini/coerce.d.cts +0 -7
  719. package/node_modules/zod/v4/mini/coerce.d.ts +0 -7
  720. package/node_modules/zod/v4/mini/coerce.js +0 -22
  721. package/node_modules/zod/v4/mini/external.cjs +0 -63
  722. package/node_modules/zod/v4/mini/external.d.cts +0 -12
  723. package/node_modules/zod/v4/mini/external.d.ts +0 -12
  724. package/node_modules/zod/v4/mini/external.js +0 -14
  725. package/node_modules/zod/v4/mini/index.cjs +0 -32
  726. package/node_modules/zod/v4/mini/index.d.cts +0 -3
  727. package/node_modules/zod/v4/mini/index.d.ts +0 -3
  728. package/node_modules/zod/v4/mini/index.js +0 -3
  729. package/node_modules/zod/v4/mini/iso.cjs +0 -64
  730. package/node_modules/zod/v4/mini/iso.d.cts +0 -22
  731. package/node_modules/zod/v4/mini/iso.d.ts +0 -22
  732. package/node_modules/zod/v4/mini/iso.js +0 -34
  733. package/node_modules/zod/v4/mini/package.json +0 -6
  734. package/node_modules/zod/v4/mini/parse.cjs +0 -16
  735. package/node_modules/zod/v4/mini/parse.d.cts +0 -1
  736. package/node_modules/zod/v4/mini/parse.d.ts +0 -1
  737. package/node_modules/zod/v4/mini/parse.js +0 -1
  738. package/node_modules/zod/v4/mini/schemas.cjs +0 -1046
  739. package/node_modules/zod/v4/mini/schemas.d.cts +0 -427
  740. package/node_modules/zod/v4/mini/schemas.d.ts +0 -427
  741. package/node_modules/zod/v4/mini/schemas.js +0 -925
  742. package/node_modules/zod/v4/package.json +0 -6
  743. package/node_modules/zod/v4-mini/index.cjs +0 -17
  744. package/node_modules/zod/v4-mini/index.d.cts +0 -1
  745. package/node_modules/zod/v4-mini/index.d.ts +0 -1
  746. package/node_modules/zod/v4-mini/index.js +0 -1
  747. package/node_modules/zod/v4-mini/package.json +0 -6
@@ -1,4543 +0,0 @@
1
- import type { $ZodTypeDiscriminable } from "./api.js";
2
- import * as checks from "./checks.js";
3
- import * as core from "./core.js";
4
- import { Doc } from "./doc.js";
5
- import type * as errors from "./errors.js";
6
- import type * as JSONSchema from "./json-schema.js";
7
- import { parse, parseAsync, safeParse, safeParseAsync } from "./parse.js";
8
- import * as regexes from "./regexes.js";
9
- import type { StandardSchemaV1 } from "./standard-schema.js";
10
- import type { ProcessParams, ToJSONSchemaContext } from "./to-json-schema.js";
11
- import * as util from "./util.js";
12
- import { version } from "./versions.js";
13
-
14
- ///////////////////////////// PARSE //////////////////////////////
15
-
16
- export interface ParseContext<T extends errors.$ZodIssueBase = never> {
17
- /** Customize error messages. */
18
- readonly error?: errors.$ZodErrorMap<T>;
19
- /** Include the `input` field in issue objects. Default `false`. */
20
- readonly reportInput?: boolean;
21
- /** Skip eval-based fast path. Default `false`. */
22
- readonly jitless?: boolean;
23
- /** Abort validation after the first error. Default `false`. */
24
- // readonly abortEarly?: boolean;
25
- }
26
-
27
- /** @internal */
28
- export interface ParseContextInternal<T extends errors.$ZodIssueBase = never> extends ParseContext<T> {
29
- readonly async?: boolean | undefined;
30
- readonly direction?: "forward" | "backward";
31
- readonly skipChecks?: boolean;
32
- }
33
-
34
- export interface ParsePayload<T = unknown> {
35
- value: T;
36
- issues: errors.$ZodRawIssue[];
37
- /** A may to mark a whole payload as aborted. Used in codecs/pipes. */
38
- aborted?: boolean;
39
- }
40
-
41
- export type CheckFn<T> = (input: ParsePayload<T>) => util.MaybeAsync<void>;
42
-
43
- ///////////////////////////// SCHEMAS //////////////////////////////
44
-
45
- export interface $ZodTypeDef {
46
- type:
47
- | "string"
48
- | "number"
49
- | "int"
50
- | "boolean"
51
- | "bigint"
52
- | "symbol"
53
- | "null"
54
- | "undefined"
55
- | "void" // merge with undefined?
56
- | "never"
57
- | "any"
58
- | "unknown"
59
- | "date"
60
- | "object"
61
- | "record"
62
- | "file"
63
- | "array"
64
- | "tuple"
65
- | "union"
66
- | "intersection"
67
- | "map"
68
- | "set"
69
- | "enum"
70
- | "literal"
71
- | "nullable"
72
- | "optional"
73
- | "nonoptional"
74
- | "success"
75
- | "transform"
76
- | "default"
77
- | "prefault"
78
- | "catch"
79
- | "nan"
80
- | "pipe"
81
- | "readonly"
82
- | "template_literal"
83
- | "promise"
84
- | "lazy"
85
- | "function"
86
- | "custom";
87
- error?: errors.$ZodErrorMap<never> | undefined;
88
- checks?: checks.$ZodCheck<never>[];
89
- }
90
-
91
- export interface _$ZodTypeInternals {
92
- /** The `@zod/core` version of this schema */
93
- version: typeof version;
94
-
95
- /** Schema definition. */
96
- def: $ZodTypeDef;
97
- // types: Types;
98
-
99
- /** @internal Randomly generated ID for this schema. */
100
- // id: string;
101
-
102
- /** @internal List of deferred initializers. */
103
- deferred: util.AnyFunc[] | undefined;
104
-
105
- /** @internal Parses input and runs all checks (refinements). */
106
- run(payload: ParsePayload<any>, ctx: ParseContextInternal): util.MaybeAsync<ParsePayload>;
107
-
108
- /** @internal Parses input, doesn't run checks. */
109
- parse(payload: ParsePayload<any>, ctx: ParseContextInternal): util.MaybeAsync<ParsePayload>;
110
-
111
- /** @internal Stores identifiers for the set of traits implemented by this schema. */
112
- traits: Set<string>;
113
-
114
- /** @internal Indicates that a schema output type should be considered optional inside objects.
115
- * @default Required
116
- */
117
-
118
- /** @internal */
119
- optin?: "optional" | undefined;
120
- /** @internal */
121
- optout?: "optional" | undefined;
122
-
123
- /** @internal The set of literal values that will pass validation. Must be an exhaustive set. Used to determine optionality in z.record().
124
- *
125
- * Defined on: enum, const, literal, null, undefined
126
- * Passthrough: optional, nullable, branded, default, catch, pipe
127
- * Todo: unions?
128
- */
129
- values?: util.PrimitiveSet | undefined;
130
-
131
- /** Default value bubbled up from */
132
- // default?: unknown | undefined;
133
-
134
- /** @internal A set of literal discriminators used for the fast path in discriminated unions. */
135
- propValues?: util.PropValues | undefined;
136
-
137
- /** @internal This flag indicates that a schema validation can be represented with a regular expression. Used to determine allowable schemas in z.templateLiteral(). */
138
- pattern: RegExp | undefined;
139
-
140
- /** @internal The constructor function of this schema. */
141
- constr: new (
142
- def: any
143
- ) => $ZodType;
144
-
145
- /** @internal A catchall object for bag metadata related to this schema. Commonly modified by checks using `onattach`. */
146
- bag: Record<string, unknown>;
147
-
148
- /** @internal The set of issues this schema might throw during type checking. */
149
- isst: errors.$ZodIssueBase;
150
-
151
- /** @internal Subject to change, not a public API. */
152
- processJSONSchema?:
153
- | ((ctx: ToJSONSchemaContext, json: JSONSchema.BaseSchema, params: ProcessParams) => void)
154
- | undefined;
155
-
156
- /** An optional method used to override `toJSONSchema` logic. */
157
- toJSONSchema?: () => unknown;
158
-
159
- /** @internal The parent of this schema. Only set during certain clone operations. */
160
- parent?: $ZodType | undefined;
161
- }
162
- /** @internal */
163
- export interface $ZodTypeInternals<out O = unknown, out I = unknown> extends _$ZodTypeInternals {
164
- /** @internal The inferred output type */
165
- output: O; //extends { $out: infer O } ? O : Out;
166
- /** @internal The inferred input type */
167
- input: I; //extends { $in: infer I } ? I : In;
168
- }
169
-
170
- export type $ZodStandardSchema<T> = StandardSchemaV1.Props<core.input<T>, core.output<T>>;
171
-
172
- export type SomeType = { _zod: _$ZodTypeInternals };
173
-
174
- export interface $ZodType<
175
- O = unknown,
176
- I = unknown,
177
- Internals extends $ZodTypeInternals<O, I> = $ZodTypeInternals<O, I>,
178
- > {
179
- _zod: Internals;
180
- "~standard": $ZodStandardSchema<this>;
181
- }
182
- export interface _$ZodType<T extends $ZodTypeInternals = $ZodTypeInternals>
183
- extends $ZodType<T["output"], T["input"], T> {}
184
-
185
- export const $ZodType: core.$constructor<$ZodType> = /*@__PURE__*/ core.$constructor("$ZodType", (inst, def) => {
186
- inst ??= {} as any;
187
-
188
- inst._zod.def = def; // set _def property
189
- inst._zod.bag = inst._zod.bag || {}; // initialize _bag object
190
- inst._zod.version = version;
191
-
192
- const checks = [...(inst._zod.def.checks ?? [])];
193
-
194
- // if inst is itself a checks.$ZodCheck, run it as a check
195
- if (inst._zod.traits.has("$ZodCheck")) {
196
- checks.unshift(inst as any);
197
- }
198
-
199
- for (const ch of checks) {
200
- for (const fn of ch._zod.onattach) {
201
- fn(inst);
202
- }
203
- }
204
-
205
- if (checks.length === 0) {
206
- // deferred initializer
207
- // inst._zod.parse is not yet defined
208
- inst._zod.deferred ??= [];
209
- inst._zod.deferred?.push(() => {
210
- inst._zod.run = inst._zod.parse;
211
- });
212
- } else {
213
- const runChecks = (
214
- payload: ParsePayload,
215
- checks: checks.$ZodCheck<never>[],
216
- ctx?: ParseContextInternal | undefined
217
- ): util.MaybeAsync<ParsePayload> => {
218
- let isAborted = util.aborted(payload);
219
-
220
- let asyncResult!: Promise<unknown> | undefined;
221
- for (const ch of checks) {
222
- if (ch._zod.def.when) {
223
- const shouldRun = ch._zod.def.when(payload);
224
- if (!shouldRun) continue;
225
- } else if (isAborted) {
226
- continue;
227
- }
228
- const currLen = payload.issues.length;
229
- const _ = ch._zod.check(payload as any) as any as ParsePayload;
230
-
231
- if (_ instanceof Promise && ctx?.async === false) {
232
- throw new core.$ZodAsyncError();
233
- }
234
- if (asyncResult || _ instanceof Promise) {
235
- asyncResult = (asyncResult ?? Promise.resolve()).then(async () => {
236
- await _;
237
- const nextLen = payload.issues.length;
238
- if (nextLen === currLen) return;
239
- if (!isAborted) isAborted = util.aborted(payload, currLen);
240
- });
241
- } else {
242
- const nextLen = payload.issues.length;
243
- if (nextLen === currLen) continue;
244
- if (!isAborted) isAborted = util.aborted(payload, currLen);
245
- }
246
- }
247
-
248
- if (asyncResult) {
249
- return asyncResult.then(() => {
250
- return payload;
251
- });
252
- }
253
- return payload;
254
- };
255
-
256
- const handleCanaryResult = (canary: ParsePayload, payload: ParsePayload, ctx: ParseContextInternal) => {
257
- // abort if the canary is aborted
258
- if (util.aborted(canary)) {
259
- canary.aborted = true;
260
- return canary;
261
- }
262
-
263
- // run checks first, then
264
- const checkResult = runChecks(payload, checks, ctx);
265
- if (checkResult instanceof Promise) {
266
- if (ctx.async === false) throw new core.$ZodAsyncError();
267
- return checkResult.then((checkResult) => inst._zod.parse(checkResult, ctx));
268
- }
269
- return inst._zod.parse(checkResult, ctx);
270
- };
271
-
272
- inst._zod.run = (payload, ctx) => {
273
- if (ctx.skipChecks) {
274
- return inst._zod.parse(payload, ctx);
275
- }
276
- if (ctx.direction === "backward") {
277
- // run canary
278
- // initial pass (no checks)
279
- const canary = inst._zod.parse({ value: payload.value, issues: [] }, { ...ctx, skipChecks: true });
280
-
281
- if (canary instanceof Promise) {
282
- return canary.then((canary) => {
283
- return handleCanaryResult(canary, payload, ctx);
284
- });
285
- }
286
-
287
- return handleCanaryResult(canary, payload, ctx);
288
- }
289
-
290
- // forward
291
- const result = inst._zod.parse(payload, ctx);
292
- if (result instanceof Promise) {
293
- if (ctx.async === false) throw new core.$ZodAsyncError();
294
- return result.then((result) => runChecks(result, checks, ctx));
295
- }
296
-
297
- return runChecks(result, checks, ctx);
298
- };
299
- }
300
-
301
- // Lazy initialize ~standard to avoid creating objects for every schema
302
- util.defineLazy(inst, "~standard", () => ({
303
- validate: (value: unknown) => {
304
- try {
305
- const r = safeParse(inst, value);
306
- return r.success ? { value: r.data } : { issues: r.error?.issues };
307
- } catch (_) {
308
- return safeParseAsync(inst, value).then((r) => (r.success ? { value: r.data } : { issues: r.error?.issues }));
309
- }
310
- },
311
- vendor: "zod",
312
- version: 1 as const,
313
- }));
314
- });
315
-
316
- export { clone } from "./util.js";
317
-
318
- //////////////////////////////////////////
319
- //////////////////////////////////////////
320
- ////////// //////////
321
- ////////// $ZodString //////////
322
- ////////// //////////
323
- //////////////////////////////////////////
324
- //////////////////////////////////////////
325
- export interface $ZodStringDef extends $ZodTypeDef {
326
- type: "string";
327
- coerce?: boolean;
328
- checks?: checks.$ZodCheck<string>[];
329
- }
330
-
331
- export interface $ZodStringInternals<Input> extends $ZodTypeInternals<string, Input> {
332
- def: $ZodStringDef;
333
- /** @deprecated Internal API, use with caution (not deprecated) */
334
- pattern: RegExp;
335
-
336
- /** @deprecated Internal API, use with caution (not deprecated) */
337
- isst: errors.$ZodIssueInvalidType;
338
- bag: util.LoosePartial<{
339
- minimum: number;
340
- maximum: number;
341
- patterns: Set<RegExp>;
342
- format: string;
343
- contentEncoding: string;
344
- }>;
345
- }
346
-
347
- export interface $ZodString<Input = unknown> extends _$ZodType<$ZodStringInternals<Input>> {
348
- // _zod: $ZodStringInternals<Input>;
349
- }
350
-
351
- export const $ZodString: core.$constructor<$ZodString> = /*@__PURE__*/ core.$constructor("$ZodString", (inst, def) => {
352
- $ZodType.init(inst, def);
353
- inst._zod.pattern = [...(inst?._zod.bag?.patterns ?? [])].pop() ?? regexes.string(inst._zod.bag);
354
- inst._zod.parse = (payload, _) => {
355
- if (def.coerce)
356
- try {
357
- payload.value = String(payload.value);
358
- } catch (_) {}
359
-
360
- if (typeof payload.value === "string") return payload;
361
-
362
- payload.issues.push({
363
- expected: "string",
364
- code: "invalid_type",
365
-
366
- input: payload.value,
367
- inst,
368
- });
369
- return payload;
370
- };
371
- });
372
-
373
- ////////////////////////////// ZodStringFormat //////////////////////////////
374
-
375
- export interface $ZodStringFormatDef<Format extends string = string>
376
- extends $ZodStringDef,
377
- checks.$ZodCheckStringFormatDef<Format> {}
378
-
379
- export interface $ZodStringFormatInternals<Format extends string = string>
380
- extends $ZodStringInternals<string>,
381
- checks.$ZodCheckStringFormatInternals {
382
- def: $ZodStringFormatDef<Format>;
383
- }
384
- export interface $ZodStringFormat<Format extends string = string> extends $ZodType {
385
- _zod: $ZodStringFormatInternals<Format>;
386
- }
387
-
388
- export const $ZodStringFormat: core.$constructor<$ZodStringFormat> = /*@__PURE__*/ core.$constructor(
389
- "$ZodStringFormat",
390
- (inst, def): void => {
391
- // check initialization must come first
392
- checks.$ZodCheckStringFormat.init(inst, def);
393
- $ZodString.init(inst, def);
394
- }
395
- );
396
-
397
- ////////////////////////////// ZodGUID //////////////////////////////
398
- export interface $ZodGUIDDef extends $ZodStringFormatDef<"guid"> {}
399
- export interface $ZodGUIDInternals extends $ZodStringFormatInternals<"guid"> {}
400
-
401
- export interface $ZodGUID extends $ZodType {
402
- _zod: $ZodGUIDInternals;
403
- }
404
-
405
- export const $ZodGUID: core.$constructor<$ZodGUID> = /*@__PURE__*/ core.$constructor("$ZodGUID", (inst, def): void => {
406
- def.pattern ??= regexes.guid;
407
- $ZodStringFormat.init(inst, def);
408
- });
409
-
410
- ////////////////////////////// ZodUUID //////////////////////////////
411
-
412
- export interface $ZodUUIDDef extends $ZodStringFormatDef<"uuid"> {
413
- version?: "v1" | "v2" | "v3" | "v4" | "v5" | "v6" | "v7" | "v8";
414
- }
415
-
416
- export interface $ZodUUIDInternals extends $ZodStringFormatInternals<"uuid"> {
417
- def: $ZodUUIDDef;
418
- }
419
-
420
- export interface $ZodUUID extends $ZodType {
421
- _zod: $ZodUUIDInternals;
422
- }
423
-
424
- export const $ZodUUID: core.$constructor<$ZodUUID> = /*@__PURE__*/ core.$constructor("$ZodUUID", (inst, def): void => {
425
- if (def.version) {
426
- const versionMap: Record<string, number> = {
427
- v1: 1,
428
- v2: 2,
429
- v3: 3,
430
- v4: 4,
431
- v5: 5,
432
- v6: 6,
433
- v7: 7,
434
- v8: 8,
435
- };
436
- const v = versionMap[def.version];
437
- if (v === undefined) throw new Error(`Invalid UUID version: "${def.version}"`);
438
- def.pattern ??= regexes.uuid(v);
439
- } else def.pattern ??= regexes.uuid();
440
- $ZodStringFormat.init(inst, def);
441
- });
442
-
443
- ////////////////////////////// ZodEmail //////////////////////////////
444
-
445
- export interface $ZodEmailDef extends $ZodStringFormatDef<"email"> {}
446
- export interface $ZodEmailInternals extends $ZodStringFormatInternals<"email"> {}
447
- export interface $ZodEmail extends $ZodType {
448
- _zod: $ZodEmailInternals;
449
- }
450
-
451
- export const $ZodEmail: core.$constructor<$ZodEmail> = /*@__PURE__*/ core.$constructor(
452
- "$ZodEmail",
453
- (inst, def): void => {
454
- def.pattern ??= regexes.email;
455
- $ZodStringFormat.init(inst, def);
456
- }
457
- );
458
-
459
- ////////////////////////////// ZodURL //////////////////////////////
460
-
461
- export interface $ZodURLDef extends $ZodStringFormatDef<"url"> {
462
- hostname?: RegExp | undefined;
463
- protocol?: RegExp | undefined;
464
- normalize?: boolean | undefined;
465
- }
466
- export interface $ZodURLInternals extends $ZodStringFormatInternals<"url"> {
467
- def: $ZodURLDef;
468
- }
469
-
470
- export interface $ZodURL extends $ZodType {
471
- _zod: $ZodURLInternals;
472
- }
473
-
474
- export const $ZodURL: core.$constructor<$ZodURL> = /*@__PURE__*/ core.$constructor("$ZodURL", (inst, def) => {
475
- $ZodStringFormat.init(inst, def);
476
- inst._zod.check = (payload) => {
477
- try {
478
- // Trim whitespace from input
479
- const trimmed = payload.value.trim();
480
- // @ts-ignore
481
- const url = new URL(trimmed);
482
-
483
- if (def.hostname) {
484
- def.hostname.lastIndex = 0;
485
- if (!def.hostname.test(url.hostname)) {
486
- payload.issues.push({
487
- code: "invalid_format",
488
- format: "url",
489
- note: "Invalid hostname",
490
- pattern: def.hostname.source,
491
- input: payload.value,
492
- inst,
493
- continue: !def.abort,
494
- });
495
- }
496
- }
497
-
498
- if (def.protocol) {
499
- def.protocol.lastIndex = 0;
500
- if (!def.protocol.test(url.protocol.endsWith(":") ? url.protocol.slice(0, -1) : url.protocol)) {
501
- payload.issues.push({
502
- code: "invalid_format",
503
- format: "url",
504
- note: "Invalid protocol",
505
- pattern: def.protocol.source,
506
- input: payload.value,
507
- inst,
508
- continue: !def.abort,
509
- });
510
- }
511
- }
512
-
513
- // Set the output value based on normalize flag
514
- if (def.normalize) {
515
- // Use normalized URL
516
- payload.value = url.href;
517
- } else {
518
- // Preserve the original input (trimmed)
519
- payload.value = trimmed;
520
- }
521
-
522
- return;
523
- } catch (_) {
524
- payload.issues.push({
525
- code: "invalid_format",
526
- format: "url",
527
- input: payload.value,
528
- inst,
529
- continue: !def.abort,
530
- });
531
- }
532
- };
533
- });
534
-
535
- ////////////////////////////// ZodEmoji //////////////////////////////
536
-
537
- export interface $ZodEmojiDef extends $ZodStringFormatDef<"emoji"> {}
538
- export interface $ZodEmojiInternals extends $ZodStringFormatInternals<"emoji"> {}
539
-
540
- export interface $ZodEmoji extends $ZodType {
541
- _zod: $ZodEmojiInternals;
542
- }
543
-
544
- export const $ZodEmoji: core.$constructor<$ZodEmoji> = /*@__PURE__*/ core.$constructor(
545
- "$ZodEmoji",
546
- (inst, def): void => {
547
- def.pattern ??= regexes.emoji();
548
- $ZodStringFormat.init(inst, def);
549
- }
550
- );
551
-
552
- ////////////////////////////// ZodNanoID //////////////////////////////
553
-
554
- export interface $ZodNanoIDDef extends $ZodStringFormatDef<"nanoid"> {}
555
- export interface $ZodNanoIDInternals extends $ZodStringFormatInternals<"nanoid"> {}
556
-
557
- export interface $ZodNanoID extends $ZodType {
558
- _zod: $ZodNanoIDInternals;
559
- }
560
-
561
- export const $ZodNanoID: core.$constructor<$ZodNanoID> = /*@__PURE__*/ core.$constructor(
562
- "$ZodNanoID",
563
- (inst, def): void => {
564
- def.pattern ??= regexes.nanoid;
565
- $ZodStringFormat.init(inst, def);
566
- }
567
- );
568
-
569
- ////////////////////////////// ZodCUID //////////////////////////////
570
-
571
- export interface $ZodCUIDDef extends $ZodStringFormatDef<"cuid"> {}
572
- export interface $ZodCUIDInternals extends $ZodStringFormatInternals<"cuid"> {}
573
-
574
- export interface $ZodCUID extends $ZodType {
575
- _zod: $ZodCUIDInternals;
576
- }
577
-
578
- export const $ZodCUID: core.$constructor<$ZodCUID> = /*@__PURE__*/ core.$constructor("$ZodCUID", (inst, def): void => {
579
- def.pattern ??= regexes.cuid;
580
- $ZodStringFormat.init(inst, def);
581
- });
582
-
583
- ////////////////////////////// ZodCUID2 //////////////////////////////
584
-
585
- export interface $ZodCUID2Def extends $ZodStringFormatDef<"cuid2"> {}
586
- export interface $ZodCUID2Internals extends $ZodStringFormatInternals<"cuid2"> {}
587
-
588
- export interface $ZodCUID2 extends $ZodType {
589
- _zod: $ZodCUID2Internals;
590
- }
591
-
592
- export const $ZodCUID2: core.$constructor<$ZodCUID2> = /*@__PURE__*/ core.$constructor(
593
- "$ZodCUID2",
594
- (inst, def): void => {
595
- def.pattern ??= regexes.cuid2;
596
- $ZodStringFormat.init(inst, def);
597
- }
598
- );
599
-
600
- ////////////////////////////// ZodULID //////////////////////////////
601
-
602
- export interface $ZodULIDDef extends $ZodStringFormatDef<"ulid"> {}
603
- export interface $ZodULIDInternals extends $ZodStringFormatInternals<"ulid"> {}
604
-
605
- export interface $ZodULID extends $ZodType {
606
- _zod: $ZodULIDInternals;
607
- }
608
-
609
- export const $ZodULID: core.$constructor<$ZodULID> = /*@__PURE__*/ core.$constructor("$ZodULID", (inst, def): void => {
610
- def.pattern ??= regexes.ulid;
611
- $ZodStringFormat.init(inst, def);
612
- });
613
-
614
- ////////////////////////////// ZodXID //////////////////////////////
615
-
616
- export interface $ZodXIDDef extends $ZodStringFormatDef<"xid"> {}
617
- export interface $ZodXIDInternals extends $ZodStringFormatInternals<"xid"> {}
618
-
619
- export interface $ZodXID extends $ZodType {
620
- _zod: $ZodXIDInternals;
621
- }
622
-
623
- export const $ZodXID: core.$constructor<$ZodXID> = /*@__PURE__*/ core.$constructor("$ZodXID", (inst, def): void => {
624
- def.pattern ??= regexes.xid;
625
- $ZodStringFormat.init(inst, def);
626
- });
627
-
628
- ////////////////////////////// ZodKSUID //////////////////////////////
629
-
630
- export interface $ZodKSUIDDef extends $ZodStringFormatDef<"ksuid"> {}
631
- export interface $ZodKSUIDInternals extends $ZodStringFormatInternals<"ksuid"> {}
632
-
633
- export interface $ZodKSUID extends $ZodType {
634
- _zod: $ZodKSUIDInternals;
635
- }
636
-
637
- export const $ZodKSUID: core.$constructor<$ZodKSUID> = /*@__PURE__*/ core.$constructor(
638
- "$ZodKSUID",
639
- (inst, def): void => {
640
- def.pattern ??= regexes.ksuid;
641
- $ZodStringFormat.init(inst, def);
642
- }
643
- );
644
-
645
- ////////////////////////////// ZodISODateTime //////////////////////////////
646
-
647
- export interface $ZodISODateTimeDef extends $ZodStringFormatDef<"datetime"> {
648
- precision: number | null;
649
- offset: boolean;
650
- local: boolean;
651
- }
652
-
653
- export interface $ZodISODateTimeInternals extends $ZodStringFormatInternals {
654
- def: $ZodISODateTimeDef;
655
- }
656
-
657
- export interface $ZodISODateTime extends $ZodType {
658
- _zod: $ZodISODateTimeInternals;
659
- }
660
-
661
- export const $ZodISODateTime: core.$constructor<$ZodISODateTime> = /*@__PURE__*/ core.$constructor(
662
- "$ZodISODateTime",
663
- (inst, def): void => {
664
- def.pattern ??= regexes.datetime(def);
665
- $ZodStringFormat.init(inst, def);
666
- }
667
- );
668
-
669
- ////////////////////////////// ZodISODate //////////////////////////////
670
-
671
- export interface $ZodISODateDef extends $ZodStringFormatDef<"date"> {}
672
- export interface $ZodISODateInternals extends $ZodStringFormatInternals<"date"> {}
673
-
674
- export interface $ZodISODate extends $ZodType {
675
- _zod: $ZodISODateInternals;
676
- }
677
-
678
- export const $ZodISODate: core.$constructor<$ZodISODate> = /*@__PURE__*/ core.$constructor(
679
- "$ZodISODate",
680
- (inst, def): void => {
681
- def.pattern ??= regexes.date;
682
- $ZodStringFormat.init(inst, def);
683
- }
684
- );
685
-
686
- ////////////////////////////// ZodISOTime //////////////////////////////
687
-
688
- export interface $ZodISOTimeDef extends $ZodStringFormatDef<"time"> {
689
- precision?: number | null;
690
- }
691
-
692
- export interface $ZodISOTimeInternals extends $ZodStringFormatInternals<"time"> {
693
- def: $ZodISOTimeDef;
694
- }
695
-
696
- export interface $ZodISOTime extends $ZodType {
697
- _zod: $ZodISOTimeInternals;
698
- }
699
-
700
- export const $ZodISOTime: core.$constructor<$ZodISOTime> = /*@__PURE__*/ core.$constructor(
701
- "$ZodISOTime",
702
- (inst, def): void => {
703
- def.pattern ??= regexes.time(def);
704
- $ZodStringFormat.init(inst, def);
705
- }
706
- );
707
-
708
- ////////////////////////////// ZodISODuration //////////////////////////////
709
-
710
- export interface $ZodISODurationDef extends $ZodStringFormatDef<"duration"> {}
711
- export interface $ZodISODurationInternals extends $ZodStringFormatInternals<"duration"> {}
712
-
713
- export interface $ZodISODuration extends $ZodType {
714
- _zod: $ZodISODurationInternals;
715
- }
716
-
717
- export const $ZodISODuration: core.$constructor<$ZodISODuration> = /*@__PURE__*/ core.$constructor(
718
- "$ZodISODuration",
719
- (inst, def): void => {
720
- def.pattern ??= regexes.duration;
721
- $ZodStringFormat.init(inst, def);
722
- }
723
- );
724
-
725
- ////////////////////////////// ZodIPv4 //////////////////////////////
726
-
727
- export interface $ZodIPv4Def extends $ZodStringFormatDef<"ipv4"> {
728
- version?: "v4";
729
- }
730
-
731
- export interface $ZodIPv4Internals extends $ZodStringFormatInternals<"ipv4"> {
732
- def: $ZodIPv4Def;
733
- }
734
-
735
- export interface $ZodIPv4 extends $ZodType {
736
- _zod: $ZodIPv4Internals;
737
- }
738
-
739
- export const $ZodIPv4: core.$constructor<$ZodIPv4> = /*@__PURE__*/ core.$constructor("$ZodIPv4", (inst, def): void => {
740
- def.pattern ??= regexes.ipv4;
741
- $ZodStringFormat.init(inst, def);
742
-
743
- inst._zod.bag.format = `ipv4`;
744
- });
745
-
746
- ////////////////////////////// ZodIPv6 //////////////////////////////
747
-
748
- export interface $ZodIPv6Def extends $ZodStringFormatDef<"ipv6"> {
749
- version?: "v6";
750
- }
751
-
752
- export interface $ZodIPv6Internals extends $ZodStringFormatInternals<"ipv6"> {
753
- def: $ZodIPv6Def;
754
- }
755
-
756
- export interface $ZodIPv6 extends $ZodType {
757
- _zod: $ZodIPv6Internals;
758
- }
759
-
760
- export const $ZodIPv6: core.$constructor<$ZodIPv6> = /*@__PURE__*/ core.$constructor("$ZodIPv6", (inst, def): void => {
761
- def.pattern ??= regexes.ipv6;
762
- $ZodStringFormat.init(inst, def);
763
-
764
- inst._zod.bag.format = `ipv6`;
765
-
766
- inst._zod.check = (payload) => {
767
- try {
768
- // @ts-ignore
769
- new URL(`http://[${payload.value}]`);
770
- // return;
771
- } catch {
772
- payload.issues.push({
773
- code: "invalid_format",
774
- format: "ipv6",
775
- input: payload.value,
776
- inst,
777
- continue: !def.abort,
778
- });
779
- }
780
- };
781
- });
782
-
783
- ////////////////////////////// ZodMAC //////////////////////////////
784
- export interface $ZodMACDef extends $ZodStringFormatDef<"mac"> {
785
- delimiter?: string;
786
- }
787
-
788
- export interface $ZodMACInternals extends $ZodStringFormatInternals<"mac"> {
789
- def: $ZodMACDef;
790
- }
791
-
792
- export interface $ZodMAC extends $ZodType {
793
- _zod: $ZodMACInternals;
794
- }
795
-
796
- export const $ZodMAC: core.$constructor<$ZodMAC> = /*@__PURE__*/ core.$constructor("$ZodMAC", (inst, def): void => {
797
- def.pattern ??= regexes.mac(def.delimiter);
798
- $ZodStringFormat.init(inst, def);
799
-
800
- inst._zod.bag.format = `mac`;
801
- });
802
-
803
- ////////////////////////////// ZodCIDRv4 //////////////////////////////
804
-
805
- export interface $ZodCIDRv4Def extends $ZodStringFormatDef<"cidrv4"> {
806
- version?: "v4";
807
- }
808
-
809
- export interface $ZodCIDRv4Internals extends $ZodStringFormatInternals<"cidrv4"> {
810
- def: $ZodCIDRv4Def;
811
- }
812
-
813
- export interface $ZodCIDRv4 extends $ZodType {
814
- _zod: $ZodCIDRv4Internals;
815
- }
816
-
817
- export const $ZodCIDRv4: core.$constructor<$ZodCIDRv4> = /*@__PURE__*/ core.$constructor(
818
- "$ZodCIDRv4",
819
- (inst, def): void => {
820
- def.pattern ??= regexes.cidrv4;
821
- $ZodStringFormat.init(inst, def);
822
- }
823
- );
824
-
825
- ////////////////////////////// ZodCIDRv6 //////////////////////////////
826
-
827
- export interface $ZodCIDRv6Def extends $ZodStringFormatDef<"cidrv6"> {
828
- version?: "v6";
829
- }
830
-
831
- export interface $ZodCIDRv6Internals extends $ZodStringFormatInternals<"cidrv6"> {
832
- def: $ZodCIDRv6Def;
833
- }
834
-
835
- export interface $ZodCIDRv6 extends $ZodType {
836
- _zod: $ZodCIDRv6Internals;
837
- }
838
-
839
- export const $ZodCIDRv6: core.$constructor<$ZodCIDRv6> = /*@__PURE__*/ core.$constructor(
840
- "$ZodCIDRv6",
841
- (inst, def): void => {
842
- def.pattern ??= regexes.cidrv6; // not used for validation
843
- $ZodStringFormat.init(inst, def);
844
-
845
- inst._zod.check = (payload) => {
846
- const parts = payload.value.split("/");
847
- try {
848
- if (parts.length !== 2) throw new Error();
849
- const [address, prefix] = parts;
850
- if (!prefix) throw new Error();
851
- const prefixNum = Number(prefix);
852
- if (`${prefixNum}` !== prefix) throw new Error();
853
- if (prefixNum < 0 || prefixNum > 128) throw new Error();
854
- // @ts-ignore
855
- new URL(`http://[${address}]`);
856
- } catch {
857
- payload.issues.push({
858
- code: "invalid_format",
859
- format: "cidrv6",
860
- input: payload.value,
861
- inst,
862
- continue: !def.abort,
863
- });
864
- }
865
- };
866
- }
867
- );
868
-
869
- ////////////////////////////// ZodBase64 //////////////////////////////
870
- export function isValidBase64(data: string): boolean {
871
- if (data === "") return true;
872
- if (data.length % 4 !== 0) return false;
873
- try {
874
- // @ts-ignore
875
- atob(data);
876
- return true;
877
- } catch {
878
- return false;
879
- }
880
- }
881
-
882
- export interface $ZodBase64Def extends $ZodStringFormatDef<"base64"> {}
883
- export interface $ZodBase64Internals extends $ZodStringFormatInternals<"base64"> {}
884
-
885
- export interface $ZodBase64 extends $ZodType {
886
- _zod: $ZodBase64Internals;
887
- }
888
-
889
- export const $ZodBase64: core.$constructor<$ZodBase64> = /*@__PURE__*/ core.$constructor(
890
- "$ZodBase64",
891
- (inst, def): void => {
892
- def.pattern ??= regexes.base64;
893
- $ZodStringFormat.init(inst, def);
894
-
895
- inst._zod.bag.contentEncoding = "base64";
896
-
897
- inst._zod.check = (payload) => {
898
- if (isValidBase64(payload.value)) return;
899
-
900
- payload.issues.push({
901
- code: "invalid_format",
902
- format: "base64",
903
- input: payload.value,
904
- inst,
905
- continue: !def.abort,
906
- });
907
- };
908
- }
909
- );
910
-
911
- ////////////////////////////// ZodBase64 //////////////////////////////
912
- export function isValidBase64URL(data: string): boolean {
913
- if (!regexes.base64url.test(data)) return false;
914
- const base64 = data.replace(/[-_]/g, (c) => (c === "-" ? "+" : "/"));
915
- const padded = base64.padEnd(Math.ceil(base64.length / 4) * 4, "=");
916
- return isValidBase64(padded);
917
- }
918
-
919
- export interface $ZodBase64URLDef extends $ZodStringFormatDef<"base64url"> {}
920
- export interface $ZodBase64URLInternals extends $ZodStringFormatInternals<"base64url"> {}
921
-
922
- export interface $ZodBase64URL extends $ZodType {
923
- _zod: $ZodBase64URLInternals;
924
- }
925
-
926
- export const $ZodBase64URL: core.$constructor<$ZodBase64URL> = /*@__PURE__*/ core.$constructor(
927
- "$ZodBase64URL",
928
- (inst, def): void => {
929
- def.pattern ??= regexes.base64url;
930
- $ZodStringFormat.init(inst, def);
931
-
932
- inst._zod.bag.contentEncoding = "base64url";
933
-
934
- inst._zod.check = (payload) => {
935
- if (isValidBase64URL(payload.value)) return;
936
-
937
- payload.issues.push({
938
- code: "invalid_format",
939
- format: "base64url",
940
- input: payload.value,
941
- inst,
942
- continue: !def.abort,
943
- });
944
- };
945
- }
946
- );
947
-
948
- ////////////////////////////// ZodE164 //////////////////////////////
949
-
950
- export interface $ZodE164Def extends $ZodStringFormatDef<"e164"> {}
951
- export interface $ZodE164Internals extends $ZodStringFormatInternals<"e164"> {}
952
-
953
- export interface $ZodE164 extends $ZodType {
954
- _zod: $ZodE164Internals;
955
- }
956
-
957
- export const $ZodE164: core.$constructor<$ZodE164> = /*@__PURE__*/ core.$constructor("$ZodE164", (inst, def): void => {
958
- def.pattern ??= regexes.e164;
959
- $ZodStringFormat.init(inst, def);
960
- });
961
-
962
- ////////////////////////////// ZodJWT //////////////////////////////
963
-
964
- export function isValidJWT(token: string, algorithm: util.JWTAlgorithm | null = null): boolean {
965
- try {
966
- const tokensParts = token.split(".");
967
- if (tokensParts.length !== 3) return false;
968
- const [header] = tokensParts;
969
- if (!header) return false;
970
- // @ts-ignore
971
- const parsedHeader = JSON.parse(atob(header));
972
- if ("typ" in parsedHeader && parsedHeader?.typ !== "JWT") return false;
973
- if (!parsedHeader.alg) return false;
974
- if (algorithm && (!("alg" in parsedHeader) || parsedHeader.alg !== algorithm)) return false;
975
- return true;
976
- } catch {
977
- return false;
978
- }
979
- }
980
-
981
- export interface $ZodJWTDef extends $ZodStringFormatDef<"jwt"> {
982
- alg?: util.JWTAlgorithm | undefined;
983
- }
984
-
985
- export interface $ZodJWTInternals extends $ZodStringFormatInternals<"jwt"> {
986
- def: $ZodJWTDef;
987
- }
988
-
989
- export interface $ZodJWT extends $ZodType {
990
- _zod: $ZodJWTInternals;
991
- }
992
-
993
- export const $ZodJWT: core.$constructor<$ZodJWT> = /*@__PURE__*/ core.$constructor("$ZodJWT", (inst, def): void => {
994
- $ZodStringFormat.init(inst, def);
995
- inst._zod.check = (payload) => {
996
- if (isValidJWT(payload.value, def.alg)) return;
997
-
998
- payload.issues.push({
999
- code: "invalid_format",
1000
- format: "jwt",
1001
- input: payload.value,
1002
- inst,
1003
- continue: !def.abort,
1004
- });
1005
- };
1006
- });
1007
-
1008
- ////////////////////////////// ZodCustomStringFormat //////////////////////////////
1009
-
1010
- export interface $ZodCustomStringFormatDef<Format extends string = string> extends $ZodStringFormatDef<Format> {
1011
- fn: (val: string) => unknown;
1012
- }
1013
-
1014
- export interface $ZodCustomStringFormatInternals<Format extends string = string>
1015
- extends $ZodStringFormatInternals<Format> {
1016
- def: $ZodCustomStringFormatDef<Format>;
1017
- }
1018
-
1019
- export interface $ZodCustomStringFormat<Format extends string = string> extends $ZodStringFormat<Format> {
1020
- _zod: $ZodCustomStringFormatInternals<Format>;
1021
- }
1022
-
1023
- export const $ZodCustomStringFormat: core.$constructor<$ZodCustomStringFormat> = /*@__PURE__*/ core.$constructor(
1024
- "$ZodCustomStringFormat",
1025
- (inst, def): void => {
1026
- $ZodStringFormat.init(inst, def);
1027
- inst._zod.check = (payload) => {
1028
- if (def.fn(payload.value)) return;
1029
-
1030
- payload.issues.push({
1031
- code: "invalid_format",
1032
- format: def.format,
1033
- input: payload.value,
1034
- inst,
1035
- continue: !def.abort,
1036
- });
1037
- };
1038
- }
1039
- );
1040
-
1041
- /////////////////////////////////////////
1042
- /////////////////////////////////////////
1043
- ////////// //////////
1044
- ////////// ZodNumber //////////
1045
- ////////// //////////
1046
- /////////////////////////////////////////
1047
- /////////////////////////////////////////
1048
-
1049
- export interface $ZodNumberDef extends $ZodTypeDef {
1050
- type: "number";
1051
- coerce?: boolean;
1052
- // checks: checks.$ZodCheck<number>[];
1053
- }
1054
-
1055
- export interface $ZodNumberInternals<Input = unknown> extends $ZodTypeInternals<number, Input> {
1056
- def: $ZodNumberDef;
1057
- /** @deprecated Internal API, use with caution (not deprecated) */
1058
- pattern: RegExp;
1059
- /** @deprecated Internal API, use with caution (not deprecated) */
1060
- isst: errors.$ZodIssueInvalidType;
1061
- bag: util.LoosePartial<{
1062
- minimum: number;
1063
- maximum: number;
1064
- exclusiveMinimum: number;
1065
- exclusiveMaximum: number;
1066
- format: string;
1067
- pattern: RegExp;
1068
- }>;
1069
- }
1070
-
1071
- export interface $ZodNumber<Input = unknown> extends $ZodType {
1072
- _zod: $ZodNumberInternals<Input>;
1073
- }
1074
-
1075
- export const $ZodNumber: core.$constructor<$ZodNumber> = /*@__PURE__*/ core.$constructor("$ZodNumber", (inst, def) => {
1076
- $ZodType.init(inst, def);
1077
-
1078
- inst._zod.pattern = inst._zod.bag.pattern ?? regexes.number;
1079
- inst._zod.parse = (payload, _ctx) => {
1080
- if (def.coerce)
1081
- try {
1082
- payload.value = Number(payload.value);
1083
- } catch (_) {}
1084
- const input = payload.value;
1085
- if (typeof input === "number" && !Number.isNaN(input) && Number.isFinite(input)) {
1086
- return payload;
1087
- }
1088
-
1089
- const received =
1090
- typeof input === "number"
1091
- ? Number.isNaN(input)
1092
- ? "NaN"
1093
- : !Number.isFinite(input)
1094
- ? "Infinity"
1095
- : undefined
1096
- : undefined;
1097
-
1098
- payload.issues.push({
1099
- expected: "number",
1100
- code: "invalid_type",
1101
-
1102
- input,
1103
- inst,
1104
- ...(received ? { received } : {}),
1105
- });
1106
- return payload;
1107
- };
1108
- });
1109
-
1110
- ///////////////////////////////////////////////
1111
- ////////// ZodNumberFormat //////////
1112
- ///////////////////////////////////////////////
1113
- export interface $ZodNumberFormatDef extends $ZodNumberDef, checks.$ZodCheckNumberFormatDef {}
1114
-
1115
- export interface $ZodNumberFormatInternals extends $ZodNumberInternals<number>, checks.$ZodCheckNumberFormatInternals {
1116
- def: $ZodNumberFormatDef;
1117
- isst: errors.$ZodIssueInvalidType;
1118
- }
1119
-
1120
- export interface $ZodNumberFormat extends $ZodType {
1121
- _zod: $ZodNumberFormatInternals;
1122
- }
1123
-
1124
- export const $ZodNumberFormat: core.$constructor<$ZodNumberFormat> = /*@__PURE__*/ core.$constructor(
1125
- "$ZodNumberFormat",
1126
- (inst, def) => {
1127
- checks.$ZodCheckNumberFormat.init(inst, def);
1128
- $ZodNumber.init(inst, def); // no format checks
1129
- }
1130
- );
1131
-
1132
- ///////////////////////////////////////////
1133
- ///////////////////////////////////////////
1134
- ////////// ///////////
1135
- ////////// $ZodBoolean //////////
1136
- ////////// ///////////
1137
- ///////////////////////////////////////////
1138
- ///////////////////////////////////////////
1139
-
1140
- export interface $ZodBooleanDef extends $ZodTypeDef {
1141
- type: "boolean";
1142
- coerce?: boolean;
1143
- checks?: checks.$ZodCheck<boolean>[];
1144
- }
1145
-
1146
- export interface $ZodBooleanInternals<T = unknown> extends $ZodTypeInternals<boolean, T> {
1147
- pattern: RegExp;
1148
- def: $ZodBooleanDef;
1149
- isst: errors.$ZodIssueInvalidType;
1150
- }
1151
-
1152
- export interface $ZodBoolean<T = unknown> extends $ZodType {
1153
- _zod: $ZodBooleanInternals<T>;
1154
- }
1155
-
1156
- export const $ZodBoolean: core.$constructor<$ZodBoolean> = /*@__PURE__*/ core.$constructor(
1157
- "$ZodBoolean",
1158
- (inst, def) => {
1159
- $ZodType.init(inst, def);
1160
- inst._zod.pattern = regexes.boolean;
1161
-
1162
- inst._zod.parse = (payload, _ctx) => {
1163
- if (def.coerce)
1164
- try {
1165
- payload.value = Boolean(payload.value);
1166
- } catch (_) {}
1167
- const input = payload.value;
1168
- if (typeof input === "boolean") return payload;
1169
- payload.issues.push({
1170
- expected: "boolean",
1171
- code: "invalid_type",
1172
-
1173
- input,
1174
- inst,
1175
- });
1176
- return payload;
1177
- };
1178
- }
1179
- );
1180
-
1181
- //////////////////////////////////////////
1182
- //////////////////////////////////////////
1183
- ////////// //////////
1184
- ////////// $ZodBigInt //////////
1185
- ////////// //////////
1186
- //////////////////////////////////////////
1187
- //////////////////////////////////////////
1188
-
1189
- export interface $ZodBigIntDef extends $ZodTypeDef {
1190
- type: "bigint";
1191
- coerce?: boolean;
1192
- // checks: checks.$ZodCheck<bigint>[];
1193
- }
1194
-
1195
- export interface $ZodBigIntInternals<T = unknown> extends $ZodTypeInternals<bigint, T> {
1196
- pattern: RegExp;
1197
- /** @internal Internal API, use with caution */
1198
- def: $ZodBigIntDef;
1199
- isst: errors.$ZodIssueInvalidType;
1200
- bag: util.LoosePartial<{
1201
- minimum: bigint;
1202
- maximum: bigint;
1203
- format: string;
1204
- }>;
1205
- }
1206
-
1207
- export interface $ZodBigInt<T = unknown> extends $ZodType {
1208
- _zod: $ZodBigIntInternals<T>;
1209
- }
1210
-
1211
- export const $ZodBigInt: core.$constructor<$ZodBigInt> = /*@__PURE__*/ core.$constructor("$ZodBigInt", (inst, def) => {
1212
- $ZodType.init(inst, def);
1213
- inst._zod.pattern = regexes.bigint;
1214
-
1215
- inst._zod.parse = (payload, _ctx) => {
1216
- if (def.coerce)
1217
- try {
1218
- payload.value = BigInt(payload.value);
1219
- } catch (_) {}
1220
-
1221
- if (typeof payload.value === "bigint") return payload;
1222
- payload.issues.push({
1223
- expected: "bigint",
1224
- code: "invalid_type",
1225
-
1226
- input: payload.value,
1227
- inst,
1228
- });
1229
- return payload;
1230
- };
1231
- });
1232
-
1233
- ///////////////////////////////////////////////
1234
- ////////// ZodBigIntFormat //////////
1235
- ///////////////////////////////////////////////
1236
- export interface $ZodBigIntFormatDef extends $ZodBigIntDef, checks.$ZodCheckBigIntFormatDef {
1237
- check: "bigint_format";
1238
- }
1239
-
1240
- export interface $ZodBigIntFormatInternals extends $ZodBigIntInternals<bigint>, checks.$ZodCheckBigIntFormatInternals {
1241
- def: $ZodBigIntFormatDef;
1242
- }
1243
-
1244
- export interface $ZodBigIntFormat extends $ZodType {
1245
- _zod: $ZodBigIntFormatInternals;
1246
- }
1247
-
1248
- export const $ZodBigIntFormat: core.$constructor<$ZodBigIntFormat> = /*@__PURE__*/ core.$constructor(
1249
- "$ZodBigIntFormat",
1250
- (inst, def) => {
1251
- checks.$ZodCheckBigIntFormat.init(inst, def);
1252
- $ZodBigInt.init(inst, def); // no format checks
1253
- }
1254
- );
1255
-
1256
- ////////////////////////////////////////////
1257
- ////////////////////////////////////////////
1258
- ////////// //////////
1259
- ////////// $ZodSymbol //////////
1260
- ////////// //////////
1261
- ////////////////////////////////////////////
1262
- ////////////////////////////////////////////
1263
- export interface $ZodSymbolDef extends $ZodTypeDef {
1264
- type: "symbol";
1265
- }
1266
-
1267
- export interface $ZodSymbolInternals extends $ZodTypeInternals<symbol, symbol> {
1268
- def: $ZodSymbolDef;
1269
- isst: errors.$ZodIssueInvalidType;
1270
- }
1271
-
1272
- export interface $ZodSymbol extends $ZodType {
1273
- _zod: $ZodSymbolInternals;
1274
- }
1275
-
1276
- export const $ZodSymbol: core.$constructor<$ZodSymbol> = /*@__PURE__*/ core.$constructor("$ZodSymbol", (inst, def) => {
1277
- $ZodType.init(inst, def);
1278
-
1279
- inst._zod.parse = (payload, _ctx) => {
1280
- const input = payload.value;
1281
- if (typeof input === "symbol") return payload;
1282
- payload.issues.push({
1283
- expected: "symbol",
1284
- code: "invalid_type",
1285
-
1286
- input,
1287
- inst,
1288
- });
1289
- return payload;
1290
- };
1291
- });
1292
-
1293
- ////////////////////////////////////////////
1294
- ////////////////////////////////////////////
1295
- ////////// //////////
1296
- ////////// $ZodUndefined //////////
1297
- ////////// //////////
1298
- ////////////////////////////////////////////
1299
- ////////////////////////////////////////////
1300
- export interface $ZodUndefinedDef extends $ZodTypeDef {
1301
- type: "undefined";
1302
- }
1303
-
1304
- export interface $ZodUndefinedInternals extends $ZodTypeInternals<undefined, undefined> {
1305
- pattern: RegExp;
1306
- def: $ZodUndefinedDef;
1307
- values: util.PrimitiveSet;
1308
- isst: errors.$ZodIssueInvalidType;
1309
- }
1310
-
1311
- export interface $ZodUndefined extends $ZodType {
1312
- _zod: $ZodUndefinedInternals;
1313
- }
1314
-
1315
- export const $ZodUndefined: core.$constructor<$ZodUndefined> = /*@__PURE__*/ core.$constructor(
1316
- "$ZodUndefined",
1317
- (inst, def) => {
1318
- $ZodType.init(inst, def);
1319
- inst._zod.pattern = regexes.undefined;
1320
- inst._zod.values = new Set([undefined]);
1321
- inst._zod.optin = "optional";
1322
- inst._zod.optout = "optional";
1323
-
1324
- inst._zod.parse = (payload, _ctx) => {
1325
- const input = payload.value;
1326
- if (typeof input === "undefined") return payload;
1327
- payload.issues.push({
1328
- expected: "undefined",
1329
- code: "invalid_type",
1330
-
1331
- input,
1332
- inst,
1333
- });
1334
- return payload;
1335
- };
1336
- }
1337
- );
1338
-
1339
- ///////////////////////////////////////
1340
- ///////////////////////////////////////
1341
- ////////// //////////
1342
- ////////// $ZodNull /////////
1343
- ////////// //////////
1344
- ///////////////////////////////////////
1345
- ///////////////////////////////////////
1346
-
1347
- export interface $ZodNullDef extends $ZodTypeDef {
1348
- type: "null";
1349
- }
1350
-
1351
- export interface $ZodNullInternals extends $ZodTypeInternals<null, null> {
1352
- pattern: RegExp;
1353
- def: $ZodNullDef;
1354
- values: util.PrimitiveSet;
1355
- isst: errors.$ZodIssueInvalidType;
1356
- }
1357
-
1358
- export interface $ZodNull extends $ZodType {
1359
- _zod: $ZodNullInternals;
1360
- }
1361
-
1362
- export const $ZodNull: core.$constructor<$ZodNull> = /*@__PURE__*/ core.$constructor("$ZodNull", (inst, def) => {
1363
- $ZodType.init(inst, def);
1364
- inst._zod.pattern = regexes.null;
1365
- inst._zod.values = new Set([null]);
1366
-
1367
- inst._zod.parse = (payload, _ctx) => {
1368
- const input = payload.value;
1369
- if (input === null) return payload;
1370
- payload.issues.push({
1371
- expected: "null",
1372
- code: "invalid_type",
1373
-
1374
- input,
1375
- inst,
1376
- });
1377
- return payload;
1378
- };
1379
- });
1380
-
1381
- //////////////////////////////////////
1382
- //////////////////////////////////////
1383
- ////////// //////////
1384
- ////////// $ZodAny //////////
1385
- ////////// //////////
1386
- //////////////////////////////////////
1387
- //////////////////////////////////////
1388
-
1389
- export interface $ZodAnyDef extends $ZodTypeDef {
1390
- type: "any";
1391
- }
1392
-
1393
- export interface $ZodAnyInternals extends $ZodTypeInternals<any, any> {
1394
- def: $ZodAnyDef;
1395
- isst: never;
1396
- }
1397
-
1398
- export interface $ZodAny extends $ZodType {
1399
- _zod: $ZodAnyInternals;
1400
- }
1401
-
1402
- export const $ZodAny: core.$constructor<$ZodAny> = /*@__PURE__*/ core.$constructor("$ZodAny", (inst, def) => {
1403
- $ZodType.init(inst, def);
1404
-
1405
- inst._zod.parse = (payload) => payload;
1406
- });
1407
-
1408
- //////////////////////////////////////////
1409
- //////////////////////////////////////////
1410
- ////////// //////////
1411
- ////////// $ZodUnknown //////////
1412
- ////////// //////////
1413
- //////////////////////////////////////////
1414
- //////////////////////////////////////////
1415
-
1416
- export interface $ZodUnknownDef extends $ZodTypeDef {
1417
- type: "unknown";
1418
- }
1419
-
1420
- export interface $ZodUnknownInternals extends $ZodTypeInternals<unknown, unknown> {
1421
- def: $ZodUnknownDef;
1422
- isst: never;
1423
- }
1424
-
1425
- export interface $ZodUnknown extends $ZodType {
1426
- _zod: $ZodUnknownInternals;
1427
- }
1428
-
1429
- export const $ZodUnknown: core.$constructor<$ZodUnknown> = /*@__PURE__*/ core.$constructor(
1430
- "$ZodUnknown",
1431
- (inst, def) => {
1432
- $ZodType.init(inst, def);
1433
-
1434
- inst._zod.parse = (payload) => payload;
1435
- }
1436
- );
1437
-
1438
- /////////////////////////////////////////
1439
- /////////////////////////////////////////
1440
- ////////// //////////
1441
- ////////// $ZodNever //////////
1442
- ////////// //////////
1443
- /////////////////////////////////////////
1444
- /////////////////////////////////////////
1445
-
1446
- export interface $ZodNeverDef extends $ZodTypeDef {
1447
- type: "never";
1448
- }
1449
-
1450
- export interface $ZodNeverInternals extends $ZodTypeInternals<never, never> {
1451
- def: $ZodNeverDef;
1452
- isst: errors.$ZodIssueInvalidType;
1453
- }
1454
-
1455
- export interface $ZodNever extends $ZodType {
1456
- _zod: $ZodNeverInternals;
1457
- }
1458
-
1459
- export const $ZodNever: core.$constructor<$ZodNever> = /*@__PURE__*/ core.$constructor("$ZodNever", (inst, def) => {
1460
- $ZodType.init(inst, def);
1461
- inst._zod.parse = (payload, _ctx) => {
1462
- payload.issues.push({
1463
- expected: "never",
1464
- code: "invalid_type",
1465
-
1466
- input: payload.value,
1467
- inst,
1468
- });
1469
- return payload;
1470
- };
1471
- });
1472
-
1473
- ////////////////////////////////////////
1474
- ////////////////////////////////////////
1475
- ////////// //////////
1476
- ////////// $ZodVoid //////////
1477
- ////////// //////////
1478
- ////////////////////////////////////////
1479
- ////////////////////////////////////////
1480
-
1481
- export interface $ZodVoidDef extends $ZodTypeDef {
1482
- type: "void";
1483
- }
1484
-
1485
- export interface $ZodVoidInternals extends $ZodTypeInternals<void, void> {
1486
- def: $ZodVoidDef;
1487
- isst: errors.$ZodIssueInvalidType;
1488
- }
1489
-
1490
- export interface $ZodVoid extends $ZodType {
1491
- _zod: $ZodVoidInternals;
1492
- }
1493
-
1494
- export const $ZodVoid: core.$constructor<$ZodVoid> = /*@__PURE__*/ core.$constructor("$ZodVoid", (inst, def) => {
1495
- $ZodType.init(inst, def);
1496
-
1497
- inst._zod.parse = (payload, _ctx) => {
1498
- const input = payload.value;
1499
- if (typeof input === "undefined") return payload;
1500
- payload.issues.push({
1501
- expected: "void",
1502
- code: "invalid_type",
1503
-
1504
- input,
1505
- inst,
1506
- });
1507
- return payload;
1508
- };
1509
- });
1510
-
1511
- ///////////////////////////////////////
1512
- ///////////////////////////////////////
1513
- ////////// ////////
1514
- ////////// $ZodDate ////////
1515
- ////////// ////////
1516
- ///////////////////////////////////////
1517
- ///////////////////////////////////////
1518
- export interface $ZodDateDef extends $ZodTypeDef {
1519
- type: "date";
1520
- coerce?: boolean;
1521
- }
1522
-
1523
- export interface $ZodDateInternals<T = unknown> extends $ZodTypeInternals<Date, T> {
1524
- def: $ZodDateDef;
1525
- isst: errors.$ZodIssueInvalidType; // | errors.$ZodIssueInvalidDate;
1526
- bag: util.LoosePartial<{
1527
- minimum: Date;
1528
- maximum: Date;
1529
- format: string;
1530
- }>;
1531
- }
1532
-
1533
- export interface $ZodDate<T = unknown> extends $ZodType {
1534
- _zod: $ZodDateInternals<T>;
1535
- }
1536
-
1537
- export const $ZodDate: core.$constructor<$ZodDate> = /*@__PURE__*/ core.$constructor("$ZodDate", (inst, def) => {
1538
- $ZodType.init(inst, def);
1539
-
1540
- inst._zod.parse = (payload, _ctx) => {
1541
- if (def.coerce) {
1542
- try {
1543
- payload.value = new Date(payload.value as string | number | Date);
1544
- } catch (_err: any) {}
1545
- }
1546
- const input = payload.value;
1547
-
1548
- const isDate = input instanceof Date;
1549
- const isValidDate = isDate && !Number.isNaN(input.getTime());
1550
- if (isValidDate) return payload;
1551
- payload.issues.push({
1552
- expected: "date",
1553
- code: "invalid_type",
1554
-
1555
- input,
1556
- ...(isDate ? { received: "Invalid Date" } : {}),
1557
- inst,
1558
- });
1559
-
1560
- return payload;
1561
- };
1562
- });
1563
-
1564
- /////////////////////////////////////////
1565
- /////////////////////////////////////////
1566
- ////////// //////////
1567
- ////////// $ZodArray //////////
1568
- ////////// //////////
1569
- /////////////////////////////////////////
1570
- /////////////////////////////////////////
1571
-
1572
- export interface $ZodArrayDef<T extends SomeType = $ZodType> extends $ZodTypeDef {
1573
- type: "array";
1574
- element: T;
1575
- }
1576
-
1577
- export interface $ZodArrayInternals<T extends SomeType = $ZodType> extends _$ZodTypeInternals {
1578
- //$ZodTypeInternals<core.output<T>[], core.input<T>[]> {
1579
- def: $ZodArrayDef<T>;
1580
- isst: errors.$ZodIssueInvalidType;
1581
- output: core.output<T>[];
1582
- input: core.input<T>[];
1583
- }
1584
-
1585
- export interface $ZodArray<T extends SomeType = $ZodType> extends $ZodType<any, any, $ZodArrayInternals<T>> {}
1586
-
1587
- function handleArrayResult(result: ParsePayload<any>, final: ParsePayload<any[]>, index: number) {
1588
- if (result.issues.length) {
1589
- final.issues.push(...util.prefixIssues(index, result.issues));
1590
- }
1591
- final.value[index] = result.value;
1592
- }
1593
-
1594
- export const $ZodArray: core.$constructor<$ZodArray> = /*@__PURE__*/ core.$constructor("$ZodArray", (inst, def) => {
1595
- $ZodType.init(inst, def);
1596
-
1597
- inst._zod.parse = (payload, ctx) => {
1598
- const input = payload.value;
1599
-
1600
- if (!Array.isArray(input)) {
1601
- payload.issues.push({
1602
- expected: "array",
1603
- code: "invalid_type",
1604
-
1605
- input,
1606
- inst,
1607
- });
1608
- return payload;
1609
- }
1610
-
1611
- payload.value = Array(input.length);
1612
- const proms: Promise<any>[] = [];
1613
- for (let i = 0; i < input.length; i++) {
1614
- const item = input[i];
1615
- const result = def.element._zod.run(
1616
- {
1617
- value: item,
1618
- issues: [],
1619
- },
1620
- ctx
1621
- );
1622
-
1623
- if (result instanceof Promise) {
1624
- proms.push(result.then((result) => handleArrayResult(result, payload, i)));
1625
- } else {
1626
- handleArrayResult(result, payload, i);
1627
- }
1628
- }
1629
-
1630
- if (proms.length) {
1631
- return Promise.all(proms).then(() => payload);
1632
- }
1633
-
1634
- return payload; //handleArrayResultsAsync(parseResults, final);
1635
- };
1636
- });
1637
-
1638
- //////////////////////////////////////////
1639
- //////////////////////////////////////////
1640
- ////////// //////////
1641
- ////////// $ZodObject //////////
1642
- ////////// //////////
1643
- //////////////////////////////////////////
1644
- //////////////////////////////////////////
1645
-
1646
- type OptionalOutSchema = { _zod: { optout: "optional" } };
1647
- type OptionalInSchema = { _zod: { optin: "optional" } };
1648
-
1649
- export type $InferObjectOutput<T extends $ZodLooseShape, Extra extends Record<string, unknown>> = string extends keyof T
1650
- ? util.IsAny<T[keyof T]> extends true
1651
- ? Record<string, unknown>
1652
- : Record<string, core.output<T[keyof T]>>
1653
- : keyof (T & Extra) extends never
1654
- ? Record<string, never>
1655
- : util.Prettify<
1656
- {
1657
- -readonly [k in keyof T as T[k] extends OptionalOutSchema ? never : k]: T[k]["_zod"]["output"];
1658
- } & {
1659
- -readonly [k in keyof T as T[k] extends OptionalOutSchema ? k : never]?: T[k]["_zod"]["output"];
1660
- } & Extra
1661
- >;
1662
-
1663
- // experimental
1664
- // export type $InferObjectOutput<T extends $ZodLooseShape, Extra extends Record<string, unknown>> = keyof (T &
1665
- // Extra) extends never
1666
- // ? Record<string, never>
1667
- // : string extends keyof T
1668
- // ? util.Prettify<
1669
- // {
1670
- // [k: string]: util.IsAny<T[string]["_zod"]["output"]> extends true ? unknown : T[string]["_zod"]["output"];
1671
- // } & $InferObjectOutputNoIndex<util.OmitIndexSignature<T>, Extra>
1672
- // >
1673
- // : util.Prettify<$InferObjectOutputNoIndex<T, Extra>>;
1674
-
1675
- // export type $InferObjectOutputNoIndex<T extends $ZodLooseShape, Extra extends Record<string, unknown>> = {
1676
- // [k in keyof T as string extends k
1677
- // ? never
1678
- // : k extends string
1679
- // ? T[k] extends OptionalOutSchema
1680
- // ? never
1681
- // : k
1682
- // : never]: T[k]["_zod"]["output"];
1683
- // } & {
1684
- // [k in keyof T as string extends k
1685
- // ? never
1686
- // : k extends string
1687
- // ? T[k] extends OptionalOutSchema
1688
- // ? k
1689
- // : never
1690
- // : never]?: T[k]["_zod"]["output"];
1691
- // } & Extra;
1692
-
1693
- export type $InferObjectInput<T extends $ZodLooseShape, Extra extends Record<string, unknown>> = string extends keyof T
1694
- ? util.IsAny<T[keyof T]> extends true
1695
- ? Record<string, unknown>
1696
- : Record<string, core.input<T[keyof T]>>
1697
- : keyof (T & Extra) extends never
1698
- ? Record<string, never>
1699
- : util.Prettify<
1700
- {
1701
- -readonly [k in keyof T as T[k] extends OptionalInSchema ? never : k]: T[k]["_zod"]["input"];
1702
- } & {
1703
- -readonly [k in keyof T as T[k] extends OptionalInSchema ? k : never]?: T[k]["_zod"]["input"];
1704
- } & Extra
1705
- >;
1706
-
1707
- function handlePropertyResult(
1708
- result: ParsePayload,
1709
- final: ParsePayload,
1710
- key: PropertyKey,
1711
- input: any,
1712
- isOptionalOut: boolean
1713
- ) {
1714
- if (result.issues.length) {
1715
- // For optional-out schemas, ignore errors on absent keys
1716
- if (isOptionalOut && !(key in input)) {
1717
- return;
1718
- }
1719
- final.issues.push(...util.prefixIssues(key, result.issues));
1720
- }
1721
-
1722
- if (result.value === undefined) {
1723
- if (key in input) {
1724
- (final.value as any)[key] = undefined;
1725
- }
1726
- } else {
1727
- (final.value as any)[key] = result.value;
1728
- }
1729
- }
1730
-
1731
- export type $ZodObjectConfig = { out: Record<string, unknown>; in: Record<string, unknown> };
1732
-
1733
- export type $loose = {
1734
- out: Record<string, unknown>;
1735
- in: Record<string, unknown>;
1736
- };
1737
- export type $strict = {
1738
- out: {};
1739
- in: {};
1740
- };
1741
- export type $strip = {
1742
- out: {};
1743
- in: {};
1744
- };
1745
-
1746
- export type $catchall<T extends SomeType> = {
1747
- out: { [k: string]: core.output<T> };
1748
- in: { [k: string]: core.input<T> };
1749
- };
1750
-
1751
- export type $ZodShape = Readonly<{ [k: string]: $ZodType }>;
1752
-
1753
- export interface $ZodObjectDef<Shape extends $ZodShape = $ZodShape> extends $ZodTypeDef {
1754
- type: "object";
1755
- shape: Shape;
1756
- catchall?: $ZodType | undefined;
1757
- }
1758
-
1759
- export interface $ZodObjectInternals<
1760
- /** @ts-ignore Cast variance */
1761
- out Shape extends $ZodShape = $ZodShape,
1762
- out Config extends $ZodObjectConfig = $ZodObjectConfig,
1763
- > extends _$ZodTypeInternals {
1764
- def: $ZodObjectDef<Shape>;
1765
- config: Config;
1766
- isst: errors.$ZodIssueInvalidType | errors.$ZodIssueUnrecognizedKeys;
1767
- propValues: util.PropValues;
1768
- output: $InferObjectOutput<Shape, Config["out"]>;
1769
- input: $InferObjectInput<Shape, Config["in"]>;
1770
- optin?: "optional" | undefined;
1771
- optout?: "optional" | undefined;
1772
- }
1773
- export type $ZodLooseShape = Record<string, any>;
1774
-
1775
- export interface $ZodObject<
1776
- /** @ts-ignore Cast variance */
1777
- out Shape extends Readonly<$ZodShape> = Readonly<$ZodShape>,
1778
- out Params extends $ZodObjectConfig = $ZodObjectConfig,
1779
- > extends $ZodType<any, any, $ZodObjectInternals<Shape, Params>> {}
1780
-
1781
- function normalizeDef(def: $ZodObjectDef) {
1782
- const keys = Object.keys(def.shape);
1783
- for (const k of keys) {
1784
- if (!def.shape?.[k]?._zod?.traits?.has("$ZodType")) {
1785
- throw new Error(`Invalid element at key "${k}": expected a Zod schema`);
1786
- }
1787
- }
1788
- const okeys = util.optionalKeys(def.shape);
1789
-
1790
- return {
1791
- ...def,
1792
- keys,
1793
- keySet: new Set(keys),
1794
- numKeys: keys.length,
1795
- optionalKeys: new Set(okeys),
1796
- };
1797
- }
1798
-
1799
- function handleCatchall(
1800
- proms: Promise<any>[],
1801
- input: any,
1802
- payload: ParsePayload,
1803
- ctx: ParseContext,
1804
- def: ReturnType<typeof normalizeDef>,
1805
- inst: $ZodObject
1806
- ) {
1807
- const unrecognized: string[] = [];
1808
- // iterate over input keys
1809
- const keySet = def.keySet;
1810
- const _catchall = def.catchall!._zod;
1811
- const t = _catchall.def.type;
1812
- const isOptionalOut = _catchall.optout === "optional";
1813
- for (const key in input) {
1814
- if (keySet.has(key)) continue;
1815
- if (t === "never") {
1816
- unrecognized.push(key);
1817
- continue;
1818
- }
1819
- const r = _catchall.run({ value: input[key], issues: [] }, ctx);
1820
-
1821
- if (r instanceof Promise) {
1822
- proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, isOptionalOut)));
1823
- } else {
1824
- handlePropertyResult(r, payload, key, input, isOptionalOut);
1825
- }
1826
- }
1827
-
1828
- if (unrecognized.length) {
1829
- payload.issues.push({
1830
- code: "unrecognized_keys",
1831
- keys: unrecognized,
1832
- input,
1833
- inst,
1834
- });
1835
- }
1836
-
1837
- if (!proms.length) return payload;
1838
- return Promise.all(proms).then(() => {
1839
- return payload;
1840
- });
1841
- }
1842
-
1843
- export const $ZodObject: core.$constructor<$ZodObject> = /*@__PURE__*/ core.$constructor("$ZodObject", (inst, def) => {
1844
- // requires cast because technically $ZodObject doesn't extend
1845
- $ZodType.init(inst, def);
1846
- // const sh = def.shape;
1847
- const desc = Object.getOwnPropertyDescriptor(def, "shape");
1848
- if (!desc?.get) {
1849
- const sh = def.shape;
1850
- Object.defineProperty(def, "shape", {
1851
- get: () => {
1852
- const newSh = { ...sh };
1853
- Object.defineProperty(def, "shape", {
1854
- value: newSh,
1855
- });
1856
-
1857
- return newSh;
1858
- },
1859
- });
1860
- }
1861
-
1862
- const _normalized = util.cached(() => normalizeDef(def));
1863
-
1864
- util.defineLazy(inst._zod, "propValues", () => {
1865
- const shape = def.shape;
1866
- const propValues: util.PropValues = {};
1867
- for (const key in shape) {
1868
- const field = shape[key]!._zod;
1869
- if (field.values) {
1870
- propValues[key] ??= new Set();
1871
- for (const v of field.values) propValues[key].add(v);
1872
- }
1873
- }
1874
- return propValues;
1875
- });
1876
-
1877
- const isObject = util.isObject;
1878
- const catchall = def.catchall;
1879
-
1880
- let value!: typeof _normalized.value;
1881
-
1882
- inst._zod.parse = (payload, ctx) => {
1883
- value ??= _normalized.value;
1884
- const input = payload.value;
1885
- if (!isObject(input)) {
1886
- payload.issues.push({
1887
- expected: "object",
1888
- code: "invalid_type",
1889
- input,
1890
- inst,
1891
- });
1892
- return payload;
1893
- }
1894
-
1895
- payload.value = {};
1896
-
1897
- const proms: Promise<any>[] = [];
1898
- const shape = value.shape;
1899
-
1900
- for (const key of value.keys) {
1901
- const el = shape[key]!;
1902
- const isOptionalOut = el._zod.optout === "optional";
1903
-
1904
- const r = el._zod.run({ value: input[key], issues: [] }, ctx);
1905
- if (r instanceof Promise) {
1906
- proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, isOptionalOut)));
1907
- } else {
1908
- handlePropertyResult(r, payload, key, input, isOptionalOut);
1909
- }
1910
- }
1911
-
1912
- if (!catchall) {
1913
- return proms.length ? Promise.all(proms).then(() => payload) : payload;
1914
- }
1915
-
1916
- return handleCatchall(proms, input, payload, ctx, _normalized.value, inst);
1917
- };
1918
- });
1919
-
1920
- export const $ZodObjectJIT: core.$constructor<$ZodObject> = /*@__PURE__*/ core.$constructor(
1921
- "$ZodObjectJIT",
1922
- (inst, def) => {
1923
- // requires cast because technically $ZodObject doesn't extend
1924
- $ZodObject.init(inst, def);
1925
-
1926
- const superParse = inst._zod.parse;
1927
- const _normalized = util.cached(() => normalizeDef(def));
1928
-
1929
- const generateFastpass = (shape: any) => {
1930
- const doc = new Doc(["shape", "payload", "ctx"]);
1931
- const normalized = _normalized.value;
1932
-
1933
- const parseStr = (key: string) => {
1934
- const k = util.esc(key);
1935
- return `shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`;
1936
- };
1937
-
1938
- doc.write(`const input = payload.value;`);
1939
-
1940
- const ids: any = Object.create(null);
1941
- let counter = 0;
1942
- for (const key of normalized.keys) {
1943
- ids[key] = `key_${counter++}`;
1944
- }
1945
-
1946
- // A: preserve key order {
1947
- doc.write(`const newResult = {};`);
1948
- for (const key of normalized.keys) {
1949
- const id = ids[key];
1950
- const k = util.esc(key);
1951
- const schema = shape[key];
1952
- const isOptionalOut = schema?._zod?.optout === "optional";
1953
-
1954
- doc.write(`const ${id} = ${parseStr(key)};`);
1955
-
1956
- if (isOptionalOut) {
1957
- // For optional-out schemas, ignore errors on absent keys
1958
- doc.write(`
1959
- if (${id}.issues.length) {
1960
- if (${k} in input) {
1961
- payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
1962
- ...iss,
1963
- path: iss.path ? [${k}, ...iss.path] : [${k}]
1964
- })));
1965
- }
1966
- }
1967
-
1968
- if (${id}.value === undefined) {
1969
- if (${k} in input) {
1970
- newResult[${k}] = undefined;
1971
- }
1972
- } else {
1973
- newResult[${k}] = ${id}.value;
1974
- }
1975
-
1976
- `);
1977
- } else {
1978
- doc.write(`
1979
- if (${id}.issues.length) {
1980
- payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
1981
- ...iss,
1982
- path: iss.path ? [${k}, ...iss.path] : [${k}]
1983
- })));
1984
- }
1985
-
1986
- if (${id}.value === undefined) {
1987
- if (${k} in input) {
1988
- newResult[${k}] = undefined;
1989
- }
1990
- } else {
1991
- newResult[${k}] = ${id}.value;
1992
- }
1993
-
1994
- `);
1995
- }
1996
- }
1997
-
1998
- doc.write(`payload.value = newResult;`);
1999
- doc.write(`return payload;`);
2000
- const fn = doc.compile();
2001
- return (payload: any, ctx: any) => fn(shape, payload, ctx);
2002
- };
2003
-
2004
- let fastpass!: ReturnType<typeof generateFastpass>;
2005
-
2006
- const isObject = util.isObject;
2007
- const jit = !core.globalConfig.jitless;
2008
- const allowsEval = util.allowsEval;
2009
-
2010
- const fastEnabled = jit && allowsEval.value; // && !def.catchall;
2011
- const catchall = def.catchall;
2012
-
2013
- let value!: typeof _normalized.value;
2014
-
2015
- inst._zod.parse = (payload, ctx) => {
2016
- value ??= _normalized.value;
2017
- const input = payload.value;
2018
- if (!isObject(input)) {
2019
- payload.issues.push({
2020
- expected: "object",
2021
- code: "invalid_type",
2022
- input,
2023
- inst,
2024
- });
2025
- return payload;
2026
- }
2027
-
2028
- if (jit && fastEnabled && ctx?.async === false && ctx.jitless !== true) {
2029
- // always synchronous
2030
- if (!fastpass) fastpass = generateFastpass(def.shape);
2031
- payload = fastpass(payload, ctx);
2032
-
2033
- if (!catchall) return payload;
2034
- return handleCatchall([], input, payload, ctx, value, inst);
2035
- }
2036
-
2037
- return superParse(payload, ctx);
2038
- };
2039
- }
2040
- );
2041
-
2042
- /////////////////////////////////////////
2043
- /////////////////////////////////////////
2044
- ////////// ///////////
2045
- ////////// $ZodUnion //////////
2046
- ////////// ///////////
2047
- /////////////////////////////////////////
2048
- /////////////////////////////////////////
2049
- // use generic to distribute union types
2050
- export type $InferUnionOutput<T extends SomeType> = T extends any ? core.output<T> : never;
2051
- export type $InferUnionInput<T extends SomeType> = T extends any ? core.input<T> : never;
2052
- export interface $ZodUnionDef<Options extends readonly SomeType[] = readonly $ZodType[]> extends $ZodTypeDef {
2053
- type: "union";
2054
- options: Options;
2055
- inclusive?: boolean;
2056
- }
2057
-
2058
- type IsOptionalIn<T extends SomeType> = T extends OptionalInSchema ? true : false;
2059
- type IsOptionalOut<T extends SomeType> = T extends OptionalOutSchema ? true : false;
2060
-
2061
- export interface $ZodUnionInternals<T extends readonly SomeType[] = readonly $ZodType[]> extends _$ZodTypeInternals {
2062
- def: $ZodUnionDef<T>;
2063
- isst: errors.$ZodIssueInvalidUnion;
2064
- pattern: T[number]["_zod"]["pattern"];
2065
- values: T[number]["_zod"]["values"]; //GetValues<T[number]>;
2066
- output: $InferUnionOutput<T[number]>;
2067
- input: $InferUnionInput<T[number]>;
2068
- // if any element in the union is optional, then the union is optional
2069
- optin: IsOptionalIn<T[number]> extends false ? "optional" | undefined : "optional";
2070
- optout: IsOptionalOut<T[number]> extends false ? "optional" | undefined : "optional";
2071
- }
2072
-
2073
- export interface $ZodUnion<T extends readonly SomeType[] = readonly $ZodType[]>
2074
- extends $ZodType<any, any, $ZodUnionInternals<T>> {
2075
- _zod: $ZodUnionInternals<T>;
2076
- }
2077
-
2078
- function handleUnionResults(results: ParsePayload[], final: ParsePayload, inst: $ZodUnion, ctx?: ParseContext) {
2079
- for (const result of results) {
2080
- if (result.issues.length === 0) {
2081
- final.value = result.value;
2082
- return final;
2083
- }
2084
- }
2085
-
2086
- const nonaborted = results.filter((r) => !util.aborted(r));
2087
- if (nonaborted.length === 1) {
2088
- final.value = nonaborted[0].value;
2089
- return nonaborted[0];
2090
- }
2091
-
2092
- final.issues.push({
2093
- code: "invalid_union",
2094
-
2095
- input: final.value,
2096
- inst,
2097
- errors: results.map((result) => result.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config()))),
2098
- });
2099
-
2100
- return final;
2101
- }
2102
-
2103
- export const $ZodUnion: core.$constructor<$ZodUnion> = /*@__PURE__*/ core.$constructor("$ZodUnion", (inst, def) => {
2104
- $ZodType.init(inst, def);
2105
-
2106
- util.defineLazy(inst._zod, "optin", () =>
2107
- def.options.some((o) => o._zod.optin === "optional") ? "optional" : undefined
2108
- );
2109
-
2110
- util.defineLazy(inst._zod, "optout", () =>
2111
- def.options.some((o) => o._zod.optout === "optional") ? "optional" : undefined
2112
- );
2113
-
2114
- util.defineLazy(inst._zod, "values", () => {
2115
- if (def.options.every((o) => o._zod.values)) {
2116
- return new Set<util.Primitive>(def.options.flatMap((option) => Array.from(option._zod.values!)));
2117
- }
2118
- return undefined;
2119
- });
2120
-
2121
- util.defineLazy(inst._zod, "pattern", () => {
2122
- if (def.options.every((o) => o._zod.pattern)) {
2123
- const patterns = def.options.map((o) => o._zod.pattern);
2124
- return new RegExp(`^(${patterns.map((p) => util.cleanRegex(p!.source)).join("|")})$`);
2125
- }
2126
- return undefined;
2127
- });
2128
-
2129
- const single = def.options.length === 1;
2130
- const first = def.options[0]._zod.run;
2131
-
2132
- inst._zod.parse = (payload, ctx) => {
2133
- if (single) {
2134
- return first(payload, ctx);
2135
- }
2136
- let async = false;
2137
-
2138
- const results: util.MaybeAsync<ParsePayload>[] = [];
2139
- for (const option of def.options) {
2140
- const result = option._zod.run(
2141
- {
2142
- value: payload.value,
2143
- issues: [],
2144
- },
2145
- ctx
2146
- );
2147
- if (result instanceof Promise) {
2148
- results.push(result);
2149
- async = true;
2150
- } else {
2151
- if (result.issues.length === 0) return result;
2152
- results.push(result);
2153
- }
2154
- }
2155
-
2156
- if (!async) return handleUnionResults(results as ParsePayload[], payload, inst, ctx);
2157
- return Promise.all(results).then((results) => {
2158
- return handleUnionResults(results as ParsePayload[], payload, inst, ctx);
2159
- });
2160
- };
2161
- });
2162
-
2163
- function handleExclusiveUnionResults(
2164
- results: ParsePayload[],
2165
- final: ParsePayload,
2166
- inst: $ZodUnion,
2167
- ctx?: ParseContext
2168
- ) {
2169
- const successes = results.filter((r) => r.issues.length === 0);
2170
-
2171
- if (successes.length === 1) {
2172
- final.value = successes[0].value;
2173
- return final;
2174
- }
2175
-
2176
- if (successes.length === 0) {
2177
- // No matches - same as regular union
2178
- final.issues.push({
2179
- code: "invalid_union",
2180
- input: final.value,
2181
- inst,
2182
- errors: results.map((result) => result.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config()))),
2183
- });
2184
- } else {
2185
- // Multiple matches - exclusive union failure
2186
- final.issues.push({
2187
- code: "invalid_union",
2188
- input: final.value,
2189
- inst,
2190
- errors: [],
2191
- inclusive: false,
2192
- });
2193
- }
2194
-
2195
- return final;
2196
- }
2197
-
2198
- export interface $ZodXorInternals<T extends readonly SomeType[] = readonly $ZodType[]> extends $ZodUnionInternals<T> {}
2199
-
2200
- export interface $ZodXor<T extends readonly SomeType[] = readonly $ZodType[]>
2201
- extends $ZodType<any, any, $ZodXorInternals<T>> {
2202
- _zod: $ZodXorInternals<T>;
2203
- }
2204
-
2205
- export const $ZodXor: core.$constructor<$ZodXor> = /*@__PURE__*/ core.$constructor("$ZodXor", (inst, def) => {
2206
- $ZodUnion.init(inst, def);
2207
- def.inclusive = false;
2208
-
2209
- const single = def.options.length === 1;
2210
- const first = def.options[0]._zod.run;
2211
-
2212
- inst._zod.parse = (payload, ctx) => {
2213
- if (single) {
2214
- return first(payload, ctx);
2215
- }
2216
- let async = false;
2217
-
2218
- const results: util.MaybeAsync<ParsePayload>[] = [];
2219
- for (const option of def.options) {
2220
- const result = option._zod.run(
2221
- {
2222
- value: payload.value,
2223
- issues: [],
2224
- },
2225
- ctx
2226
- );
2227
- if (result instanceof Promise) {
2228
- results.push(result);
2229
- async = true;
2230
- } else {
2231
- results.push(result);
2232
- }
2233
- }
2234
-
2235
- if (!async) return handleExclusiveUnionResults(results as ParsePayload[], payload, inst, ctx);
2236
- return Promise.all(results).then((results) => {
2237
- return handleExclusiveUnionResults(results as ParsePayload[], payload, inst, ctx);
2238
- });
2239
- };
2240
- });
2241
-
2242
- //////////////////////////////////////////////////////
2243
- //////////////////////////////////////////////////////
2244
- ////////// //////////
2245
- ////////// $ZodDiscriminatedUnion //////////
2246
- ////////// //////////
2247
- //////////////////////////////////////////////////////
2248
- //////////////////////////////////////////////////////
2249
-
2250
- export interface $ZodDiscriminatedUnionDef<
2251
- Options extends readonly SomeType[] = readonly $ZodType[],
2252
- Disc extends string = string,
2253
- > extends $ZodUnionDef<Options> {
2254
- discriminator: Disc;
2255
- unionFallback?: boolean;
2256
- }
2257
-
2258
- export interface $ZodDiscriminatedUnionInternals<
2259
- Options extends readonly SomeType[] = readonly $ZodType[],
2260
- Disc extends string = string,
2261
- > extends $ZodUnionInternals<Options> {
2262
- def: $ZodDiscriminatedUnionDef<Options, Disc>;
2263
- propValues: util.PropValues;
2264
- }
2265
-
2266
- export interface $ZodDiscriminatedUnion<
2267
- Options extends readonly SomeType[] = readonly $ZodType[],
2268
- Disc extends string = string,
2269
- > extends $ZodType {
2270
- _zod: $ZodDiscriminatedUnionInternals<Options, Disc>;
2271
- }
2272
-
2273
- export const $ZodDiscriminatedUnion: core.$constructor<$ZodDiscriminatedUnion> =
2274
- /*@__PURE__*/
2275
- core.$constructor("$ZodDiscriminatedUnion", (inst, def) => {
2276
- def.inclusive = false;
2277
-
2278
- $ZodUnion.init(inst, def);
2279
-
2280
- const _super = inst._zod.parse;
2281
- util.defineLazy(inst._zod, "propValues", () => {
2282
- const propValues: util.PropValues = {};
2283
- for (const option of def.options) {
2284
- const pv = option._zod.propValues;
2285
- if (!pv || Object.keys(pv).length === 0)
2286
- throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(option)}"`);
2287
- for (const [k, v] of Object.entries(pv!)) {
2288
- if (!propValues[k]) propValues[k] = new Set();
2289
- for (const val of v) {
2290
- propValues[k].add(val);
2291
- }
2292
- }
2293
- }
2294
- return propValues;
2295
- });
2296
-
2297
- const disc = util.cached(() => {
2298
- const opts = def.options as $ZodTypeDiscriminable[];
2299
- const map: Map<util.Primitive, $ZodType> = new Map();
2300
- for (const o of opts) {
2301
- const values = o._zod.propValues?.[def.discriminator];
2302
- if (!values || values.size === 0)
2303
- throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(o)}"`);
2304
- for (const v of values) {
2305
- if (map.has(v)) {
2306
- throw new Error(`Duplicate discriminator value "${String(v)}"`);
2307
- }
2308
- map.set(v, o);
2309
- }
2310
- }
2311
- return map;
2312
- });
2313
-
2314
- inst._zod.parse = (payload, ctx) => {
2315
- const input = payload.value;
2316
- if (!util.isObject(input)) {
2317
- payload.issues.push({
2318
- code: "invalid_type",
2319
-
2320
- expected: "object",
2321
- input,
2322
- inst,
2323
- });
2324
- return payload;
2325
- }
2326
-
2327
- const opt = disc.value.get(input?.[def.discriminator] as any);
2328
- if (opt) {
2329
- return opt._zod.run(payload, ctx) as any;
2330
- }
2331
-
2332
- if (def.unionFallback) {
2333
- return _super(payload, ctx);
2334
- }
2335
-
2336
- // no matching discriminator
2337
- payload.issues.push({
2338
- code: "invalid_union",
2339
-
2340
- errors: [],
2341
- note: "No matching discriminator",
2342
- discriminator: def.discriminator,
2343
- input,
2344
- path: [def.discriminator],
2345
- inst,
2346
- });
2347
-
2348
- return payload;
2349
- };
2350
- });
2351
-
2352
- ////////////////////////////////////////////////
2353
- ////////////////////////////////////////////////
2354
- ////////// //////////
2355
- ////////// $ZodIntersection //////////
2356
- ////////// //////////
2357
- ////////////////////////////////////////////////
2358
- ////////////////////////////////////////////////
2359
-
2360
- export interface $ZodIntersectionDef<Left extends SomeType = $ZodType, Right extends SomeType = $ZodType>
2361
- extends $ZodTypeDef {
2362
- type: "intersection";
2363
- left: Left;
2364
- right: Right;
2365
- }
2366
-
2367
- export interface $ZodIntersectionInternals<A extends SomeType = $ZodType, B extends SomeType = $ZodType>
2368
- extends _$ZodTypeInternals {
2369
- // $ZodTypeInternals<core.output<A> & core.output<B>, core.input<A> & core.input<B>>
2370
- def: $ZodIntersectionDef<A, B>;
2371
- isst: never;
2372
- optin: A["_zod"]["optin"] | B["_zod"]["optin"];
2373
- optout: A["_zod"]["optout"] | B["_zod"]["optout"];
2374
- output: core.output<A> & core.output<B>;
2375
- input: core.input<A> & core.input<B>;
2376
- }
2377
-
2378
- export interface $ZodIntersection<A extends SomeType = $ZodType, B extends SomeType = $ZodType> extends $ZodType {
2379
- _zod: $ZodIntersectionInternals<A, B>;
2380
- }
2381
-
2382
- export const $ZodIntersection: core.$constructor<$ZodIntersection> = /*@__PURE__*/ core.$constructor(
2383
- "$ZodIntersection",
2384
- (inst, def) => {
2385
- $ZodType.init(inst, def);
2386
-
2387
- inst._zod.parse = (payload, ctx) => {
2388
- const input = payload.value;
2389
- const left = def.left._zod.run({ value: input, issues: [] }, ctx);
2390
- const right = def.right._zod.run({ value: input, issues: [] }, ctx);
2391
- const async = left instanceof Promise || right instanceof Promise;
2392
-
2393
- if (async) {
2394
- return Promise.all([left, right]).then(([left, right]) => {
2395
- return handleIntersectionResults(payload, left, right);
2396
- });
2397
- }
2398
-
2399
- return handleIntersectionResults(payload, left, right);
2400
- };
2401
- }
2402
- );
2403
-
2404
- function mergeValues(
2405
- a: any,
2406
- b: any
2407
- ): { valid: true; data: any } | { valid: false; mergeErrorPath: (string | number)[] } {
2408
- // const aType = parse.t(a);
2409
- // const bType = parse.t(b);
2410
-
2411
- if (a === b) {
2412
- return { valid: true, data: a };
2413
- }
2414
- if (a instanceof Date && b instanceof Date && +a === +b) {
2415
- return { valid: true, data: a };
2416
- }
2417
- if (util.isPlainObject(a) && util.isPlainObject(b)) {
2418
- const bKeys = Object.keys(b);
2419
- const sharedKeys = Object.keys(a).filter((key) => bKeys.indexOf(key) !== -1);
2420
-
2421
- const newObj: any = { ...a, ...b };
2422
- for (const key of sharedKeys) {
2423
- const sharedValue = mergeValues(a[key], b[key]);
2424
- if (!sharedValue.valid) {
2425
- return {
2426
- valid: false,
2427
- mergeErrorPath: [key, ...sharedValue.mergeErrorPath],
2428
- };
2429
- }
2430
- newObj[key] = sharedValue.data;
2431
- }
2432
-
2433
- return { valid: true, data: newObj };
2434
- }
2435
- if (Array.isArray(a) && Array.isArray(b)) {
2436
- if (a.length !== b.length) {
2437
- return { valid: false, mergeErrorPath: [] };
2438
- }
2439
-
2440
- const newArray: unknown[] = [];
2441
- for (let index = 0; index < a.length; index++) {
2442
- const itemA = a[index];
2443
- const itemB = b[index];
2444
- const sharedValue = mergeValues(itemA, itemB);
2445
-
2446
- if (!sharedValue.valid) {
2447
- return {
2448
- valid: false,
2449
- mergeErrorPath: [index, ...sharedValue.mergeErrorPath],
2450
- };
2451
- }
2452
-
2453
- newArray.push(sharedValue.data);
2454
- }
2455
-
2456
- return { valid: true, data: newArray };
2457
- }
2458
-
2459
- return { valid: false, mergeErrorPath: [] };
2460
- }
2461
-
2462
- function handleIntersectionResults(result: ParsePayload, left: ParsePayload, right: ParsePayload): ParsePayload {
2463
- // Track which side(s) report each key as unrecognized
2464
- const unrecKeys = new Map<string, { l?: true; r?: true }>();
2465
- let unrecIssue: errors.$ZodRawIssue | undefined;
2466
-
2467
- for (const iss of left.issues) {
2468
- if (iss.code === "unrecognized_keys") {
2469
- unrecIssue ??= iss;
2470
- for (const k of iss.keys) {
2471
- if (!unrecKeys.has(k)) unrecKeys.set(k, {});
2472
- unrecKeys.get(k)!.l = true;
2473
- }
2474
- } else {
2475
- result.issues.push(iss);
2476
- }
2477
- }
2478
-
2479
- for (const iss of right.issues) {
2480
- if (iss.code === "unrecognized_keys") {
2481
- for (const k of iss.keys) {
2482
- if (!unrecKeys.has(k)) unrecKeys.set(k, {});
2483
- unrecKeys.get(k)!.r = true;
2484
- }
2485
- } else {
2486
- result.issues.push(iss);
2487
- }
2488
- }
2489
-
2490
- // Report only keys unrecognized by BOTH sides
2491
- const bothKeys = [...unrecKeys].filter(([, f]) => f.l && f.r).map(([k]) => k);
2492
- if (bothKeys.length && unrecIssue) {
2493
- result.issues.push({ ...unrecIssue, keys: bothKeys });
2494
- }
2495
-
2496
- if (util.aborted(result)) return result;
2497
-
2498
- const merged = mergeValues(left.value, right.value);
2499
-
2500
- if (!merged.valid) {
2501
- throw new Error(`Unmergable intersection. Error path: ` + `${JSON.stringify(merged.mergeErrorPath)}`);
2502
- }
2503
-
2504
- result.value = merged.data;
2505
- return result;
2506
- }
2507
-
2508
- /////////////////////////////////////////
2509
- /////////////////////////////////////////
2510
- ////////// //////////
2511
- ////////// $ZodTuple //////////
2512
- ////////// //////////
2513
- /////////////////////////////////////////
2514
- /////////////////////////////////////////
2515
-
2516
- export interface $ZodTupleDef<
2517
- T extends util.TupleItems = readonly $ZodType[],
2518
- Rest extends SomeType | null = $ZodType | null,
2519
- > extends $ZodTypeDef {
2520
- type: "tuple";
2521
- items: T;
2522
- rest: Rest;
2523
- }
2524
-
2525
- export type $InferTupleInputType<T extends util.TupleItems, Rest extends SomeType | null> = [
2526
- ...TupleInputTypeWithOptionals<T>,
2527
- ...(Rest extends SomeType ? core.input<Rest>[] : []),
2528
- ];
2529
- type TupleInputTypeNoOptionals<T extends util.TupleItems> = {
2530
- [k in keyof T]: core.input<T[k]>;
2531
- };
2532
- type TupleInputTypeWithOptionals<T extends util.TupleItems> = T extends readonly [
2533
- ...infer Prefix extends SomeType[],
2534
- infer Tail extends SomeType,
2535
- ]
2536
- ? Tail["_zod"]["optin"] extends "optional"
2537
- ? [...TupleInputTypeWithOptionals<Prefix>, core.input<Tail>?]
2538
- : TupleInputTypeNoOptionals<T>
2539
- : [];
2540
-
2541
- export type $InferTupleOutputType<T extends util.TupleItems, Rest extends SomeType | null> = [
2542
- ...TupleOutputTypeWithOptionals<T>,
2543
- ...(Rest extends SomeType ? core.output<Rest>[] : []),
2544
- ];
2545
- type TupleOutputTypeNoOptionals<T extends util.TupleItems> = {
2546
- [k in keyof T]: core.output<T[k]>;
2547
- };
2548
- type TupleOutputTypeWithOptionals<T extends util.TupleItems> = T extends readonly [
2549
- ...infer Prefix extends SomeType[],
2550
- infer Tail extends SomeType,
2551
- ]
2552
- ? Tail["_zod"]["optout"] extends "optional"
2553
- ? [...TupleOutputTypeWithOptionals<Prefix>, core.output<Tail>?]
2554
- : TupleOutputTypeNoOptionals<T>
2555
- : [];
2556
-
2557
- export interface $ZodTupleInternals<
2558
- T extends util.TupleItems = readonly $ZodType[],
2559
- Rest extends SomeType | null = $ZodType | null,
2560
- > extends _$ZodTypeInternals {
2561
- def: $ZodTupleDef<T, Rest>;
2562
- isst: errors.$ZodIssueInvalidType | errors.$ZodIssueTooBig<unknown[]> | errors.$ZodIssueTooSmall<unknown[]>;
2563
- // $ZodTypeInternals<$InferTupleOutputType<T, Rest>, $InferTupleInputType<T, Rest>>
2564
- output: $InferTupleOutputType<T, Rest>;
2565
- input: $InferTupleInputType<T, Rest>;
2566
- }
2567
-
2568
- export interface $ZodTuple<
2569
- T extends util.TupleItems = readonly $ZodType[],
2570
- Rest extends SomeType | null = $ZodType | null,
2571
- > extends $ZodType {
2572
- _zod: $ZodTupleInternals<T, Rest>;
2573
- }
2574
-
2575
- export const $ZodTuple: core.$constructor<$ZodTuple> = /*@__PURE__*/ core.$constructor("$ZodTuple", (inst, def) => {
2576
- $ZodType.init(inst, def);
2577
- const items = def.items;
2578
-
2579
- inst._zod.parse = (payload, ctx) => {
2580
- const input = payload.value;
2581
- if (!Array.isArray(input)) {
2582
- payload.issues.push({
2583
- input,
2584
- inst,
2585
- expected: "tuple",
2586
- code: "invalid_type",
2587
- });
2588
- return payload;
2589
- }
2590
-
2591
- payload.value = [];
2592
- const proms: Promise<any>[] = [];
2593
-
2594
- const reversedIndex = [...items].reverse().findIndex((item) => item._zod.optin !== "optional");
2595
- const optStart = reversedIndex === -1 ? 0 : items.length - reversedIndex;
2596
-
2597
- if (!def.rest) {
2598
- const tooBig = input.length > items.length;
2599
- const tooSmall = input.length < optStart - 1;
2600
- if (tooBig || tooSmall) {
2601
- payload.issues.push({
2602
- ...(tooBig
2603
- ? { code: "too_big", maximum: items.length, inclusive: true }
2604
- : { code: "too_small", minimum: items.length }),
2605
-
2606
- input,
2607
- inst,
2608
- origin: "array" as const,
2609
- });
2610
- return payload;
2611
- }
2612
- }
2613
-
2614
- let i = -1;
2615
- for (const item of items) {
2616
- i++;
2617
- if (i >= input.length) if (i >= optStart) continue;
2618
- const result = item._zod.run(
2619
- {
2620
- value: input[i],
2621
- issues: [],
2622
- },
2623
- ctx
2624
- );
2625
-
2626
- if (result instanceof Promise) {
2627
- proms.push(result.then((result) => handleTupleResult(result, payload, i)));
2628
- } else {
2629
- handleTupleResult(result, payload, i);
2630
- }
2631
- }
2632
-
2633
- if (def.rest) {
2634
- const rest = input.slice(items.length);
2635
- for (const el of rest) {
2636
- i++;
2637
- const result = def.rest._zod.run(
2638
- {
2639
- value: el,
2640
- issues: [],
2641
- },
2642
- ctx
2643
- );
2644
-
2645
- if (result instanceof Promise) {
2646
- proms.push(result.then((result) => handleTupleResult(result, payload, i)));
2647
- } else {
2648
- handleTupleResult(result, payload, i);
2649
- }
2650
- }
2651
- }
2652
-
2653
- if (proms.length) return Promise.all(proms).then(() => payload);
2654
- return payload;
2655
- };
2656
- });
2657
-
2658
- function handleTupleResult(result: ParsePayload, final: ParsePayload<any[]>, index: number) {
2659
- if (result.issues.length) {
2660
- final.issues.push(...util.prefixIssues(index, result.issues));
2661
- }
2662
- final.value[index] = result.value;
2663
- }
2664
-
2665
- //////////////////////////////////////////
2666
- //////////////////////////////////////////
2667
- ////////// //////////
2668
- ////////// $ZodRecord //////////
2669
- ////////// //////////
2670
- //////////////////////////////////////////
2671
- //////////////////////////////////////////
2672
-
2673
- export type $ZodRecordKey = $ZodType<string | number | symbol, unknown>; // $HasValues | $HasPattern;
2674
- export interface $ZodRecordDef<Key extends $ZodRecordKey = $ZodRecordKey, Value extends SomeType = $ZodType>
2675
- extends $ZodTypeDef {
2676
- type: "record";
2677
- keyType: Key;
2678
- valueType: Value;
2679
- /** @default "strict" - errors on keys not matching keyType. "loose" passes through non-matching keys unchanged. */
2680
- mode?: "strict" | "loose";
2681
- }
2682
-
2683
- // export type $InferZodRecordOutput<
2684
- // Key extends $ZodRecordKey = $ZodRecordKey,
2685
- // Value extends SomeType = $ZodType,
2686
- // > = undefined extends Key["_zod"]["values"]
2687
- // ? string extends core.output<Key>
2688
- // ? Record<core.output<Key>, core.output<Value>>
2689
- // : number extends core.output<Key>
2690
- // ? Record<core.output<Key>, core.output<Value>>
2691
- // : symbol extends core.output<Key>
2692
- // ? Record<core.output<Key>, core.output<Value>>
2693
- // : Record<core.output<Key>, core.output<Value>>
2694
- // : Record<core.output<Key>, core.output<Value>>;
2695
- export type $InferZodRecordOutput<
2696
- Key extends $ZodRecordKey = $ZodRecordKey,
2697
- Value extends SomeType = $ZodType,
2698
- > = Key extends $partial
2699
- ? Partial<Record<core.output<Key>, core.output<Value>>>
2700
- : Record<core.output<Key>, core.output<Value>>;
2701
-
2702
- // export type $InferZodRecordInput<
2703
- // Key extends $ZodRecordKey = $ZodRecordKey,
2704
- // Value extends SomeType = $ZodType,
2705
- // > = undefined extends Key["_zod"]["values"]
2706
- // ? string extends core.input<Key>
2707
- // ? Record<core.input<Key>, core.input<Value>>
2708
- // : number extends core.input<Key>
2709
- // ? Record<core.input<Key>, core.input<Value>>
2710
- // : symbol extends core.input<Key>
2711
- // ? Record<core.input<Key>, core.input<Value>>
2712
- // : Record<core.input<Key>, core.input<Value>>
2713
- // : Record<core.input<Key>, core.input<Value>>;
2714
-
2715
- export type $InferZodRecordInput<
2716
- Key extends $ZodRecordKey = $ZodRecordKey,
2717
- Value extends SomeType = $ZodType,
2718
- > = Key extends $partial
2719
- ? Partial<Record<core.input<Key> & PropertyKey, core.input<Value>>>
2720
- : Record<core.input<Key> & PropertyKey, core.input<Value>>;
2721
-
2722
- export interface $ZodRecordInternals<Key extends $ZodRecordKey = $ZodRecordKey, Value extends SomeType = $ZodType>
2723
- extends $ZodTypeInternals<$InferZodRecordOutput<Key, Value>, $InferZodRecordInput<Key, Value>> {
2724
- def: $ZodRecordDef<Key, Value>;
2725
- isst: errors.$ZodIssueInvalidType | errors.$ZodIssueInvalidKey<Record<PropertyKey, unknown>>;
2726
- optin?: "optional" | undefined;
2727
- optout?: "optional" | undefined;
2728
- }
2729
-
2730
- export type $partial = { "~~partial": true };
2731
- export interface $ZodRecord<Key extends $ZodRecordKey = $ZodRecordKey, Value extends SomeType = $ZodType>
2732
- extends $ZodType {
2733
- _zod: $ZodRecordInternals<Key, Value>;
2734
- }
2735
-
2736
- export const $ZodRecord: core.$constructor<$ZodRecord> = /*@__PURE__*/ core.$constructor("$ZodRecord", (inst, def) => {
2737
- $ZodType.init(inst, def);
2738
-
2739
- inst._zod.parse = (payload, ctx) => {
2740
- const input = payload.value;
2741
-
2742
- if (!util.isPlainObject(input)) {
2743
- payload.issues.push({
2744
- expected: "record",
2745
- code: "invalid_type",
2746
-
2747
- input,
2748
- inst,
2749
- });
2750
- return payload;
2751
- }
2752
-
2753
- const proms: Promise<any>[] = [];
2754
-
2755
- const values = def.keyType._zod.values;
2756
- if (values) {
2757
- payload.value = {};
2758
- const recordKeys = new Set<string | symbol>();
2759
- for (const key of values) {
2760
- if (typeof key === "string" || typeof key === "number" || typeof key === "symbol") {
2761
- recordKeys.add(typeof key === "number" ? key.toString() : key);
2762
- const result = def.valueType._zod.run({ value: input[key], issues: [] }, ctx);
2763
-
2764
- if (result instanceof Promise) {
2765
- proms.push(
2766
- result.then((result) => {
2767
- if (result.issues.length) {
2768
- payload.issues.push(...util.prefixIssues(key, result.issues));
2769
- }
2770
- payload.value[key] = result.value;
2771
- })
2772
- );
2773
- } else {
2774
- if (result.issues.length) {
2775
- payload.issues.push(...util.prefixIssues(key, result.issues));
2776
- }
2777
- payload.value[key] = result.value;
2778
- }
2779
- }
2780
- }
2781
-
2782
- let unrecognized!: string[];
2783
- for (const key in input) {
2784
- if (!recordKeys.has(key)) {
2785
- unrecognized = unrecognized ?? [];
2786
- unrecognized.push(key);
2787
- }
2788
- }
2789
- if (unrecognized && unrecognized.length > 0) {
2790
- payload.issues.push({
2791
- code: "unrecognized_keys",
2792
-
2793
- input,
2794
- inst,
2795
- keys: unrecognized,
2796
- });
2797
- }
2798
- } else {
2799
- payload.value = {};
2800
- for (const key of Reflect.ownKeys(input)) {
2801
- if (key === "__proto__") continue;
2802
- let keyResult = def.keyType._zod.run({ value: key, issues: [] }, ctx);
2803
- if (keyResult instanceof Promise) {
2804
- throw new Error("Async schemas not supported in object keys currently");
2805
- }
2806
-
2807
- // Numeric string fallback: if key failed with "expected number", retry with Number(key)
2808
- const checkNumericKey =
2809
- typeof key === "string" &&
2810
- regexes.number.test(key) &&
2811
- keyResult.issues.length &&
2812
- keyResult.issues.some(
2813
- (iss) => iss.code === "invalid_type" && (iss as errors.$ZodIssueInvalidType).expected === "number"
2814
- );
2815
- if (checkNumericKey) {
2816
- const retryResult = def.keyType._zod.run({ value: Number(key), issues: [] }, ctx);
2817
- if (retryResult instanceof Promise) {
2818
- throw new Error("Async schemas not supported in object keys currently");
2819
- }
2820
- if (retryResult.issues.length === 0) {
2821
- keyResult = retryResult;
2822
- }
2823
- }
2824
-
2825
- if (keyResult.issues.length) {
2826
- if (def.mode === "loose") {
2827
- // Pass through unchanged
2828
- payload.value[key] = input[key];
2829
- } else {
2830
- // Default "strict" behavior: error on invalid key
2831
- payload.issues.push({
2832
- code: "invalid_key",
2833
- origin: "record",
2834
- issues: keyResult.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())),
2835
- input: key,
2836
- path: [key],
2837
- inst,
2838
- });
2839
- }
2840
- continue;
2841
- }
2842
-
2843
- const result = def.valueType._zod.run({ value: input[key], issues: [] }, ctx);
2844
-
2845
- if (result instanceof Promise) {
2846
- proms.push(
2847
- result.then((result) => {
2848
- if (result.issues.length) {
2849
- payload.issues.push(...util.prefixIssues(key, result.issues));
2850
- }
2851
- payload.value[keyResult.value as PropertyKey] = result.value;
2852
- })
2853
- );
2854
- } else {
2855
- if (result.issues.length) {
2856
- payload.issues.push(...util.prefixIssues(key, result.issues));
2857
- }
2858
- payload.value[keyResult.value as PropertyKey] = result.value;
2859
- }
2860
- }
2861
- }
2862
-
2863
- if (proms.length) {
2864
- return Promise.all(proms).then(() => payload);
2865
- }
2866
- return payload;
2867
- };
2868
- });
2869
-
2870
- ///////////////////////////////////////
2871
- ///////////////////////////////////////
2872
- ////////// //////////
2873
- ////////// $ZodMap //////////
2874
- ////////// //////////
2875
- ///////////////////////////////////////
2876
- ///////////////////////////////////////
2877
- export interface $ZodMapDef<Key extends SomeType = $ZodType, Value extends SomeType = $ZodType> extends $ZodTypeDef {
2878
- type: "map";
2879
- keyType: Key;
2880
- valueType: Value;
2881
- }
2882
-
2883
- export interface $ZodMapInternals<Key extends SomeType = $ZodType, Value extends SomeType = $ZodType>
2884
- extends $ZodTypeInternals<Map<core.output<Key>, core.output<Value>>, Map<core.input<Key>, core.input<Value>>> {
2885
- def: $ZodMapDef<Key, Value>;
2886
- isst: errors.$ZodIssueInvalidType | errors.$ZodIssueInvalidKey | errors.$ZodIssueInvalidElement<unknown>;
2887
- optin?: "optional" | undefined;
2888
- optout?: "optional" | undefined;
2889
- }
2890
-
2891
- export interface $ZodMap<Key extends SomeType = $ZodType, Value extends SomeType = $ZodType> extends $ZodType {
2892
- _zod: $ZodMapInternals<Key, Value>;
2893
- }
2894
-
2895
- export const $ZodMap: core.$constructor<$ZodMap> = /*@__PURE__*/ core.$constructor("$ZodMap", (inst, def) => {
2896
- $ZodType.init(inst, def);
2897
-
2898
- inst._zod.parse = (payload, ctx) => {
2899
- const input = payload.value;
2900
- if (!(input instanceof Map)) {
2901
- payload.issues.push({
2902
- expected: "map",
2903
- code: "invalid_type",
2904
-
2905
- input,
2906
- inst,
2907
- });
2908
- return payload;
2909
- }
2910
-
2911
- const proms: Promise<any>[] = [];
2912
- payload.value = new Map();
2913
-
2914
- for (const [key, value] of input) {
2915
- const keyResult = def.keyType._zod.run({ value: key, issues: [] }, ctx);
2916
- const valueResult = def.valueType._zod.run({ value: value, issues: [] }, ctx);
2917
-
2918
- if (keyResult instanceof Promise || valueResult instanceof Promise) {
2919
- proms.push(
2920
- Promise.all([keyResult, valueResult]).then(([keyResult, valueResult]) => {
2921
- handleMapResult(keyResult, valueResult, payload, key, input, inst, ctx);
2922
- })
2923
- );
2924
- } else {
2925
- handleMapResult(keyResult as ParsePayload, valueResult as ParsePayload, payload, key, input, inst, ctx);
2926
- }
2927
- }
2928
-
2929
- if (proms.length) return Promise.all(proms).then(() => payload);
2930
- return payload;
2931
- };
2932
- });
2933
-
2934
- function handleMapResult(
2935
- keyResult: ParsePayload,
2936
- valueResult: ParsePayload,
2937
- final: ParsePayload<Map<unknown, unknown>>,
2938
- key: unknown,
2939
- input: Map<any, any>,
2940
- inst: $ZodMap,
2941
- ctx?: ParseContext | undefined
2942
- ): void {
2943
- if (keyResult.issues.length) {
2944
- if (util.propertyKeyTypes.has(typeof key)) {
2945
- final.issues.push(...util.prefixIssues(key as PropertyKey, keyResult.issues));
2946
- } else {
2947
- final.issues.push({
2948
- code: "invalid_key",
2949
-
2950
- origin: "map",
2951
- input,
2952
- inst,
2953
- issues: keyResult.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())),
2954
- });
2955
- }
2956
- }
2957
- if (valueResult.issues.length) {
2958
- if (util.propertyKeyTypes.has(typeof key)) {
2959
- final.issues.push(...util.prefixIssues(key as PropertyKey, valueResult.issues));
2960
- } else {
2961
- final.issues.push({
2962
- origin: "map",
2963
- code: "invalid_element",
2964
-
2965
- input,
2966
- inst,
2967
- key: key,
2968
- issues: valueResult.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())),
2969
- });
2970
- }
2971
- }
2972
- final.value.set(keyResult.value, valueResult.value);
2973
- }
2974
-
2975
- ///////////////////////////////////////
2976
- ///////////////////////////////////////
2977
- ////////// //////////
2978
- ////////// $ZodSet //////////
2979
- ////////// //////////
2980
- ///////////////////////////////////////
2981
- ///////////////////////////////////////
2982
- export interface $ZodSetDef<T extends SomeType = $ZodType> extends $ZodTypeDef {
2983
- type: "set";
2984
- valueType: T;
2985
- }
2986
-
2987
- export interface $ZodSetInternals<T extends SomeType = $ZodType>
2988
- extends $ZodTypeInternals<Set<core.output<T>>, Set<core.input<T>>> {
2989
- def: $ZodSetDef<T>;
2990
- isst: errors.$ZodIssueInvalidType;
2991
- optin?: "optional" | undefined;
2992
- optout?: "optional" | undefined;
2993
- }
2994
-
2995
- export interface $ZodSet<T extends SomeType = $ZodType> extends $ZodType {
2996
- _zod: $ZodSetInternals<T>;
2997
- }
2998
-
2999
- export const $ZodSet: core.$constructor<$ZodSet> = /*@__PURE__*/ core.$constructor("$ZodSet", (inst, def) => {
3000
- $ZodType.init(inst, def);
3001
-
3002
- inst._zod.parse = (payload, ctx) => {
3003
- const input = payload.value;
3004
- if (!(input instanceof Set)) {
3005
- payload.issues.push({
3006
- input,
3007
- inst,
3008
- expected: "set",
3009
- code: "invalid_type",
3010
- });
3011
- return payload;
3012
- }
3013
-
3014
- const proms: Promise<any>[] = [];
3015
- payload.value = new Set();
3016
- for (const item of input) {
3017
- const result = def.valueType._zod.run({ value: item, issues: [] }, ctx);
3018
- if (result instanceof Promise) {
3019
- proms.push(result.then((result) => handleSetResult(result, payload)));
3020
- } else handleSetResult(result, payload);
3021
- }
3022
-
3023
- if (proms.length) return Promise.all(proms).then(() => payload);
3024
- return payload;
3025
- };
3026
- });
3027
-
3028
- function handleSetResult(result: ParsePayload, final: ParsePayload<Set<any>>) {
3029
- if (result.issues.length) {
3030
- final.issues.push(...result.issues);
3031
- }
3032
- final.value.add(result.value);
3033
- }
3034
-
3035
- ////////////////////////////////////////
3036
- ////////////////////////////////////////
3037
- ////////// //////////
3038
- ////////// $ZodEnum //////////
3039
- ////////// //////////
3040
- ////////////////////////////////////////
3041
- ////////////////////////////////////////
3042
- export type $InferEnumOutput<T extends util.EnumLike> = T[keyof T] & {};
3043
- export type $InferEnumInput<T extends util.EnumLike> = T[keyof T] & {};
3044
-
3045
- export interface $ZodEnumDef<T extends util.EnumLike = util.EnumLike> extends $ZodTypeDef {
3046
- type: "enum";
3047
- entries: T;
3048
- }
3049
-
3050
- export interface $ZodEnumInternals<
3051
- /** @ts-ignore Cast variance */
3052
- out T extends util.EnumLike = util.EnumLike,
3053
- > extends $ZodTypeInternals<$InferEnumOutput<T>, $InferEnumInput<T>> {
3054
- // enum: T;
3055
-
3056
- def: $ZodEnumDef<T>;
3057
- /** @deprecated Internal API, use with caution (not deprecated) */
3058
- values: util.PrimitiveSet;
3059
- /** @deprecated Internal API, use with caution (not deprecated) */
3060
- pattern: RegExp;
3061
- isst: errors.$ZodIssueInvalidValue;
3062
- }
3063
-
3064
- export interface $ZodEnum<T extends util.EnumLike = util.EnumLike> extends $ZodType {
3065
- _zod: $ZodEnumInternals<T>;
3066
- }
3067
-
3068
- export const $ZodEnum: core.$constructor<$ZodEnum> = /*@__PURE__*/ core.$constructor("$ZodEnum", (inst, def) => {
3069
- $ZodType.init(inst, def);
3070
-
3071
- const values = util.getEnumValues(def.entries);
3072
- const valuesSet = new Set<util.Primitive>(values);
3073
- inst._zod.values = valuesSet;
3074
-
3075
- inst._zod.pattern = new RegExp(
3076
- `^(${values
3077
- .filter((k) => util.propertyKeyTypes.has(typeof k))
3078
- .map((o) => (typeof o === "string" ? util.escapeRegex(o) : o.toString()))
3079
- .join("|")})$`
3080
- );
3081
-
3082
- inst._zod.parse = (payload, _ctx) => {
3083
- const input = payload.value;
3084
- if (valuesSet.has(input)) {
3085
- return payload;
3086
- }
3087
- payload.issues.push({
3088
- code: "invalid_value",
3089
-
3090
- values,
3091
- input,
3092
- inst,
3093
- });
3094
- return payload;
3095
- };
3096
- });
3097
-
3098
- ////////////////////////////////////////
3099
- ////////////////////////////////////////
3100
- ////////// //////////
3101
- ////////// $ZodLiteral //////////
3102
- ////////// //////////
3103
- ////////////////////////////////////////
3104
- ////////////////////////////////////////
3105
-
3106
- export interface $ZodLiteralDef<T extends util.Literal> extends $ZodTypeDef {
3107
- type: "literal";
3108
- values: T[];
3109
- }
3110
-
3111
- export interface $ZodLiteralInternals<T extends util.Literal = util.Literal> extends $ZodTypeInternals<T, T> {
3112
- def: $ZodLiteralDef<T>;
3113
- values: Set<T>;
3114
- pattern: RegExp;
3115
- isst: errors.$ZodIssueInvalidValue;
3116
- }
3117
-
3118
- export interface $ZodLiteral<T extends util.Literal = util.Literal> extends $ZodType {
3119
- _zod: $ZodLiteralInternals<T>;
3120
- }
3121
-
3122
- export const $ZodLiteral: core.$constructor<$ZodLiteral> = /*@__PURE__*/ core.$constructor(
3123
- "$ZodLiteral",
3124
- (inst, def) => {
3125
- $ZodType.init(inst, def);
3126
- if (def.values.length === 0) {
3127
- throw new Error("Cannot create literal schema with no valid values");
3128
- }
3129
-
3130
- const values = new Set<util.Literal>(def.values);
3131
- inst._zod.values = values;
3132
- inst._zod.pattern = new RegExp(
3133
- `^(${def.values
3134
-
3135
- .map((o) => (typeof o === "string" ? util.escapeRegex(o) : o ? util.escapeRegex(o.toString()) : String(o)))
3136
- .join("|")})$`
3137
- );
3138
-
3139
- inst._zod.parse = (payload, _ctx) => {
3140
- const input = payload.value;
3141
- if (values.has(input)) {
3142
- return payload;
3143
- }
3144
- payload.issues.push({
3145
- code: "invalid_value",
3146
-
3147
- values: def.values,
3148
- input,
3149
- inst,
3150
- });
3151
- return payload;
3152
- };
3153
- }
3154
- );
3155
-
3156
- ////////////////////////////////////////
3157
- ////////////////////////////////////////
3158
- ////////// //////////
3159
- ////////// $ZodConst //////////
3160
- ////////// //////////
3161
- ////////////////////////////////////////
3162
- ////////////////////////////////////////
3163
-
3164
- // export interface $ZodConstDef extends $ZodTypeDef {
3165
- // type: "const";
3166
- // value: unknown;
3167
- // }
3168
-
3169
- // export _interface $ZodConstInternals<T extends util.Literal = util.Literal> extends $ZodTypeInternals<T, T> {
3170
- // _def: $ZodConstDef;
3171
- // _values: util.PrimitiveSet;
3172
- // _pattern: RegExp;
3173
- // _isst: errors.$ZodIssueInvalidValue;
3174
- // }
3175
-
3176
- // export const $ZodConst: core.$constructor<{_zod: $ZodConstInternals}> = /*@__PURE__*/ core.$constructor("$ZodConst", (inst, def) => {
3177
- // $ZodType.init(inst, def);
3178
-
3179
- // if (util.primitiveTypes.has(typeof def.value) || def.value === null) {
3180
- // inst._zod.values = new Set<util.Primitive>(def.value as any);
3181
- // }
3182
-
3183
- // if (util.propertyKeyTypes.has(typeof def.value)) {
3184
- // inst._zod.pattern = new RegExp(
3185
- // `^(${typeof def.value === "string" ? util.escapeRegex(def.value) : (def.value as any).toString()})$`
3186
- // );
3187
- // } else {
3188
- // throw new Error("Const value cannot be converted to regex");
3189
- // }
3190
-
3191
- // inst._zod.parse = (payload, _ctx) => {
3192
- // payload.value = def.value; // always override
3193
- // return payload;
3194
- // };
3195
- // });
3196
-
3197
- //////////////////////////////////////////
3198
- //////////////////////////////////////////
3199
- ////////// //////////
3200
- ////////// $ZodFile //////////
3201
- ////////// //////////
3202
- //////////////////////////////////////////
3203
- //////////////////////////////////////////
3204
-
3205
- // provide a fallback in case the File interface isn't provided in the environment
3206
- type _File = typeof globalThis extends { File: infer F extends new (...args: any[]) => any } ? InstanceType<F> : {};
3207
- /** Do not reference this directly. */
3208
- export interface File extends _File {
3209
- readonly type: string;
3210
- readonly size: number;
3211
- }
3212
-
3213
- export interface $ZodFileDef extends $ZodTypeDef {
3214
- type: "file";
3215
- }
3216
-
3217
- export interface $ZodFileInternals extends $ZodTypeInternals<File, File> {
3218
- def: $ZodFileDef;
3219
- isst: errors.$ZodIssueInvalidType;
3220
- bag: util.LoosePartial<{
3221
- minimum: number;
3222
- maximum: number;
3223
- mime: util.MimeTypes[];
3224
- }>;
3225
- }
3226
-
3227
- export interface $ZodFile extends $ZodType {
3228
- _zod: $ZodFileInternals;
3229
- }
3230
-
3231
- export const $ZodFile: core.$constructor<$ZodFile> = /*@__PURE__*/ core.$constructor("$ZodFile", (inst, def) => {
3232
- $ZodType.init(inst, def);
3233
-
3234
- inst._zod.parse = (payload, _ctx) => {
3235
- const input = payload.value;
3236
- // @ts-ignore
3237
- if (input instanceof File) return payload;
3238
- payload.issues.push({
3239
- expected: "file",
3240
- code: "invalid_type",
3241
-
3242
- input,
3243
- inst,
3244
- });
3245
- return payload;
3246
- };
3247
- });
3248
-
3249
- //////////////////////////////////////////////
3250
- //////////////////////////////////////////////
3251
- ////////// //////////
3252
- ////////// $ZodTransform //////////
3253
- ////////// //////////
3254
- //////////////////////////////////////////////
3255
- //////////////////////////////////////////////
3256
- export interface $ZodTransformDef extends $ZodTypeDef {
3257
- type: "transform";
3258
- transform: (input: unknown, payload: ParsePayload<unknown>) => util.MaybeAsync<unknown>;
3259
- }
3260
- export interface $ZodTransformInternals<O = unknown, I = unknown> extends $ZodTypeInternals<O, I> {
3261
- def: $ZodTransformDef;
3262
- isst: never;
3263
- }
3264
-
3265
- export interface $ZodTransform<O = unknown, I = unknown> extends $ZodType {
3266
- _zod: $ZodTransformInternals<O, I>;
3267
- }
3268
-
3269
- export const $ZodTransform: core.$constructor<$ZodTransform> = /*@__PURE__*/ core.$constructor(
3270
- "$ZodTransform",
3271
- (inst, def) => {
3272
- $ZodType.init(inst, def);
3273
- inst._zod.parse = (payload, ctx) => {
3274
- if (ctx.direction === "backward") {
3275
- throw new core.$ZodEncodeError(inst.constructor.name);
3276
- }
3277
-
3278
- const _out = def.transform(payload.value, payload);
3279
- if (ctx.async) {
3280
- const output = _out instanceof Promise ? _out : Promise.resolve(_out);
3281
- return output.then((output) => {
3282
- payload.value = output;
3283
- return payload;
3284
- });
3285
- }
3286
-
3287
- if (_out instanceof Promise) {
3288
- throw new core.$ZodAsyncError();
3289
- }
3290
-
3291
- payload.value = _out;
3292
- return payload;
3293
- };
3294
- }
3295
- );
3296
-
3297
- ////////////////////////////////////////////
3298
- ////////////////////////////////////////////
3299
- ////////// //////////
3300
- ////////// $ZodOptional //////////
3301
- ////////// //////////
3302
- ////////////////////////////////////////////
3303
- ////////////////////////////////////////////
3304
- export interface $ZodOptionalDef<T extends SomeType = $ZodType> extends $ZodTypeDef {
3305
- type: "optional";
3306
- innerType: T;
3307
- }
3308
-
3309
- export interface $ZodOptionalInternals<T extends SomeType = $ZodType>
3310
- extends $ZodTypeInternals<core.output<T> | undefined, core.input<T> | undefined> {
3311
- def: $ZodOptionalDef<T>;
3312
- optin: "optional";
3313
- optout: "optional";
3314
- isst: never;
3315
- values: T["_zod"]["values"];
3316
- pattern: T["_zod"]["pattern"];
3317
- }
3318
-
3319
- export interface $ZodOptional<T extends SomeType = $ZodType> extends $ZodType {
3320
- _zod: $ZodOptionalInternals<T>;
3321
- }
3322
-
3323
- function handleOptionalResult(result: ParsePayload, input: unknown) {
3324
- if (result.issues.length && input === undefined) {
3325
- return { issues: [], value: undefined };
3326
- }
3327
- return result;
3328
- }
3329
-
3330
- export const $ZodOptional: core.$constructor<$ZodOptional> = /*@__PURE__*/ core.$constructor(
3331
- "$ZodOptional",
3332
- (inst, def) => {
3333
- $ZodType.init(inst, def);
3334
- inst._zod.optin = "optional";
3335
- inst._zod.optout = "optional";
3336
-
3337
- util.defineLazy(inst._zod, "values", () => {
3338
- return def.innerType._zod.values ? new Set([...def.innerType._zod.values, undefined]) : undefined;
3339
- });
3340
- util.defineLazy(inst._zod, "pattern", () => {
3341
- const pattern = def.innerType._zod.pattern;
3342
- return pattern ? new RegExp(`^(${util.cleanRegex(pattern.source)})?$`) : undefined;
3343
- });
3344
-
3345
- inst._zod.parse = (payload, ctx) => {
3346
- if (def.innerType._zod.optin === "optional") {
3347
- const result = def.innerType._zod.run(payload, ctx);
3348
- if (result instanceof Promise) return result.then((r) => handleOptionalResult(r, payload.value));
3349
- return handleOptionalResult(result, payload.value);
3350
- }
3351
- if (payload.value === undefined) {
3352
- return payload;
3353
- }
3354
- return def.innerType._zod.run(payload, ctx);
3355
- };
3356
- }
3357
- );
3358
-
3359
- ////////////////////////////////////////////////
3360
- ////////////////////////////////////////////////
3361
- ////////// //////////
3362
- ////////// $ZodExactOptional //////////
3363
- ////////// //////////
3364
- ////////////////////////////////////////////////
3365
- ////////////////////////////////////////////////
3366
-
3367
- // Def extends $ZodOptionalDef (no additional fields needed)
3368
- export interface $ZodExactOptionalDef<T extends SomeType = $ZodType> extends $ZodOptionalDef<T> {}
3369
-
3370
- // Internals extends $ZodOptionalInternals but narrows output/input types (removes | undefined)
3371
- export interface $ZodExactOptionalInternals<T extends SomeType = $ZodType> extends $ZodOptionalInternals<T> {
3372
- def: $ZodExactOptionalDef<T>;
3373
- output: core.output<T>; // NO | undefined (narrowed from parent)
3374
- input: core.input<T>; // NO | undefined (narrowed from parent)
3375
- }
3376
-
3377
- export interface $ZodExactOptional<T extends SomeType = $ZodType> extends $ZodType {
3378
- _zod: $ZodExactOptionalInternals<T>;
3379
- }
3380
-
3381
- export const $ZodExactOptional: core.$constructor<$ZodExactOptional> = /*@__PURE__*/ core.$constructor(
3382
- "$ZodExactOptional",
3383
- (inst, def) => {
3384
- // Call parent init - inherits optin/optout = "optional"
3385
- $ZodOptional.init(inst, def);
3386
-
3387
- // Override values/pattern to NOT add undefined
3388
- util.defineLazy(inst._zod, "values", () => def.innerType._zod.values);
3389
- util.defineLazy(inst._zod, "pattern", () => def.innerType._zod.pattern);
3390
-
3391
- // Override parse to just delegate (no undefined handling)
3392
- inst._zod.parse = (payload, ctx) => {
3393
- return def.innerType._zod.run(payload, ctx);
3394
- };
3395
- }
3396
- );
3397
-
3398
- ////////////////////////////////////////////
3399
- ////////////////////////////////////////////
3400
- ////////// //////////
3401
- ////////// $ZodNullable //////////
3402
- ////////// //////////
3403
- ////////////////////////////////////////////
3404
- ////////////////////////////////////////////
3405
- export interface $ZodNullableDef<T extends SomeType = $ZodType> extends $ZodTypeDef {
3406
- type: "nullable";
3407
- innerType: T;
3408
- }
3409
-
3410
- export interface $ZodNullableInternals<T extends SomeType = $ZodType>
3411
- extends $ZodTypeInternals<core.output<T> | null, core.input<T> | null> {
3412
- def: $ZodNullableDef<T>;
3413
- optin: T["_zod"]["optin"];
3414
- optout: T["_zod"]["optout"];
3415
- isst: never;
3416
- values: T["_zod"]["values"];
3417
- pattern: T["_zod"]["pattern"];
3418
- }
3419
-
3420
- export interface $ZodNullable<T extends SomeType = $ZodType> extends $ZodType {
3421
- _zod: $ZodNullableInternals<T>;
3422
- }
3423
-
3424
- export const $ZodNullable: core.$constructor<$ZodNullable> = /*@__PURE__*/ core.$constructor(
3425
- "$ZodNullable",
3426
- (inst, def) => {
3427
- $ZodType.init(inst, def);
3428
- util.defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
3429
- util.defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
3430
-
3431
- util.defineLazy(inst._zod, "pattern", () => {
3432
- const pattern = def.innerType._zod.pattern;
3433
- return pattern ? new RegExp(`^(${util.cleanRegex(pattern.source)}|null)$`) : undefined;
3434
- });
3435
-
3436
- util.defineLazy(inst._zod, "values", () => {
3437
- return def.innerType._zod.values ? new Set([...def.innerType._zod.values, null]) : undefined;
3438
- });
3439
-
3440
- inst._zod.parse = (payload, ctx) => {
3441
- // Forward direction (decode): allow null to pass through
3442
- if (payload.value === null) return payload;
3443
- return def.innerType._zod.run(payload, ctx);
3444
- };
3445
- }
3446
- );
3447
- // );
3448
-
3449
- ////////////////////////////////////////////
3450
- ////////////////////////////////////////////
3451
- ////////// //////////
3452
- ////////// $ZodDefault //////////
3453
- ////////// //////////
3454
- ////////////////////////////////////////////
3455
- ////////////////////////////////////////////
3456
- export interface $ZodDefaultDef<T extends SomeType = $ZodType> extends $ZodTypeDef {
3457
- type: "default";
3458
- innerType: T;
3459
- /** The default value. May be a getter. */
3460
- defaultValue: util.NoUndefined<core.output<T>>;
3461
- }
3462
-
3463
- export interface $ZodDefaultInternals<T extends SomeType = $ZodType>
3464
- extends $ZodTypeInternals<util.NoUndefined<core.output<T>>, core.input<T> | undefined> {
3465
- def: $ZodDefaultDef<T>;
3466
- optin: "optional";
3467
- optout?: "optional" | undefined; // required
3468
- isst: never;
3469
- values: T["_zod"]["values"];
3470
- }
3471
-
3472
- export interface $ZodDefault<T extends SomeType = $ZodType> extends $ZodType {
3473
- _zod: $ZodDefaultInternals<T>;
3474
- }
3475
-
3476
- export const $ZodDefault: core.$constructor<$ZodDefault> = /*@__PURE__*/ core.$constructor(
3477
- "$ZodDefault",
3478
- (inst, def) => {
3479
- $ZodType.init(inst, def);
3480
-
3481
- // inst._zod.qin = "true";
3482
- inst._zod.optin = "optional";
3483
- util.defineLazy(inst._zod, "values", () => def.innerType._zod.values);
3484
-
3485
- inst._zod.parse = (payload, ctx) => {
3486
- if (ctx.direction === "backward") {
3487
- return def.innerType._zod.run(payload, ctx);
3488
- }
3489
-
3490
- // Forward direction (decode): apply defaults for undefined input
3491
- if (payload.value === undefined) {
3492
- payload.value = def.defaultValue;
3493
- /**
3494
- * $ZodDefault returns the default value immediately in forward direction.
3495
- * 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. */
3496
- return payload;
3497
- }
3498
- // Forward direction: continue with default handling
3499
- const result = def.innerType._zod.run(payload, ctx);
3500
- if (result instanceof Promise) {
3501
- return result.then((result) => handleDefaultResult(result, def));
3502
- }
3503
- return handleDefaultResult(result, def);
3504
- };
3505
- }
3506
- );
3507
-
3508
- function handleDefaultResult(payload: ParsePayload, def: $ZodDefaultDef) {
3509
- if (payload.value === undefined) {
3510
- payload.value = def.defaultValue;
3511
- }
3512
- return payload;
3513
- }
3514
-
3515
- ////////////////////////////////////////////
3516
- ////////////////////////////////////////////
3517
- ////////// //////////
3518
- ////////// $ZodPrefault //////////
3519
- ////////// //////////
3520
- ////////////////////////////////////////////
3521
- ////////////////////////////////////////////
3522
-
3523
- export interface $ZodPrefaultDef<T extends SomeType = $ZodType> extends $ZodTypeDef {
3524
- type: "prefault";
3525
- innerType: T;
3526
- /** The default value. May be a getter. */
3527
- defaultValue: core.input<T>;
3528
- }
3529
-
3530
- export interface $ZodPrefaultInternals<T extends SomeType = $ZodType>
3531
- extends $ZodTypeInternals<util.NoUndefined<core.output<T>>, core.input<T> | undefined> {
3532
- def: $ZodPrefaultDef<T>;
3533
- optin: "optional";
3534
- optout?: "optional" | undefined;
3535
- isst: never;
3536
- values: T["_zod"]["values"];
3537
- }
3538
-
3539
- export interface $ZodPrefault<T extends SomeType = $ZodType> extends $ZodType {
3540
- _zod: $ZodPrefaultInternals<T>;
3541
- }
3542
-
3543
- export const $ZodPrefault: core.$constructor<$ZodPrefault> = /*@__PURE__*/ core.$constructor(
3544
- "$ZodPrefault",
3545
- (inst, def) => {
3546
- $ZodType.init(inst, def);
3547
-
3548
- inst._zod.optin = "optional";
3549
- util.defineLazy(inst._zod, "values", () => def.innerType._zod.values);
3550
-
3551
- inst._zod.parse = (payload, ctx) => {
3552
- if (ctx.direction === "backward") {
3553
- return def.innerType._zod.run(payload, ctx);
3554
- }
3555
-
3556
- // Forward direction (decode): apply prefault for undefined input
3557
- if (payload.value === undefined) {
3558
- payload.value = def.defaultValue;
3559
- }
3560
- return def.innerType._zod.run(payload, ctx);
3561
- };
3562
- }
3563
- );
3564
-
3565
- ///////////////////////////////////////////////
3566
- ///////////////////////////////////////////////
3567
- ////////// //////////
3568
- ////////// $ZodNonOptional //////////
3569
- ////////// //////////
3570
- ///////////////////////////////////////////////
3571
- ///////////////////////////////////////////////
3572
- export interface $ZodNonOptionalDef<T extends SomeType = $ZodType> extends $ZodTypeDef {
3573
- type: "nonoptional";
3574
- innerType: T;
3575
- }
3576
-
3577
- export interface $ZodNonOptionalInternals<T extends SomeType = $ZodType>
3578
- extends $ZodTypeInternals<util.NoUndefined<core.output<T>>, util.NoUndefined<core.input<T>>> {
3579
- def: $ZodNonOptionalDef<T>;
3580
- isst: errors.$ZodIssueInvalidType;
3581
- values: T["_zod"]["values"];
3582
- optin: "optional" | undefined;
3583
- optout: "optional" | undefined;
3584
- }
3585
-
3586
- export interface $ZodNonOptional<T extends SomeType = $ZodType> extends $ZodType {
3587
- _zod: $ZodNonOptionalInternals<T>;
3588
- }
3589
-
3590
- export const $ZodNonOptional: core.$constructor<$ZodNonOptional> = /*@__PURE__*/ core.$constructor(
3591
- "$ZodNonOptional",
3592
- (inst, def) => {
3593
- $ZodType.init(inst, def);
3594
-
3595
- util.defineLazy(inst._zod, "values", () => {
3596
- const v = def.innerType._zod.values;
3597
- return v ? new Set([...v].filter((x) => x !== undefined)) : undefined;
3598
- });
3599
-
3600
- inst._zod.parse = (payload, ctx) => {
3601
- const result = def.innerType._zod.run(payload, ctx);
3602
- if (result instanceof Promise) {
3603
- return result.then((result) => handleNonOptionalResult(result, inst));
3604
- }
3605
- return handleNonOptionalResult(result, inst);
3606
- };
3607
- }
3608
- );
3609
-
3610
- function handleNonOptionalResult(payload: ParsePayload, inst: $ZodNonOptional) {
3611
- if (!payload.issues.length && payload.value === undefined) {
3612
- payload.issues.push({
3613
- code: "invalid_type",
3614
- expected: "nonoptional",
3615
- input: payload.value,
3616
- inst,
3617
- });
3618
- }
3619
- return payload;
3620
- }
3621
-
3622
- ////////////////////////////////////////////
3623
- ////////////////////////////////////////////
3624
- ////////// //////////
3625
- ////////// $ZodCoalesce //////////
3626
- ////////// //////////
3627
- ////////////////////////////////////////////
3628
- ////////////////////////////////////////////
3629
- // export interface $ZodCoalesceDef<T extends $ZodType = $ZodType> extends $ZodTypeDef {
3630
- // type: "coalesce";
3631
- // innerType: T;
3632
- // defaultValue: () => NonNullable<T['_zod']["output"]>;
3633
- // }
3634
-
3635
- // export _interface $ZodCoalesceInternals<T extends $ZodType = $ZodType>
3636
- // extends $ZodTypeInternals<NonNullable<T['_zod']["output"]>, T['_zod']["input"] | undefined | null> {
3637
- // _def: $ZodCoalesceDef<T>;
3638
- // _isst: errors.$ZodIssueInvalidType;
3639
- // _qin: "true";
3640
- // }
3641
-
3642
- // function handleCoalesceResult(payload: ParsePayload, def: $ZodCoalesceDef) {
3643
- // payload.value ??= def.defaultValue();
3644
- // return payload;
3645
- // }
3646
-
3647
- // export const $ZodCoalesce: core.$constructor<{_zod: $ZodCoalesceInternals}> = /*@__PURE__*/ core.$constructor(
3648
- // "$ZodCoalesce",
3649
- // (inst, def) => {
3650
- // $ZodType.init(inst, def);
3651
- // inst._zod.qin = "true";
3652
- // inst._zod.parse = (payload, ctx) => {
3653
- // const result = def.innerType._zod.run(payload, ctx);
3654
- // if (result instanceof Promise) {
3655
- // return result.then((result) => handleCoalesceResult(result, def));
3656
- // }
3657
- // return handleCoalesceResult(result, def);
3658
- // };
3659
- // }
3660
- // );
3661
-
3662
- /////////////////////////////////////////////
3663
- /////////////////////////////////////////////
3664
- ////////// //////////
3665
- ////////// $ZodSuccess //////////
3666
- ////////// //////////
3667
- /////////////////////////////////////////////
3668
- /////////////////////////////////////////////
3669
- export interface $ZodSuccessDef<T extends SomeType = $ZodType> extends $ZodTypeDef {
3670
- type: "success";
3671
- innerType: T;
3672
- }
3673
-
3674
- export interface $ZodSuccessInternals<T extends SomeType = $ZodType> extends $ZodTypeInternals<boolean, core.input<T>> {
3675
- def: $ZodSuccessDef<T>;
3676
- isst: never;
3677
- optin: T["_zod"]["optin"];
3678
- optout: "optional" | undefined;
3679
- }
3680
-
3681
- export interface $ZodSuccess<T extends SomeType = $ZodType> extends $ZodType {
3682
- _zod: $ZodSuccessInternals<T>;
3683
- }
3684
-
3685
- export const $ZodSuccess: core.$constructor<$ZodSuccess> = /*@__PURE__*/ core.$constructor(
3686
- "$ZodSuccess",
3687
- (inst, def) => {
3688
- $ZodType.init(inst, def);
3689
-
3690
- inst._zod.parse = (payload, ctx) => {
3691
- if (ctx.direction === "backward") {
3692
- throw new core.$ZodEncodeError("ZodSuccess");
3693
- }
3694
-
3695
- const result = def.innerType._zod.run(payload, ctx);
3696
- if (result instanceof Promise) {
3697
- return result.then((result) => {
3698
- payload.value = result.issues.length === 0;
3699
- return payload;
3700
- });
3701
- }
3702
- payload.value = result.issues.length === 0;
3703
- return payload;
3704
- };
3705
- }
3706
- );
3707
-
3708
- ////////////////////////////////////////////
3709
- ////////////////////////////////////////////
3710
- ////////// //////////
3711
- ////////// $ZodCatch //////////
3712
- ////////// //////////
3713
- ////////////////////////////////////////////
3714
- ////////////////////////////////////////////
3715
- export interface $ZodCatchCtx extends ParsePayload {
3716
- /** @deprecated Use `ctx.issues` */
3717
- error: { issues: errors.$ZodIssue[] };
3718
- /** @deprecated Use `ctx.value` */
3719
- input: unknown;
3720
- }
3721
- export interface $ZodCatchDef<T extends SomeType = $ZodType> extends $ZodTypeDef {
3722
- type: "catch";
3723
- innerType: T;
3724
- catchValue: (ctx: $ZodCatchCtx) => unknown;
3725
- }
3726
-
3727
- export interface $ZodCatchInternals<T extends SomeType = $ZodType>
3728
- extends $ZodTypeInternals<core.output<T>, core.input<T>> {
3729
- def: $ZodCatchDef<T>;
3730
- optin: T["_zod"]["optin"];
3731
- optout: T["_zod"]["optout"];
3732
- isst: never;
3733
- values: T["_zod"]["values"];
3734
- }
3735
-
3736
- export interface $ZodCatch<T extends SomeType = $ZodType> extends $ZodType {
3737
- _zod: $ZodCatchInternals<T>;
3738
- }
3739
-
3740
- export const $ZodCatch: core.$constructor<$ZodCatch> = /*@__PURE__*/ core.$constructor("$ZodCatch", (inst, def) => {
3741
- $ZodType.init(inst, def);
3742
- util.defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
3743
- util.defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
3744
- util.defineLazy(inst._zod, "values", () => def.innerType._zod.values);
3745
-
3746
- inst._zod.parse = (payload, ctx) => {
3747
- if (ctx.direction === "backward") {
3748
- return def.innerType._zod.run(payload, ctx);
3749
- }
3750
-
3751
- // Forward direction (decode): apply catch logic
3752
- const result = def.innerType._zod.run(payload, ctx);
3753
- if (result instanceof Promise) {
3754
- return result.then((result) => {
3755
- payload.value = result.value;
3756
- if (result.issues.length) {
3757
- payload.value = def.catchValue({
3758
- ...payload,
3759
- error: {
3760
- issues: result.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())),
3761
- },
3762
- input: payload.value,
3763
- });
3764
- payload.issues = [];
3765
- }
3766
-
3767
- return payload;
3768
- });
3769
- }
3770
-
3771
- payload.value = result.value;
3772
- if (result.issues.length) {
3773
- payload.value = def.catchValue({
3774
- ...payload,
3775
- error: {
3776
- issues: result.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())),
3777
- },
3778
- input: payload.value,
3779
- });
3780
-
3781
- payload.issues = [];
3782
- }
3783
-
3784
- return payload;
3785
- };
3786
- });
3787
-
3788
- ////////////////////////////////////////////
3789
- ////////////////////////////////////////////
3790
- ////////// //////////
3791
- ////////// $ZodNaN //////////
3792
- ////////// //////////
3793
- ////////////////////////////////////////////
3794
- ////////////////////////////////////////////
3795
- export interface $ZodNaNDef extends $ZodTypeDef {
3796
- type: "nan";
3797
- }
3798
-
3799
- export interface $ZodNaNInternals extends $ZodTypeInternals<number, number> {
3800
- def: $ZodNaNDef;
3801
- isst: errors.$ZodIssueInvalidType;
3802
- }
3803
-
3804
- export interface $ZodNaN extends $ZodType {
3805
- _zod: $ZodNaNInternals;
3806
- }
3807
-
3808
- export const $ZodNaN: core.$constructor<$ZodNaN> = /*@__PURE__*/ core.$constructor("$ZodNaN", (inst, def) => {
3809
- $ZodType.init(inst, def);
3810
-
3811
- inst._zod.parse = (payload, _ctx) => {
3812
- if (typeof payload.value !== "number" || !Number.isNaN(payload.value)) {
3813
- payload.issues.push({
3814
- input: payload.value,
3815
- inst,
3816
- expected: "nan",
3817
- code: "invalid_type",
3818
- });
3819
- return payload;
3820
- }
3821
- return payload;
3822
- };
3823
- });
3824
-
3825
- ////////////////////////////////////////////
3826
- ////////////////////////////////////////////
3827
- ////////// //////////
3828
- ////////// $ZodPipe //////////
3829
- ////////// //////////
3830
- ////////////////////////////////////////////
3831
- ////////////////////////////////////////////
3832
- export interface $ZodPipeDef<A extends SomeType = $ZodType, B extends SomeType = $ZodType> extends $ZodTypeDef {
3833
- type: "pipe";
3834
- in: A;
3835
- out: B;
3836
- /** Only defined inside $ZodCodec instances. */
3837
- transform?: (value: core.output<A>, payload: ParsePayload<core.output<A>>) => util.MaybeAsync<core.input<B>>;
3838
- /** Only defined inside $ZodCodec instances. */
3839
- reverseTransform?: (value: core.input<B>, payload: ParsePayload<core.input<B>>) => util.MaybeAsync<core.output<A>>;
3840
- }
3841
-
3842
- export interface $ZodPipeInternals<A extends SomeType = $ZodType, B extends SomeType = $ZodType>
3843
- extends $ZodTypeInternals<core.output<B>, core.input<A>> {
3844
- def: $ZodPipeDef<A, B>;
3845
- isst: never;
3846
- values: A["_zod"]["values"];
3847
- optin: A["_zod"]["optin"];
3848
- optout: B["_zod"]["optout"];
3849
- propValues: A["_zod"]["propValues"];
3850
- }
3851
-
3852
- export interface $ZodPipe<A extends SomeType = $ZodType, B extends SomeType = $ZodType> extends $ZodType {
3853
- _zod: $ZodPipeInternals<A, B>;
3854
- }
3855
-
3856
- export const $ZodPipe: core.$constructor<$ZodPipe> = /*@__PURE__*/ core.$constructor("$ZodPipe", (inst, def) => {
3857
- $ZodType.init(inst, def);
3858
- util.defineLazy(inst._zod, "values", () => def.in._zod.values);
3859
- util.defineLazy(inst._zod, "optin", () => def.in._zod.optin);
3860
- util.defineLazy(inst._zod, "optout", () => def.out._zod.optout);
3861
- util.defineLazy(inst._zod, "propValues", () => def.in._zod.propValues);
3862
-
3863
- inst._zod.parse = (payload, ctx) => {
3864
- if (ctx.direction === "backward") {
3865
- const right = def.out._zod.run(payload, ctx);
3866
- if (right instanceof Promise) {
3867
- return right.then((right) => handlePipeResult(right, def.in, ctx));
3868
- }
3869
- return handlePipeResult(right, def.in, ctx);
3870
- }
3871
-
3872
- const left = def.in._zod.run(payload, ctx);
3873
- if (left instanceof Promise) {
3874
- return left.then((left) => handlePipeResult(left, def.out, ctx));
3875
- }
3876
- return handlePipeResult(left, def.out, ctx);
3877
- };
3878
- });
3879
-
3880
- function handlePipeResult(left: ParsePayload, next: $ZodType, ctx: ParseContextInternal) {
3881
- if (left.issues.length) {
3882
- // prevent further checks
3883
- left.aborted = true;
3884
- return left;
3885
- }
3886
- return next._zod.run({ value: left.value, issues: left.issues }, ctx);
3887
- }
3888
-
3889
- ////////////////////////////////////////////
3890
- ////////////////////////////////////////////
3891
- ////////// //////////
3892
- ////////// $ZodCodec //////////
3893
- ////////// //////////
3894
- ////////////////////////////////////////////
3895
- ////////////////////////////////////////////
3896
- export interface $ZodCodecDef<A extends SomeType = $ZodType, B extends SomeType = $ZodType> extends $ZodPipeDef<A, B> {
3897
- transform: (value: core.output<A>, payload: ParsePayload<core.output<A>>) => util.MaybeAsync<core.input<B>>;
3898
- reverseTransform: (value: core.input<B>, payload: ParsePayload<core.input<B>>) => util.MaybeAsync<core.output<A>>;
3899
- }
3900
-
3901
- export interface $ZodCodecInternals<A extends SomeType = $ZodType, B extends SomeType = $ZodType>
3902
- extends $ZodTypeInternals<core.output<B>, core.input<A>> {
3903
- def: $ZodCodecDef<A, B>;
3904
- isst: never;
3905
- values: A["_zod"]["values"];
3906
- optin: A["_zod"]["optin"];
3907
- optout: B["_zod"]["optout"];
3908
- propValues: A["_zod"]["propValues"];
3909
- }
3910
-
3911
- export interface $ZodCodec<A extends SomeType = $ZodType, B extends SomeType = $ZodType> extends $ZodType {
3912
- _zod: $ZodCodecInternals<A, B>;
3913
- }
3914
-
3915
- export const $ZodCodec: core.$constructor<$ZodCodec> = /*@__PURE__*/ core.$constructor("$ZodCodec", (inst, def) => {
3916
- $ZodType.init(inst, def);
3917
- util.defineLazy(inst._zod, "values", () => def.in._zod.values);
3918
- util.defineLazy(inst._zod, "optin", () => def.in._zod.optin);
3919
- util.defineLazy(inst._zod, "optout", () => def.out._zod.optout);
3920
- util.defineLazy(inst._zod, "propValues", () => def.in._zod.propValues);
3921
-
3922
- inst._zod.parse = (payload, ctx) => {
3923
- const direction = ctx.direction || "forward";
3924
- if (direction === "forward") {
3925
- const left = def.in._zod.run(payload, ctx);
3926
- if (left instanceof Promise) {
3927
- return left.then((left) => handleCodecAResult(left, def, ctx));
3928
- }
3929
- return handleCodecAResult(left, def, ctx);
3930
- } else {
3931
- const right = def.out._zod.run(payload, ctx);
3932
- if (right instanceof Promise) {
3933
- return right.then((right) => handleCodecAResult(right, def, ctx));
3934
- }
3935
- return handleCodecAResult(right, def, ctx);
3936
- }
3937
- };
3938
- });
3939
-
3940
- function handleCodecAResult(result: ParsePayload, def: $ZodCodecDef, ctx: ParseContextInternal) {
3941
- if (result.issues.length) {
3942
- // prevent further checks
3943
- result.aborted = true;
3944
- return result;
3945
- }
3946
-
3947
- const direction = ctx.direction || "forward";
3948
-
3949
- if (direction === "forward") {
3950
- const transformed = def.transform(result.value, result);
3951
- if (transformed instanceof Promise) {
3952
- return transformed.then((value) => handleCodecTxResult(result, value, def.out, ctx));
3953
- }
3954
- return handleCodecTxResult(result, transformed, def.out, ctx);
3955
- } else {
3956
- const transformed = def.reverseTransform(result.value, result);
3957
- if (transformed instanceof Promise) {
3958
- return transformed.then((value) => handleCodecTxResult(result, value, def.in, ctx));
3959
- }
3960
- return handleCodecTxResult(result, transformed, def.in, ctx);
3961
- }
3962
- }
3963
-
3964
- function handleCodecTxResult(left: ParsePayload, value: any, nextSchema: SomeType, ctx: ParseContextInternal) {
3965
- // Check if transform added any issues
3966
- if (left.issues.length) {
3967
- left.aborted = true;
3968
- return left;
3969
- }
3970
-
3971
- return nextSchema._zod.run({ value, issues: left.issues }, ctx);
3972
- }
3973
-
3974
- ////////////////////////////////////////////
3975
- ////////////////////////////////////////////
3976
- ////////// //////////
3977
- ////////// $ZodReadonly //////////
3978
- ////////// //////////
3979
- ////////////////////////////////////////////
3980
- ////////////////////////////////////////////
3981
-
3982
- export interface $ZodReadonlyDef<T extends SomeType = $ZodType> extends $ZodTypeDef {
3983
- type: "readonly";
3984
- innerType: T;
3985
- }
3986
-
3987
- export interface $ZodReadonlyInternals<T extends SomeType = $ZodType>
3988
- extends $ZodTypeInternals<util.MakeReadonly<core.output<T>>, util.MakeReadonly<core.input<T>>> {
3989
- def: $ZodReadonlyDef<T>;
3990
- optin: T["_zod"]["optin"];
3991
- optout: T["_zod"]["optout"];
3992
- isst: never;
3993
- propValues: T["_zod"]["propValues"];
3994
- values: T["_zod"]["values"];
3995
- }
3996
-
3997
- export interface $ZodReadonly<T extends SomeType = $ZodType> extends $ZodType {
3998
- _zod: $ZodReadonlyInternals<T>;
3999
- }
4000
-
4001
- export const $ZodReadonly: core.$constructor<$ZodReadonly> = /*@__PURE__*/ core.$constructor(
4002
- "$ZodReadonly",
4003
- (inst, def) => {
4004
- $ZodType.init(inst, def);
4005
- util.defineLazy(inst._zod, "propValues", () => def.innerType._zod.propValues);
4006
- util.defineLazy(inst._zod, "values", () => def.innerType._zod.values);
4007
- util.defineLazy(inst._zod, "optin", () => def.innerType?._zod?.optin);
4008
- util.defineLazy(inst._zod, "optout", () => def.innerType?._zod?.optout);
4009
-
4010
- inst._zod.parse = (payload, ctx) => {
4011
- if (ctx.direction === "backward") {
4012
- return def.innerType._zod.run(payload, ctx);
4013
- }
4014
- const result = def.innerType._zod.run(payload, ctx);
4015
- if (result instanceof Promise) {
4016
- return result.then(handleReadonlyResult);
4017
- }
4018
- return handleReadonlyResult(result);
4019
- };
4020
- }
4021
- );
4022
-
4023
- function handleReadonlyResult(payload: ParsePayload): ParsePayload {
4024
- payload.value = Object.freeze(payload.value);
4025
- return payload;
4026
- }
4027
-
4028
- /////////////////////////////////////////////
4029
- /////////////////////////////////////////////
4030
- ////////// //////////
4031
- ////////// $ZodTemplateLiteral //////////
4032
- ////////// //////////
4033
- /////////////////////////////////////////////
4034
- /////////////////////////////////////////////
4035
-
4036
- export interface $ZodTemplateLiteralDef extends $ZodTypeDef {
4037
- type: "template_literal";
4038
- parts: $ZodTemplateLiteralPart[];
4039
- format?: string | undefined;
4040
- }
4041
- export interface $ZodTemplateLiteralInternals<Template extends string = string>
4042
- extends $ZodTypeInternals<Template, Template> {
4043
- pattern: RegExp;
4044
- def: $ZodTemplateLiteralDef;
4045
- isst: errors.$ZodIssueInvalidType;
4046
- }
4047
-
4048
- export interface $ZodTemplateLiteral<Template extends string = string> extends $ZodType {
4049
- _zod: $ZodTemplateLiteralInternals<Template>;
4050
- }
4051
-
4052
- type LiteralPart = Exclude<util.Literal, symbol>; //string | number | boolean | null | undefined;
4053
- interface SchemaPartInternals extends $ZodTypeInternals<LiteralPart, LiteralPart> {
4054
- pattern: RegExp;
4055
- }
4056
- interface SchemaPart extends $ZodType {
4057
- _zod: SchemaPartInternals;
4058
- }
4059
- export type $ZodTemplateLiteralPart = LiteralPart | SchemaPart;
4060
-
4061
- type UndefinedToEmptyString<T> = T extends undefined ? "" : T;
4062
- type AppendToTemplateLiteral<
4063
- Template extends string,
4064
- Suffix extends LiteralPart | $ZodType,
4065
- > = Suffix extends LiteralPart
4066
- ? `${Template}${UndefinedToEmptyString<Suffix>}`
4067
- : Suffix extends $ZodType
4068
- ? `${Template}${core.output<Suffix> extends infer T extends LiteralPart ? UndefinedToEmptyString<T> : never}`
4069
- : never;
4070
-
4071
- export type ConcatenateTupleOfStrings<T extends string[]> = T extends [
4072
- infer First extends string,
4073
- ...infer Rest extends string[],
4074
- ]
4075
- ? Rest extends string[]
4076
- ? First extends ""
4077
- ? ConcatenateTupleOfStrings<Rest>
4078
- : `${First}${ConcatenateTupleOfStrings<Rest>}`
4079
- : never
4080
- : "";
4081
- export type ConvertPartsToStringTuple<Parts extends $ZodTemplateLiteralPart[]> = {
4082
- [K in keyof Parts]: Parts[K] extends LiteralPart
4083
- ? `${UndefinedToEmptyString<Parts[K]>}`
4084
- : Parts[K] extends $ZodType
4085
- ? `${core.output<Parts[K]> extends infer T extends LiteralPart ? UndefinedToEmptyString<T> : never}`
4086
- : never;
4087
- };
4088
-
4089
- export type ToTemplateLiteral<Parts extends $ZodTemplateLiteralPart[]> = ConcatenateTupleOfStrings<
4090
- ConvertPartsToStringTuple<Parts>
4091
- >;
4092
- // type lkjasd = ConcatenateTupleOfStrings<["Hello", " ", "World", "!"]>; // "Hello World!"
4093
- export type $PartsToTemplateLiteral<Parts extends $ZodTemplateLiteralPart[]> = [] extends Parts
4094
- ? ``
4095
- : Parts extends [...infer Rest, infer Last extends $ZodTemplateLiteralPart]
4096
- ? Rest extends $ZodTemplateLiteralPart[]
4097
- ? AppendToTemplateLiteral<$PartsToTemplateLiteral<Rest>, Last>
4098
- : never
4099
- : never;
4100
-
4101
- export const $ZodTemplateLiteral: core.$constructor<$ZodTemplateLiteral> = /*@__PURE__*/ core.$constructor(
4102
- "$ZodTemplateLiteral",
4103
- (inst, def) => {
4104
- $ZodType.init(inst, def);
4105
- const regexParts: string[] = [];
4106
- for (const part of def.parts) {
4107
- if (typeof part === "object" && part !== null) {
4108
- // is Zod schema
4109
- if (!part._zod.pattern) {
4110
- // if (!source)
4111
- throw new Error(`Invalid template literal part, no pattern found: ${[...(part as any)._zod.traits].shift()}`);
4112
- }
4113
-
4114
- const source = part._zod.pattern instanceof RegExp ? part._zod.pattern.source : part._zod.pattern;
4115
-
4116
- if (!source) throw new Error(`Invalid template literal part: ${part._zod.traits}`);
4117
-
4118
- const start = source.startsWith("^") ? 1 : 0;
4119
- const end = source.endsWith("$") ? source.length - 1 : source.length;
4120
- regexParts.push(source.slice(start, end));
4121
- } else if (part === null || util.primitiveTypes.has(typeof part)) {
4122
- regexParts.push(util.escapeRegex(`${part}`));
4123
- } else {
4124
- throw new Error(`Invalid template literal part: ${part}`);
4125
- }
4126
- }
4127
- inst._zod.pattern = new RegExp(`^${regexParts.join("")}$`);
4128
-
4129
- inst._zod.parse = (payload, _ctx) => {
4130
- if (typeof payload.value !== "string") {
4131
- payload.issues.push({
4132
- input: payload.value,
4133
- inst,
4134
- expected: "string",
4135
- code: "invalid_type",
4136
- });
4137
- return payload;
4138
- }
4139
-
4140
- inst._zod.pattern.lastIndex = 0;
4141
-
4142
- if (!inst._zod.pattern.test(payload.value)) {
4143
- payload.issues.push({
4144
- input: payload.value,
4145
- inst,
4146
-
4147
- code: "invalid_format",
4148
- format: def.format ?? "template_literal",
4149
- pattern: inst._zod.pattern.source,
4150
- });
4151
- return payload;
4152
- }
4153
-
4154
- return payload;
4155
- };
4156
- }
4157
- );
4158
-
4159
- //////////////////////////////////////////
4160
- //////////////////////////////////////////
4161
- ////////// //////////
4162
- ////////// $ZodFunction //////////
4163
- ////////// //////////
4164
- //////////////////////////////////////////
4165
- //////////////////////////////////////////
4166
- export type $ZodFunctionArgs = $ZodType<unknown[], unknown[]>;
4167
- export type $ZodFunctionIn = $ZodFunctionArgs;
4168
- export type $ZodFunctionOut = $ZodType;
4169
-
4170
- export type $InferInnerFunctionType<Args extends $ZodFunctionIn, Returns extends $ZodFunctionOut> = (
4171
- ...args: $ZodFunctionIn extends Args ? never[] : core.output<Args>
4172
- ) => core.input<Returns>;
4173
-
4174
- export type $InferInnerFunctionTypeAsync<Args extends $ZodFunctionIn, Returns extends $ZodFunctionOut> = (
4175
- ...args: $ZodFunctionIn extends Args ? never[] : core.output<Args>
4176
- ) => util.MaybeAsync<core.input<Returns>>;
4177
-
4178
- export type $InferOuterFunctionType<Args extends $ZodFunctionIn, Returns extends $ZodFunctionOut> = (
4179
- ...args: $ZodFunctionIn extends Args ? never[] : core.input<Args>
4180
- ) => core.output<Returns>;
4181
-
4182
- export type $InferOuterFunctionTypeAsync<Args extends $ZodFunctionIn, Returns extends $ZodFunctionOut> = (
4183
- ...args: $ZodFunctionIn extends Args ? never[] : core.input<Args>
4184
- ) => Promise<core.output<Returns>>;
4185
-
4186
- export interface $ZodFunctionDef<
4187
- In extends $ZodFunctionIn = $ZodFunctionIn,
4188
- Out extends $ZodFunctionOut = $ZodFunctionOut,
4189
- > extends $ZodTypeDef {
4190
- type: "function";
4191
- input: In;
4192
- output: Out;
4193
- }
4194
-
4195
- export interface $ZodFunctionInternals<Args extends $ZodFunctionIn, Returns extends $ZodFunctionOut>
4196
- extends $ZodTypeInternals<$InferOuterFunctionType<Args, Returns>, $InferInnerFunctionType<Args, Returns>> {
4197
- def: $ZodFunctionDef<Args, Returns>;
4198
- isst: errors.$ZodIssueInvalidType;
4199
- }
4200
-
4201
- export interface $ZodFunction<
4202
- Args extends $ZodFunctionIn = $ZodFunctionIn,
4203
- Returns extends $ZodFunctionOut = $ZodFunctionOut,
4204
- > extends $ZodType<any, any, $ZodFunctionInternals<Args, Returns>> {
4205
- /** @deprecated */
4206
- _def: $ZodFunctionDef<Args, Returns>;
4207
- _input: $InferInnerFunctionType<Args, Returns>;
4208
- _output: $InferOuterFunctionType<Args, Returns>;
4209
-
4210
- implement<F extends $InferInnerFunctionType<Args, Returns>>(
4211
- func: F
4212
- ): // allow for return type inference
4213
- (
4214
- ...args: Parameters<this["_output"]>
4215
- ) => ReturnType<F> extends ReturnType<this["_output"]> ? ReturnType<F> : ReturnType<this["_output"]>;
4216
-
4217
- implementAsync<F extends $InferInnerFunctionTypeAsync<Args, Returns>>(
4218
- func: F
4219
- ): F extends $InferOuterFunctionTypeAsync<Args, Returns> ? F : $InferOuterFunctionTypeAsync<Args, Returns>;
4220
-
4221
- input<const Items extends util.TupleItems, const Rest extends $ZodFunctionOut = $ZodFunctionOut>(
4222
- args: Items,
4223
- rest?: Rest
4224
- ): $ZodFunction<$ZodTuple<Items, Rest>, Returns>;
4225
- input<NewArgs extends $ZodFunctionIn>(args: NewArgs): $ZodFunction<NewArgs, Returns>;
4226
- input(...args: any[]): $ZodFunction<any, Returns>;
4227
-
4228
- output<NewReturns extends $ZodType>(output: NewReturns): $ZodFunction<Args, NewReturns>;
4229
- }
4230
-
4231
- export interface $ZodFunctionParams<I extends $ZodFunctionIn, O extends $ZodType> {
4232
- input?: I;
4233
- output?: O;
4234
- }
4235
-
4236
- export const $ZodFunction: core.$constructor<$ZodFunction> = /*@__PURE__*/ core.$constructor(
4237
- "$ZodFunction",
4238
- (inst, def) => {
4239
- $ZodType.init(inst, def);
4240
- inst._def = def;
4241
- inst._zod.def = def;
4242
-
4243
- inst.implement = (func) => {
4244
- if (typeof func !== "function") {
4245
- throw new Error("implement() must be called with a function");
4246
- }
4247
- return function (this: any, ...args: never[]) {
4248
- const parsedArgs = inst._def.input ? parse(inst._def.input, args) : args;
4249
- const result = Reflect.apply(func, this, parsedArgs as never[]);
4250
- if (inst._def.output) {
4251
- return parse(inst._def.output, result);
4252
- }
4253
- return result as any;
4254
- };
4255
- };
4256
-
4257
- inst.implementAsync = (func) => {
4258
- if (typeof func !== "function") {
4259
- throw new Error("implementAsync() must be called with a function");
4260
- }
4261
- return async function (this: any, ...args: never[]) {
4262
- const parsedArgs = inst._def.input ? await parseAsync(inst._def.input, args) : args;
4263
- const result = await Reflect.apply(func, this, parsedArgs as never[]);
4264
- if (inst._def.output) {
4265
- return await parseAsync(inst._def.output, result);
4266
- }
4267
- return result;
4268
- } as any;
4269
- };
4270
-
4271
- inst._zod.parse = (payload, _ctx) => {
4272
- if (typeof payload.value !== "function") {
4273
- payload.issues.push({
4274
- code: "invalid_type",
4275
- expected: "function",
4276
- input: payload.value,
4277
- inst,
4278
- });
4279
- return payload;
4280
- }
4281
-
4282
- // Check if output is a promise type to determine if we should use async implementation
4283
- const hasPromiseOutput = inst._def.output && inst._def.output._zod.def.type === "promise";
4284
-
4285
- if (hasPromiseOutput) {
4286
- payload.value = inst.implementAsync(payload.value);
4287
- } else {
4288
- payload.value = inst.implement(payload.value);
4289
- }
4290
- return payload;
4291
- };
4292
-
4293
- inst.input = (...args: any[]): $ZodFunction<any, any> => {
4294
- const F: any = inst.constructor;
4295
- if (Array.isArray(args[0])) {
4296
- return new F({
4297
- type: "function",
4298
- input: new $ZodTuple({
4299
- type: "tuple",
4300
- items: args[0],
4301
- rest: args[1],
4302
- }),
4303
- output: inst._def.output,
4304
- });
4305
- }
4306
-
4307
- return new F({
4308
- type: "function",
4309
- input: args[0],
4310
- output: inst._def.output,
4311
- });
4312
- };
4313
-
4314
- inst.output = (output) => {
4315
- const F: any = inst.constructor;
4316
- return new F({
4317
- type: "function",
4318
- input: inst._def.input,
4319
- output,
4320
- });
4321
- };
4322
-
4323
- return inst;
4324
- }
4325
- );
4326
-
4327
- /////////////////////////////////////////
4328
- /////////////////////////////////////////
4329
- ////////// //////////
4330
- ////////// $ZodPromise //////////
4331
- ////////// //////////
4332
- /////////////////////////////////////////
4333
- /////////////////////////////////////////
4334
- export interface $ZodPromiseDef<T extends SomeType = $ZodType> extends $ZodTypeDef {
4335
- type: "promise";
4336
- innerType: T;
4337
- }
4338
-
4339
- export interface $ZodPromiseInternals<T extends SomeType = $ZodType>
4340
- extends $ZodTypeInternals<Promise<core.output<T>>, util.MaybeAsync<core.input<T>>> {
4341
- def: $ZodPromiseDef<T>;
4342
- isst: never;
4343
- }
4344
-
4345
- export interface $ZodPromise<T extends SomeType = $ZodType> extends $ZodType {
4346
- _zod: $ZodPromiseInternals<T>;
4347
- }
4348
-
4349
- export const $ZodPromise: core.$constructor<$ZodPromise> = /*@__PURE__*/ core.$constructor(
4350
- "$ZodPromise",
4351
- (inst, def) => {
4352
- $ZodType.init(inst, def);
4353
-
4354
- inst._zod.parse = (payload, ctx) => {
4355
- return Promise.resolve(payload.value).then((inner) => def.innerType._zod.run({ value: inner, issues: [] }, ctx));
4356
- };
4357
- }
4358
- );
4359
-
4360
- //////////////////////////////////////////
4361
- //////////////////////////////////////////
4362
- ////////// //////////
4363
- ////////// $ZodLazy //////////
4364
- ////////// //////////
4365
- //////////////////////////////////////////
4366
- //////////////////////////////////////////
4367
-
4368
- export interface $ZodLazyDef<T extends SomeType = $ZodType> extends $ZodTypeDef {
4369
- type: "lazy";
4370
- getter: () => T;
4371
- }
4372
-
4373
- export interface $ZodLazyInternals<T extends SomeType = $ZodType>
4374
- extends $ZodTypeInternals<core.output<T>, core.input<T>> {
4375
- def: $ZodLazyDef<T>;
4376
- isst: never;
4377
- /** Auto-cached way to retrieve the inner schema */
4378
- innerType: T;
4379
- pattern: T["_zod"]["pattern"];
4380
- propValues: T["_zod"]["propValues"];
4381
- optin: T["_zod"]["optin"];
4382
- optout: T["_zod"]["optout"];
4383
- }
4384
-
4385
- export interface $ZodLazy<T extends SomeType = $ZodType> extends $ZodType {
4386
- _zod: $ZodLazyInternals<T>;
4387
- }
4388
-
4389
- export const $ZodLazy: core.$constructor<$ZodLazy> = /*@__PURE__*/ core.$constructor("$ZodLazy", (inst, def) => {
4390
- $ZodType.init(inst, def);
4391
-
4392
- // let _innerType!: any;
4393
- // util.defineLazy(def, "getter", () => {
4394
- // if (!_innerType) {
4395
- // _innerType = def.getter();
4396
- // }
4397
- // return () => _innerType;
4398
- // });
4399
- util.defineLazy(inst._zod, "innerType", () => def.getter() as $ZodType);
4400
- util.defineLazy(inst._zod, "pattern", () => inst._zod.innerType?._zod?.pattern);
4401
- util.defineLazy(inst._zod, "propValues", () => inst._zod.innerType?._zod?.propValues);
4402
- util.defineLazy(inst._zod, "optin", () => inst._zod.innerType?._zod?.optin ?? undefined);
4403
- util.defineLazy(inst._zod, "optout", () => inst._zod.innerType?._zod?.optout ?? undefined);
4404
- inst._zod.parse = (payload, ctx) => {
4405
- const inner = inst._zod.innerType;
4406
- return inner._zod.run(payload, ctx);
4407
- };
4408
- });
4409
-
4410
- ////////////////////////////////////////
4411
- ////////////////////////////////////////
4412
- ////////// //////////
4413
- ////////// $ZodCustom //////////
4414
- ////////// //////////
4415
- ////////////////////////////////////////
4416
- ////////////////////////////////////////
4417
- export interface $ZodCustomDef<O = unknown> extends $ZodTypeDef, checks.$ZodCheckDef {
4418
- type: "custom";
4419
- check: "custom";
4420
- path?: PropertyKey[] | undefined;
4421
- error?: errors.$ZodErrorMap | undefined;
4422
- params?: Record<string, any> | undefined;
4423
- fn: (arg: O) => unknown;
4424
- }
4425
-
4426
- export interface $ZodCustomInternals<O = unknown, I = unknown>
4427
- extends $ZodTypeInternals<O, I>,
4428
- checks.$ZodCheckInternals<O> {
4429
- def: $ZodCustomDef;
4430
- issc: errors.$ZodIssue;
4431
- isst: never;
4432
- bag: util.LoosePartial<{
4433
- Class: typeof util.Class;
4434
- }>;
4435
- }
4436
-
4437
- export interface $ZodCustom<O = unknown, I = unknown> extends $ZodType {
4438
- _zod: $ZodCustomInternals<O, I>;
4439
- }
4440
-
4441
- export const $ZodCustom: core.$constructor<$ZodCustom> = /*@__PURE__*/ core.$constructor("$ZodCustom", (inst, def) => {
4442
- checks.$ZodCheck.init(inst, def);
4443
- $ZodType.init(inst, def);
4444
-
4445
- inst._zod.parse = (payload, _) => {
4446
- return payload;
4447
- };
4448
-
4449
- inst._zod.check = (payload) => {
4450
- const input = payload.value;
4451
- const r = def.fn(input as any);
4452
- if (r instanceof Promise) {
4453
- return r.then((r) => handleRefineResult(r, payload, input, inst));
4454
- }
4455
- handleRefineResult(r, payload, input, inst);
4456
- return;
4457
- };
4458
- });
4459
-
4460
- function handleRefineResult(result: unknown, payload: ParsePayload, input: unknown, inst: $ZodCustom): void {
4461
- if (!result) {
4462
- const _iss: any = {
4463
- code: "custom",
4464
- input,
4465
- inst, // incorporates params.error into issue reporting
4466
- path: [...(inst._zod.def.path ?? [])], // incorporates params.error into issue reporting
4467
- continue: !inst._zod.def.abort,
4468
- // params: inst._zod.def.params,
4469
- };
4470
- if (inst._zod.def.params) _iss.params = inst._zod.def.params;
4471
- payload.issues.push(util.issue(_iss));
4472
- }
4473
- }
4474
-
4475
- export type $ZodTypes =
4476
- | $ZodString
4477
- | $ZodNumber
4478
- | $ZodBigInt
4479
- | $ZodBoolean
4480
- | $ZodDate
4481
- | $ZodSymbol
4482
- | $ZodUndefined
4483
- | $ZodNullable
4484
- | $ZodNull
4485
- | $ZodAny
4486
- | $ZodUnknown
4487
- | $ZodNever
4488
- | $ZodVoid
4489
- | $ZodArray
4490
- | $ZodObject
4491
- | $ZodUnion
4492
- | $ZodIntersection
4493
- | $ZodTuple
4494
- | $ZodRecord
4495
- | $ZodMap
4496
- | $ZodSet
4497
- | $ZodLiteral
4498
- | $ZodEnum
4499
- | $ZodFunction
4500
- | $ZodPromise
4501
- | $ZodLazy
4502
- | $ZodOptional
4503
- | $ZodDefault
4504
- | $ZodPrefault
4505
- | $ZodTemplateLiteral
4506
- | $ZodCustom
4507
- | $ZodTransform
4508
- | $ZodNonOptional
4509
- | $ZodReadonly
4510
- | $ZodNaN
4511
- | $ZodPipe
4512
- | $ZodSuccess
4513
- | $ZodCatch
4514
- | $ZodFile;
4515
-
4516
- export type $ZodStringFormatTypes =
4517
- | $ZodGUID
4518
- | $ZodUUID
4519
- | $ZodEmail
4520
- | $ZodURL
4521
- | $ZodEmoji
4522
- | $ZodNanoID
4523
- | $ZodCUID
4524
- | $ZodCUID2
4525
- | $ZodULID
4526
- | $ZodXID
4527
- | $ZodKSUID
4528
- | $ZodISODateTime
4529
- | $ZodISODate
4530
- | $ZodISOTime
4531
- | $ZodISODuration
4532
- | $ZodIPv4
4533
- | $ZodIPv6
4534
- | $ZodMAC
4535
- | $ZodCIDRv4
4536
- | $ZodCIDRv6
4537
- | $ZodBase64
4538
- | $ZodBase64URL
4539
- | $ZodE164
4540
- | $ZodJWT
4541
- | $ZodCustomStringFormat<"hex">
4542
- | $ZodCustomStringFormat<util.HashFormat>
4543
- | $ZodCustomStringFormat<"hostname">;