zod 3.26.0-canary.20250703T013930 → 3.26.0-canary.20250703T214020

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 (278) hide show
  1. package/package.json +20 -20
  2. package/src/index.ts +4 -0
  3. package/src/v3/ZodError.ts +330 -0
  4. package/src/v3/benchmarks/datetime.ts +58 -0
  5. package/src/v3/benchmarks/discriminatedUnion.ts +80 -0
  6. package/src/v3/benchmarks/index.ts +59 -0
  7. package/src/v3/benchmarks/ipv4.ts +57 -0
  8. package/src/v3/benchmarks/object.ts +69 -0
  9. package/src/v3/benchmarks/primitives.ts +162 -0
  10. package/src/v3/benchmarks/realworld.ts +63 -0
  11. package/src/v3/benchmarks/string.ts +55 -0
  12. package/src/v3/benchmarks/union.ts +80 -0
  13. package/src/v3/errors.ts +13 -0
  14. package/src/v3/external.ts +6 -0
  15. package/src/v3/helpers/enumUtil.ts +17 -0
  16. package/src/v3/helpers/errorUtil.ts +8 -0
  17. package/src/v3/helpers/parseUtil.ts +176 -0
  18. package/src/v3/helpers/partialUtil.ts +34 -0
  19. package/src/v3/helpers/typeAliases.ts +2 -0
  20. package/src/v3/helpers/util.ts +224 -0
  21. package/src/v3/index.ts +4 -0
  22. package/src/v3/locales/en.ts +124 -0
  23. package/src/v3/standard-schema.ts +113 -0
  24. package/src/v3/tests/Mocker.ts +54 -0
  25. package/src/v3/tests/all-errors.test.ts +157 -0
  26. package/src/v3/tests/anyunknown.test.ts +28 -0
  27. package/src/v3/tests/array.test.ts +71 -0
  28. package/src/v3/tests/async-parsing.test.ts +388 -0
  29. package/src/v3/tests/async-refinements.test.ts +46 -0
  30. package/src/v3/tests/base.test.ts +29 -0
  31. package/src/v3/tests/bigint.test.ts +55 -0
  32. package/src/v3/tests/branded.test.ts +53 -0
  33. package/src/v3/tests/catch.test.ts +220 -0
  34. package/src/v3/tests/coerce.test.ts +133 -0
  35. package/src/v3/tests/complex.test.ts +56 -0
  36. package/src/v3/tests/custom.test.ts +31 -0
  37. package/src/v3/tests/date.test.ts +32 -0
  38. package/src/v3/tests/deepmasking.test.ts +186 -0
  39. package/src/v3/tests/default.test.ts +112 -0
  40. package/src/v3/tests/description.test.ts +33 -0
  41. package/src/v3/tests/discriminated-unions.test.ts +315 -0
  42. package/src/v3/tests/enum.test.ts +80 -0
  43. package/src/v3/tests/error.test.ts +551 -0
  44. package/src/v3/tests/firstparty.test.ts +87 -0
  45. package/src/v3/tests/firstpartyschematypes.test.ts +21 -0
  46. package/src/v3/tests/function.test.ts +257 -0
  47. package/src/v3/tests/generics.test.ts +48 -0
  48. package/src/v3/tests/instanceof.test.ts +37 -0
  49. package/src/v3/tests/intersection.test.ts +110 -0
  50. package/src/v3/tests/language-server.source.ts +76 -0
  51. package/src/v3/tests/language-server.test.ts +207 -0
  52. package/src/v3/tests/literal.test.ts +36 -0
  53. package/src/v3/tests/map.test.ts +110 -0
  54. package/src/v3/tests/masking.test.ts +4 -0
  55. package/src/v3/tests/mocker.test.ts +19 -0
  56. package/src/v3/tests/nan.test.ts +21 -0
  57. package/src/v3/tests/nativeEnum.test.ts +87 -0
  58. package/src/v3/tests/nullable.test.ts +42 -0
  59. package/src/v3/tests/number.test.ts +176 -0
  60. package/src/v3/tests/object-augmentation.test.ts +29 -0
  61. package/src/v3/tests/object-in-es5-env.test.ts +29 -0
  62. package/src/v3/tests/object.test.ts +434 -0
  63. package/src/v3/tests/optional.test.ts +42 -0
  64. package/src/v3/tests/parseUtil.test.ts +23 -0
  65. package/src/v3/tests/parser.test.ts +41 -0
  66. package/src/v3/tests/partials.test.ts +243 -0
  67. package/src/v3/tests/pickomit.test.ts +111 -0
  68. package/src/v3/tests/pipeline.test.ts +29 -0
  69. package/src/v3/tests/preprocess.test.ts +186 -0
  70. package/src/v3/tests/primitive.test.ts +440 -0
  71. package/src/v3/tests/promise.test.ts +90 -0
  72. package/src/v3/tests/readonly.test.ts +194 -0
  73. package/src/v3/tests/record.test.ts +171 -0
  74. package/src/v3/tests/recursive.test.ts +197 -0
  75. package/src/v3/tests/refine.test.ts +313 -0
  76. package/src/v3/tests/safeparse.test.ts +27 -0
  77. package/src/v3/tests/set.test.ts +142 -0
  78. package/src/v3/tests/standard-schema.test.ts +83 -0
  79. package/src/v3/tests/string.test.ts +916 -0
  80. package/src/v3/tests/transformer.test.ts +233 -0
  81. package/src/v3/tests/tuple.test.ts +90 -0
  82. package/src/v3/tests/unions.test.ts +57 -0
  83. package/src/v3/tests/validations.test.ts +133 -0
  84. package/src/v3/tests/void.test.ts +15 -0
  85. package/src/v3/types.ts +5136 -0
  86. package/src/v4/classic/checks.ts +30 -0
  87. package/src/v4/classic/coerce.ts +27 -0
  88. package/src/v4/classic/compat.ts +66 -0
  89. package/src/v4/classic/errors.ts +75 -0
  90. package/src/v4/classic/external.ts +50 -0
  91. package/src/v4/classic/index.ts +5 -0
  92. package/src/v4/classic/iso.ts +90 -0
  93. package/src/v4/classic/parse.ts +33 -0
  94. package/src/v4/classic/schemas.ts +2055 -0
  95. package/src/v4/classic/tests/anyunknown.test.ts +26 -0
  96. package/src/v4/classic/tests/array.test.ts +264 -0
  97. package/src/v4/classic/tests/assignability.test.ts +210 -0
  98. package/src/v4/classic/tests/async-parsing.test.ts +381 -0
  99. package/src/v4/classic/tests/async-refinements.test.ts +68 -0
  100. package/src/v4/classic/tests/base.test.ts +7 -0
  101. package/src/v4/classic/tests/bigint.test.ts +54 -0
  102. package/src/v4/classic/tests/brand.test.ts +65 -0
  103. package/src/v4/classic/tests/catch.test.ts +252 -0
  104. package/src/v4/classic/tests/coalesce.test.ts +20 -0
  105. package/src/v4/classic/tests/coerce.test.ts +160 -0
  106. package/src/v4/classic/tests/continuability.test.ts +352 -0
  107. package/src/v4/classic/tests/custom.test.ts +40 -0
  108. package/src/v4/classic/tests/date.test.ts +31 -0
  109. package/src/v4/classic/tests/datetime.test.ts +296 -0
  110. package/src/v4/classic/tests/default.test.ts +313 -0
  111. package/src/v4/classic/tests/description.test.ts +32 -0
  112. package/src/v4/classic/tests/discriminated-unions.test.ts +592 -0
  113. package/src/v4/classic/tests/enum.test.ts +285 -0
  114. package/src/v4/classic/tests/error-utils.test.ts +527 -0
  115. package/src/v4/classic/tests/error.test.ts +711 -0
  116. package/src/v4/classic/tests/file.test.ts +91 -0
  117. package/src/v4/classic/tests/firstparty.test.ts +175 -0
  118. package/src/v4/classic/tests/function.test.ts +268 -0
  119. package/src/v4/classic/tests/generics.test.ts +72 -0
  120. package/src/v4/classic/tests/index.test.ts +829 -0
  121. package/src/v4/classic/tests/instanceof.test.ts +34 -0
  122. package/src/v4/classic/tests/intersection.test.ts +171 -0
  123. package/src/v4/classic/tests/json.test.ts +108 -0
  124. package/src/v4/classic/tests/lazy.test.ts +227 -0
  125. package/src/v4/classic/tests/literal.test.ts +92 -0
  126. package/src/v4/classic/tests/map.test.ts +196 -0
  127. package/src/v4/classic/tests/nan.test.ts +21 -0
  128. package/src/v4/classic/tests/nested-refine.test.ts +168 -0
  129. package/src/v4/classic/tests/nonoptional.test.ts +86 -0
  130. package/src/v4/classic/tests/nullable.test.ts +22 -0
  131. package/src/v4/classic/tests/number.test.ts +247 -0
  132. package/src/v4/classic/tests/object.test.ts +553 -0
  133. package/src/v4/classic/tests/optional.test.ts +103 -0
  134. package/src/v4/classic/tests/partial.test.ts +147 -0
  135. package/src/v4/classic/tests/pickomit.test.ts +127 -0
  136. package/src/v4/classic/tests/pipe.test.ts +81 -0
  137. package/src/v4/classic/tests/prefault.test.ts +37 -0
  138. package/src/v4/classic/tests/preprocess.test.ts +298 -0
  139. package/src/v4/classic/tests/primitive.test.ts +175 -0
  140. package/src/v4/classic/tests/promise.test.ts +81 -0
  141. package/src/v4/classic/tests/prototypes.test.ts +23 -0
  142. package/src/v4/classic/tests/readonly.test.ts +252 -0
  143. package/src/v4/classic/tests/record.test.ts +332 -0
  144. package/src/v4/classic/tests/recursive-types.test.ts +325 -0
  145. package/src/v4/classic/tests/refine.test.ts +423 -0
  146. package/src/v4/classic/tests/registries.test.ts +195 -0
  147. package/src/v4/classic/tests/set.test.ts +179 -0
  148. package/src/v4/classic/tests/standard-schema.test.ts +57 -0
  149. package/src/v4/classic/tests/string-formats.test.ts +109 -0
  150. package/src/v4/classic/tests/string.test.ts +881 -0
  151. package/src/v4/classic/tests/stringbool.test.ts +66 -0
  152. package/src/v4/classic/tests/template-literal.test.ts +758 -0
  153. package/src/v4/classic/tests/to-json-schema.test.ts +2182 -0
  154. package/src/v4/classic/tests/transform.test.ts +250 -0
  155. package/src/v4/classic/tests/tuple.test.ts +163 -0
  156. package/src/v4/classic/tests/union.test.ts +94 -0
  157. package/src/v4/classic/tests/validations.test.ts +283 -0
  158. package/src/v4/classic/tests/void.test.ts +12 -0
  159. package/src/v4/core/api.ts +1592 -0
  160. package/src/v4/core/checks.ts +1285 -0
  161. package/src/v4/core/config.ts +15 -0
  162. package/src/v4/core/core.ts +134 -0
  163. package/src/v4/core/doc.ts +44 -0
  164. package/src/v4/core/errors.ts +420 -0
  165. package/src/v4/core/function.ts +176 -0
  166. package/src/v4/core/index.ts +15 -0
  167. package/src/v4/core/json-schema.ts +143 -0
  168. package/src/v4/core/parse.ts +94 -0
  169. package/src/v4/core/regexes.ts +135 -0
  170. package/src/v4/core/registries.ts +86 -0
  171. package/src/v4/core/schemas.ts +3781 -0
  172. package/src/v4/core/standard-schema.ts +64 -0
  173. package/src/v4/core/tests/index.test.ts +46 -0
  174. package/src/v4/core/tests/locales/be.test.ts +124 -0
  175. package/src/v4/core/tests/locales/en.test.ts +22 -0
  176. package/src/v4/core/tests/locales/ru.test.ts +128 -0
  177. package/src/v4/core/tests/locales/tr.test.ts +69 -0
  178. package/src/v4/core/to-json-schema.ts +944 -0
  179. package/src/v4/core/util.ts +775 -0
  180. package/src/v4/core/versions.ts +5 -0
  181. package/src/v4/core/zsf.ts +323 -0
  182. package/src/v4/index.ts +4 -0
  183. package/src/v4/locales/ar.ts +125 -0
  184. package/src/v4/locales/az.ts +121 -0
  185. package/src/v4/locales/be.ts +184 -0
  186. package/src/v4/locales/ca.ts +127 -0
  187. package/src/v4/locales/cs.ts +142 -0
  188. package/src/v4/locales/de.ts +124 -0
  189. package/src/v4/locales/en.ts +127 -0
  190. package/src/v4/locales/eo.ts +125 -0
  191. package/src/v4/locales/es.ts +125 -0
  192. package/src/v4/locales/fa.ts +134 -0
  193. package/src/v4/locales/fi.ts +131 -0
  194. package/src/v4/locales/fr-CA.ts +126 -0
  195. package/src/v4/locales/fr.ts +124 -0
  196. package/src/v4/locales/he.ts +125 -0
  197. package/src/v4/locales/hu.ts +126 -0
  198. package/src/v4/locales/id.ts +125 -0
  199. package/src/v4/locales/index.ts +39 -0
  200. package/src/v4/locales/it.ts +125 -0
  201. package/src/v4/locales/ja.ts +122 -0
  202. package/src/v4/locales/kh.ts +126 -0
  203. package/src/v4/locales/ko.ts +131 -0
  204. package/src/v4/locales/mk.ts +127 -0
  205. package/src/v4/locales/ms.ts +124 -0
  206. package/src/v4/locales/nl.ts +126 -0
  207. package/src/v4/locales/no.ts +124 -0
  208. package/src/v4/locales/ota.ts +125 -0
  209. package/src/v4/locales/pl.ts +126 -0
  210. package/src/v4/locales/ps.ts +133 -0
  211. package/src/v4/locales/pt.ts +123 -0
  212. package/src/v4/locales/ru.ts +184 -0
  213. package/src/v4/locales/sl.ts +126 -0
  214. package/src/v4/locales/sv.ts +127 -0
  215. package/src/v4/locales/ta.ts +125 -0
  216. package/src/v4/locales/th.ts +126 -0
  217. package/src/v4/locales/tr.ts +121 -0
  218. package/src/v4/locales/ua.ts +126 -0
  219. package/src/v4/locales/ur.ts +126 -0
  220. package/src/v4/locales/vi.ts +125 -0
  221. package/src/v4/locales/zh-CN.ts +123 -0
  222. package/src/v4/locales/zh-TW.ts +125 -0
  223. package/src/v4/mini/checks.ts +32 -0
  224. package/src/v4/mini/coerce.ts +22 -0
  225. package/src/v4/mini/external.ts +40 -0
  226. package/src/v4/mini/index.ts +3 -0
  227. package/src/v4/mini/iso.ts +62 -0
  228. package/src/v4/mini/parse.ts +1 -0
  229. package/src/v4/mini/schemas.ts +1579 -0
  230. package/src/v4/mini/tests/assignability.test.ts +129 -0
  231. package/src/v4/mini/tests/brand.test.ts +51 -0
  232. package/src/v4/mini/tests/checks.test.ts +144 -0
  233. package/src/v4/mini/tests/computed.test.ts +36 -0
  234. package/src/v4/mini/tests/error.test.ts +22 -0
  235. package/src/v4/mini/tests/functions.test.ts +43 -0
  236. package/src/v4/mini/tests/index.test.ts +871 -0
  237. package/src/v4/mini/tests/number.test.ts +95 -0
  238. package/src/v4/mini/tests/object.test.ts +185 -0
  239. package/src/v4/mini/tests/prototypes.test.ts +43 -0
  240. package/src/v4/mini/tests/recursive-types.test.ts +275 -0
  241. package/src/v4/mini/tests/string.test.ts +293 -0
  242. package/src/v4-mini/index.ts +1 -0
  243. package/v4/classic/compat.cjs +1 -7
  244. package/v4/classic/compat.d.cts +0 -2
  245. package/v4/classic/compat.d.ts +0 -2
  246. package/v4/classic/compat.js +0 -6
  247. package/v4/classic/external.cjs +2 -1
  248. package/v4/classic/external.d.cts +1 -1
  249. package/v4/classic/external.d.ts +1 -1
  250. package/v4/classic/external.js +1 -1
  251. package/v4/classic/schemas.d.cts +4 -4
  252. package/v4/classic/schemas.d.ts +4 -4
  253. package/v4/core/api.cjs +11 -10
  254. package/v4/core/api.js +11 -10
  255. package/v4/core/checks.cjs +6 -4
  256. package/v4/core/checks.js +6 -4
  257. package/v4/core/core.cjs +5 -1
  258. package/v4/core/core.d.cts +2 -0
  259. package/v4/core/core.d.ts +2 -0
  260. package/v4/core/core.js +4 -0
  261. package/v4/core/schemas.cjs +12 -13
  262. package/v4/core/schemas.js +12 -13
  263. package/v4/core/util.cjs +3 -0
  264. package/v4/core/util.d.cts +1 -1
  265. package/v4/core/util.d.ts +1 -1
  266. package/v4/core/util.js +3 -0
  267. package/v4/locales/eo.cjs +144 -0
  268. package/v4/locales/eo.d.cts +5 -0
  269. package/v4/locales/eo.d.ts +5 -0
  270. package/v4/locales/eo.js +116 -0
  271. package/v4/locales/index.cjs +3 -1
  272. package/v4/locales/index.d.cts +1 -0
  273. package/v4/locales/index.d.ts +1 -0
  274. package/v4/locales/index.js +1 -0
  275. package/v4/mini/external.cjs +2 -1
  276. package/v4/mini/external.d.cts +1 -1
  277. package/v4/mini/external.d.ts +1 -1
  278. package/v4/mini/external.js +1 -1
@@ -0,0 +1,2055 @@
1
+ import * as core from "../core/index.js";
2
+ import { util } from "../core/index.js";
3
+
4
+ import * as checks from "./checks.js";
5
+ import * as iso from "./iso.js";
6
+ import * as parse from "./parse.js";
7
+
8
+ ///////////////////////////////////////////
9
+ ///////////////////////////////////////////
10
+ //////////// ////////////
11
+ //////////// ZodType ////////////
12
+ //////////// ////////////
13
+ ///////////////////////////////////////////
14
+ ///////////////////////////////////////////
15
+
16
+ export interface RefinementCtx<T = unknown> extends core.ParsePayload<T> {
17
+ addIssue(arg: string | core.$ZodRawIssue | Partial<core.$ZodIssueCustom>): void;
18
+ }
19
+
20
+ export interface ZodType<
21
+ out Output = unknown,
22
+ out Input = unknown,
23
+ out Internals extends core.$ZodTypeInternals<Output, Input> = core.$ZodTypeInternals<Output, Input>,
24
+ > extends core.$ZodType<Output, Input, Internals> {
25
+ def: Internals["def"];
26
+ type: Internals["def"]["type"];
27
+
28
+ /** @deprecated Use `.def` instead. */
29
+ _def: Internals["def"];
30
+ /** @deprecated Use `z.output<typeof schema>` instead. */
31
+ _output: Internals["output"];
32
+ /** @deprecated Use `z.input<typeof schema>` instead. */
33
+ _input: Internals["input"];
34
+
35
+ // base methods
36
+ check(...checks: (core.CheckFn<core.output<this>> | core.$ZodCheck<core.output<this>>)[]): this;
37
+ clone(def?: Internals["def"], params?: { parent: boolean }): this;
38
+ register<R extends core.$ZodRegistry>(
39
+ registry: R,
40
+ ...meta: this extends R["_schema"]
41
+ ? undefined extends R["_meta"]
42
+ ? [core.$replace<R["_meta"], this>?]
43
+ : [core.$replace<R["_meta"], this>]
44
+ : ["Incompatible schema"]
45
+ ): this;
46
+
47
+ brand<T extends PropertyKey = PropertyKey>(value?: T): PropertyKey extends T ? this : core.$ZodBranded<this, T>;
48
+
49
+ // parsing
50
+ parse(data: unknown, params?: core.ParseContext<core.$ZodIssue>): core.output<this>;
51
+ safeParse(data: unknown, params?: core.ParseContext<core.$ZodIssue>): parse.ZodSafeParseResult<core.output<this>>;
52
+ parseAsync(data: unknown, params?: core.ParseContext<core.$ZodIssue>): Promise<core.output<this>>;
53
+ safeParseAsync(
54
+ data: unknown,
55
+ params?: core.ParseContext<core.$ZodIssue>
56
+ ): Promise<parse.ZodSafeParseResult<core.output<this>>>;
57
+ spa: (
58
+ data: unknown,
59
+ params?: core.ParseContext<core.$ZodIssue>
60
+ ) => Promise<parse.ZodSafeParseResult<core.output<this>>>;
61
+
62
+ // refinements
63
+ refine(check: (arg: core.output<this>) => unknown | Promise<unknown>, params?: string | core.$ZodCustomParams): this;
64
+ /** @deprecated Use `.check()` instead. */
65
+ superRefine(
66
+ refinement: (arg: core.output<this>, ctx: RefinementCtx<core.output<this>>) => void | Promise<void>
67
+ ): this;
68
+ overwrite(fn: (x: core.output<this>) => core.output<this>): this;
69
+
70
+ // wrappers
71
+ optional(): ZodOptional<this>;
72
+ nonoptional(params?: string | core.$ZodNonOptionalParams): ZodNonOptional<this>;
73
+ nullable(): ZodNullable<this>;
74
+ nullish(): ZodOptional<ZodNullable<this>>;
75
+ default(def: core.output<this>): ZodDefault<this>;
76
+ default(def: () => util.NoUndefined<core.output<this>>): ZodDefault<this>;
77
+ prefault(def: () => core.input<this>): ZodPrefault<this>;
78
+ prefault(def: core.input<this>): ZodPrefault<this>;
79
+ array(): ZodArray<this>;
80
+ or<T extends core.SomeType>(option: T): ZodUnion<[this, T]>;
81
+ and<T extends core.SomeType>(incoming: T): ZodIntersection<this, T>;
82
+ transform<NewOut>(
83
+ transform: (arg: core.output<this>, ctx: RefinementCtx<core.output<this>>) => NewOut | Promise<NewOut>
84
+ ): ZodPipe<this, ZodTransform<Awaited<NewOut>, core.output<this>>>;
85
+ catch(def: core.output<this>): ZodCatch<this>;
86
+ catch(def: (ctx: core.$ZodCatchCtx) => core.output<this>): ZodCatch<this>;
87
+ pipe<T extends core.$ZodType<any, core.output<this>>>(
88
+ target: T | core.$ZodType<any, core.output<this>>
89
+ ): ZodPipe<this, T>;
90
+ readonly(): ZodReadonly<this>;
91
+
92
+ /** Returns a new instance that has been registered in `z.globalRegistry` with the specified description */
93
+ describe(description: string): this;
94
+ description?: string;
95
+ /** Returns the metadata associated with this instance in `z.globalRegistry` */
96
+ meta(): core.$replace<core.GlobalMeta, this> | undefined;
97
+ /** Returns a new instance that has been registered in `z.globalRegistry` with the specified metadata */
98
+ meta(data: core.$replace<core.GlobalMeta, this>): this;
99
+
100
+ // helpers
101
+ /** @deprecated Try safe-parsing `undefined` (this is what `isOptional` does internally):
102
+ *
103
+ * ```ts
104
+ * const schema = z.string().optional();
105
+ * const isOptional = schema.safeParse(undefined).success; // true
106
+ * ```
107
+ */
108
+ isOptional(): boolean;
109
+ /**
110
+ * @deprecated Try safe-parsing `null` (this is what `isNullable` does internally):
111
+ *
112
+ * ```ts
113
+ * const schema = z.string().nullable();
114
+ * const isNullable = schema.safeParse(null).success; // true
115
+ * ```
116
+ */
117
+ isNullable(): boolean;
118
+ }
119
+
120
+ export interface _ZodType<out Internals extends core.$ZodTypeInternals = core.$ZodTypeInternals>
121
+ extends ZodType<any, any, Internals> {}
122
+
123
+ export const ZodType: core.$constructor<ZodType> = /*@__PURE__*/ core.$constructor("ZodType", (inst, def) => {
124
+ core.$ZodType.init(inst, def);
125
+ inst.def = def;
126
+ Object.defineProperty(inst, "_def", { value: def });
127
+
128
+ // base methods
129
+ inst.check = (...checks) => {
130
+ return inst.clone(
131
+ {
132
+ ...def,
133
+ checks: [
134
+ ...(def.checks ?? []),
135
+ ...checks.map((ch) =>
136
+ typeof ch === "function" ? { _zod: { check: ch, def: { check: "custom" }, onattach: [] } } : ch
137
+ ),
138
+ ],
139
+ }
140
+ // { parent: true }
141
+ );
142
+ };
143
+ inst.clone = (def, params) => core.clone(inst, def, params);
144
+ inst.brand = () => inst as any;
145
+ inst.register = ((reg: any, meta: any) => {
146
+ reg.add(inst, meta);
147
+ return inst;
148
+ }) as any;
149
+
150
+ // parsing
151
+ inst.parse = (data, params) => parse.parse(inst, data, params, { callee: inst.parse });
152
+ inst.safeParse = (data, params) => parse.safeParse(inst, data, params);
153
+ inst.parseAsync = async (data, params) => parse.parseAsync(inst, data, params, { callee: inst.parseAsync });
154
+ inst.safeParseAsync = async (data, params) => parse.safeParseAsync(inst, data, params);
155
+ inst.spa = inst.safeParseAsync;
156
+
157
+ // refinements
158
+ inst.refine = (check, params) => inst.check(refine(check, params));
159
+ inst.superRefine = (refinement) => inst.check(superRefine(refinement));
160
+ inst.overwrite = (fn) => inst.check(checks.overwrite(fn));
161
+
162
+ // wrappers
163
+ inst.optional = () => optional(inst);
164
+ inst.nullable = () => nullable(inst);
165
+ inst.nullish = () => optional(nullable(inst));
166
+ inst.nonoptional = (params) => nonoptional(inst, params);
167
+ inst.array = () => array(inst);
168
+ inst.or = (arg) => union([inst, arg]);
169
+ inst.and = (arg) => intersection(inst, arg);
170
+ inst.transform = (tx) => pipe(inst, transform(tx as any)) as never;
171
+ inst.default = (def) => _default(inst, def);
172
+ inst.prefault = (def) => prefault(inst, def);
173
+ // inst.coalesce = (def, params) => coalesce(inst, def, params);
174
+ inst.catch = (params) => _catch(inst, params);
175
+ inst.pipe = (target) => pipe(inst, target);
176
+ inst.readonly = () => readonly(inst);
177
+
178
+ // meta
179
+ inst.describe = (description) => {
180
+ const cl = inst.clone();
181
+ core.globalRegistry.add(cl, { description });
182
+ return cl;
183
+ };
184
+ Object.defineProperty(inst, "description", {
185
+ get() {
186
+ return core.globalRegistry.get(inst)?.description;
187
+ },
188
+ configurable: true,
189
+ });
190
+ inst.meta = (...args: any) => {
191
+ if (args.length === 0) {
192
+ return core.globalRegistry.get(inst);
193
+ }
194
+ const cl = inst.clone();
195
+ core.globalRegistry.add(cl, args[0]);
196
+ return cl as any;
197
+ };
198
+
199
+ // helpers
200
+ inst.isOptional = () => inst.safeParse(undefined).success;
201
+ inst.isNullable = () => inst.safeParse(null).success;
202
+ return inst;
203
+ });
204
+
205
+ // ZodString
206
+ export interface _ZodString<T extends core.$ZodStringInternals<unknown> = core.$ZodStringInternals<unknown>>
207
+ extends _ZodType<T> {
208
+ format: string | null;
209
+ minLength: number | null;
210
+ maxLength: number | null;
211
+
212
+ // miscellaneous checks
213
+ regex(regex: RegExp, params?: string | core.$ZodCheckRegexParams): this;
214
+ includes(value: string, params?: core.$ZodCheckIncludesParams): this;
215
+ startsWith(value: string, params?: string | core.$ZodCheckStartsWithParams): this;
216
+ endsWith(value: string, params?: string | core.$ZodCheckEndsWithParams): this;
217
+ min(minLength: number, params?: string | core.$ZodCheckMinLengthParams): this;
218
+ max(maxLength: number, params?: string | core.$ZodCheckMaxLengthParams): this;
219
+ length(len: number, params?: string | core.$ZodCheckLengthEqualsParams): this;
220
+ nonempty(params?: string | core.$ZodCheckMinLengthParams): this;
221
+ lowercase(params?: string | core.$ZodCheckLowerCaseParams): this;
222
+ uppercase(params?: string | core.$ZodCheckUpperCaseParams): this;
223
+
224
+ // transforms
225
+ trim(): this;
226
+ normalize(form?: "NFC" | "NFD" | "NFKC" | "NFKD" | (string & {})): this;
227
+ toLowerCase(): this;
228
+ toUpperCase(): this;
229
+ }
230
+
231
+ /** @internal */
232
+ export const _ZodString: core.$constructor<_ZodString> = /*@__PURE__*/ core.$constructor("_ZodString", (inst, def) => {
233
+ core.$ZodString.init(inst, def);
234
+ ZodType.init(inst, def);
235
+
236
+ const bag = inst._zod.bag;
237
+ inst.format = bag.format ?? null;
238
+ inst.minLength = bag.minimum ?? null;
239
+ inst.maxLength = bag.maximum ?? null;
240
+
241
+ // validations
242
+ inst.regex = (...args) => inst.check(checks.regex(...args));
243
+ inst.includes = (...args) => inst.check(checks.includes(...args));
244
+ inst.startsWith = (...args) => inst.check(checks.startsWith(...args));
245
+ inst.endsWith = (...args) => inst.check(checks.endsWith(...args));
246
+ inst.min = (...args) => inst.check(checks.minLength(...args));
247
+ inst.max = (...args) => inst.check(checks.maxLength(...args));
248
+ inst.length = (...args) => inst.check(checks.length(...args));
249
+ inst.nonempty = (...args) => inst.check(checks.minLength(1, ...args));
250
+ inst.lowercase = (params) => inst.check(checks.lowercase(params));
251
+ inst.uppercase = (params) => inst.check(checks.uppercase(params));
252
+
253
+ // transforms
254
+ inst.trim = () => inst.check(checks.trim());
255
+ inst.normalize = (...args) => inst.check(checks.normalize(...args));
256
+ inst.toLowerCase = () => inst.check(checks.toLowerCase());
257
+ inst.toUpperCase = () => inst.check(checks.toUpperCase());
258
+ });
259
+
260
+ export interface ZodString extends _ZodString<core.$ZodStringInternals<string>> {
261
+ // string format checks
262
+
263
+ /** @deprecated Use `z.email()` instead. */
264
+ email(params?: string | core.$ZodCheckEmailParams): this;
265
+ /** @deprecated Use `z.url()` instead. */
266
+ url(params?: string | core.$ZodCheckURLParams): this;
267
+ /** @deprecated Use `z.jwt()` instead. */
268
+ jwt(params?: string | core.$ZodCheckJWTParams): this;
269
+ /** @deprecated Use `z.emoji()` instead. */
270
+ emoji(params?: string | core.$ZodCheckEmojiParams): this;
271
+ /** @deprecated Use `z.guid()` instead. */
272
+ guid(params?: string | core.$ZodCheckGUIDParams): this;
273
+ /** @deprecated Use `z.uuid()` instead. */
274
+ uuid(params?: string | core.$ZodCheckUUIDParams): this;
275
+ /** @deprecated Use `z.uuid()` instead. */
276
+ uuidv4(params?: string | core.$ZodCheckUUIDParams): this;
277
+ /** @deprecated Use `z.uuid()` instead. */
278
+ uuidv6(params?: string | core.$ZodCheckUUIDParams): this;
279
+ /** @deprecated Use `z.uuid()` instead. */
280
+ uuidv7(params?: string | core.$ZodCheckUUIDParams): this;
281
+ /** @deprecated Use `z.nanoid()` instead. */
282
+ nanoid(params?: string | core.$ZodCheckNanoIDParams): this;
283
+ /** @deprecated Use `z.guid()` instead. */
284
+ guid(params?: string | core.$ZodCheckGUIDParams): this;
285
+ /** @deprecated Use `z.cuid()` instead. */
286
+ cuid(params?: string | core.$ZodCheckCUIDParams): this;
287
+ /** @deprecated Use `z.cuid2()` instead. */
288
+ cuid2(params?: string | core.$ZodCheckCUID2Params): this;
289
+ /** @deprecated Use `z.ulid()` instead. */
290
+ ulid(params?: string | core.$ZodCheckULIDParams): this;
291
+ /** @deprecated Use `z.base64()` instead. */
292
+ base64(params?: string | core.$ZodCheckBase64Params): this;
293
+ /** @deprecated Use `z.base64url()` instead. */
294
+ base64url(params?: string | core.$ZodCheckBase64URLParams): this;
295
+ // /** @deprecated Use `z.jsonString()` instead. */
296
+ // jsonString(params?: string | core.$ZodCheckJSONStringParams): this;
297
+ /** @deprecated Use `z.xid()` instead. */
298
+ xid(params?: string | core.$ZodCheckXIDParams): this;
299
+ /** @deprecated Use `z.ksuid()` instead. */
300
+ ksuid(params?: string | core.$ZodCheckKSUIDParams): this;
301
+ // /** @deprecated Use `z.ipv4()` or `z.ipv6()` instead. */
302
+ // ip(params?: string | (core.$ZodCheckIPv4Params & { version?: "v4" | "v6" })): ZodUnion<[this, this]>;
303
+ /** @deprecated Use `z.ipv4()` instead. */
304
+ ipv4(params?: string | core.$ZodCheckIPv4Params): this;
305
+ /** @deprecated Use `z.ipv6()` instead. */
306
+ ipv6(params?: string | core.$ZodCheckIPv6Params): this;
307
+ /** @deprecated Use `z.cidrv4()` instead. */
308
+ cidrv4(params?: string | core.$ZodCheckCIDRv4Params): this;
309
+ /** @deprecated Use `z.cidrv6()` instead. */
310
+ cidrv6(params?: string | core.$ZodCheckCIDRv6Params): this;
311
+ /** @deprecated Use `z.e164()` instead. */
312
+ e164(params?: string | core.$ZodCheckE164Params): this;
313
+
314
+ // ISO 8601 checks
315
+ /** @deprecated Use `z.iso.datetime()` instead. */
316
+ datetime(params?: string | core.$ZodCheckISODateTimeParams): this;
317
+ /** @deprecated Use `z.iso.date()` instead. */
318
+ date(params?: string | core.$ZodCheckISODateParams): this;
319
+ /** @deprecated Use `z.iso.time()` instead. */
320
+ time(
321
+ params?:
322
+ | string
323
+ // | {
324
+ // message?: string | undefined;
325
+ // precision?: number | null;
326
+ // }
327
+ | core.$ZodCheckISOTimeParams
328
+ ): this;
329
+ /** @deprecated Use `z.iso.duration()` instead. */
330
+ duration(params?: string | core.$ZodCheckISODurationParams): this;
331
+ }
332
+
333
+ export const ZodString: core.$constructor<ZodString> = /*@__PURE__*/ core.$constructor("ZodString", (inst, def) => {
334
+ core.$ZodString.init(inst, def);
335
+ _ZodString.init(inst, def);
336
+
337
+ inst.email = (params) => inst.check(core._email(ZodEmail, params));
338
+ inst.url = (params) => inst.check(core._url(ZodURL, params));
339
+ inst.jwt = (params) => inst.check(core._jwt(ZodJWT, params));
340
+ inst.emoji = (params) => inst.check(core._emoji(ZodEmoji, params));
341
+ inst.guid = (params) => inst.check(core._guid(ZodGUID, params));
342
+ inst.uuid = (params) => inst.check(core._uuid(ZodUUID, params));
343
+ inst.uuidv4 = (params) => inst.check(core._uuidv4(ZodUUID, params));
344
+ inst.uuidv6 = (params) => inst.check(core._uuidv6(ZodUUID, params));
345
+ inst.uuidv7 = (params) => inst.check(core._uuidv7(ZodUUID, params));
346
+ inst.nanoid = (params) => inst.check(core._nanoid(ZodNanoID, params));
347
+ inst.guid = (params) => inst.check(core._guid(ZodGUID, params));
348
+ inst.cuid = (params) => inst.check(core._cuid(ZodCUID, params));
349
+ inst.cuid2 = (params) => inst.check(core._cuid2(ZodCUID2, params));
350
+ inst.ulid = (params) => inst.check(core._ulid(ZodULID, params));
351
+ inst.base64 = (params) => inst.check(core._base64(ZodBase64, params));
352
+ inst.base64url = (params) => inst.check(core._base64url(ZodBase64URL, params));
353
+ inst.xid = (params) => inst.check(core._xid(ZodXID, params));
354
+ inst.ksuid = (params) => inst.check(core._ksuid(ZodKSUID, params));
355
+ inst.ipv4 = (params) => inst.check(core._ipv4(ZodIPv4, params));
356
+ inst.ipv6 = (params) => inst.check(core._ipv6(ZodIPv6, params));
357
+ inst.cidrv4 = (params) => inst.check(core._cidrv4(ZodCIDRv4, params));
358
+ inst.cidrv6 = (params) => inst.check(core._cidrv6(ZodCIDRv6, params));
359
+ inst.e164 = (params) => inst.check(core._e164(ZodE164, params));
360
+
361
+ // iso
362
+ inst.datetime = (params) => inst.check(iso.datetime(params as any));
363
+ inst.date = (params) => inst.check(iso.date(params as any));
364
+ inst.time = (params) => inst.check(iso.time(params as any));
365
+ inst.duration = (params) => inst.check(iso.duration(params as any));
366
+ });
367
+
368
+ export function string(params?: string | core.$ZodStringParams): ZodString {
369
+ return core._string(ZodString, params) as any;
370
+ }
371
+
372
+ // ZodStringFormat
373
+ export interface ZodStringFormat<Format extends string = string>
374
+ extends _ZodString<core.$ZodStringFormatInternals<Format>> {}
375
+ export const ZodStringFormat: core.$constructor<ZodStringFormat> = /*@__PURE__*/ core.$constructor(
376
+ "ZodStringFormat",
377
+ (inst, def) => {
378
+ core.$ZodStringFormat.init(inst, def);
379
+ _ZodString.init(inst, def);
380
+ }
381
+ );
382
+
383
+ // ZodEmail
384
+ export interface ZodEmail extends ZodStringFormat<"email"> {
385
+ _zod: core.$ZodEmailInternals;
386
+ }
387
+ export const ZodEmail: core.$constructor<ZodEmail> = /*@__PURE__*/ core.$constructor("ZodEmail", (inst, def) => {
388
+ // ZodStringFormat.init(inst, def);
389
+ core.$ZodEmail.init(inst, def);
390
+ ZodStringFormat.init(inst, def);
391
+ });
392
+
393
+ export function email(params?: string | core.$ZodEmailParams): ZodEmail {
394
+ return core._email(ZodEmail, params);
395
+ }
396
+
397
+ // ZodGUID
398
+ export interface ZodGUID extends ZodStringFormat<"guid"> {
399
+ _zod: core.$ZodGUIDInternals;
400
+ }
401
+ export const ZodGUID: core.$constructor<ZodGUID> = /*@__PURE__*/ core.$constructor("ZodGUID", (inst, def) => {
402
+ // ZodStringFormat.init(inst, def);
403
+ core.$ZodGUID.init(inst, def);
404
+ ZodStringFormat.init(inst, def);
405
+ });
406
+
407
+ export function guid(params?: string | core.$ZodGUIDParams): ZodGUID {
408
+ return core._guid(ZodGUID, params);
409
+ }
410
+
411
+ // ZodUUID
412
+ export interface ZodUUID extends ZodStringFormat<"uuid"> {
413
+ _zod: core.$ZodUUIDInternals;
414
+ }
415
+ export const ZodUUID: core.$constructor<ZodUUID> = /*@__PURE__*/ core.$constructor("ZodUUID", (inst, def) => {
416
+ // ZodStringFormat.init(inst, def);
417
+ core.$ZodUUID.init(inst, def);
418
+ ZodStringFormat.init(inst, def);
419
+ });
420
+
421
+ export function uuid(params?: string | core.$ZodUUIDParams): ZodUUID {
422
+ return core._uuid(ZodUUID, params);
423
+ }
424
+
425
+ export function uuidv4(params?: string | core.$ZodUUIDv4Params): ZodUUID {
426
+ return core._uuidv4(ZodUUID, params);
427
+ }
428
+
429
+ // ZodUUIDv6
430
+
431
+ export function uuidv6(params?: string | core.$ZodUUIDv6Params): ZodUUID {
432
+ return core._uuidv6(ZodUUID, params);
433
+ }
434
+
435
+ // ZodUUIDv7
436
+
437
+ export function uuidv7(params?: string | core.$ZodUUIDv7Params): ZodUUID {
438
+ return core._uuidv7(ZodUUID, params);
439
+ }
440
+
441
+ // ZodURL
442
+ export interface ZodURL extends ZodStringFormat<"url"> {
443
+ _zod: core.$ZodURLInternals;
444
+ }
445
+ export const ZodURL: core.$constructor<ZodURL> = /*@__PURE__*/ core.$constructor("ZodURL", (inst, def) => {
446
+ // ZodStringFormat.init(inst, def);
447
+ core.$ZodURL.init(inst, def);
448
+ ZodStringFormat.init(inst, def);
449
+ });
450
+
451
+ export function url(params?: string | core.$ZodURLParams): ZodURL {
452
+ return core._url(ZodURL, params);
453
+ }
454
+
455
+ // ZodEmoji
456
+ export interface ZodEmoji extends ZodStringFormat<"emoji"> {
457
+ _zod: core.$ZodEmojiInternals;
458
+ }
459
+ export const ZodEmoji: core.$constructor<ZodEmoji> = /*@__PURE__*/ core.$constructor("ZodEmoji", (inst, def) => {
460
+ // ZodStringFormat.init(inst, def);
461
+ core.$ZodEmoji.init(inst, def);
462
+ ZodStringFormat.init(inst, def);
463
+ });
464
+
465
+ export function emoji(params?: string | core.$ZodEmojiParams): ZodEmoji {
466
+ return core._emoji(ZodEmoji, params);
467
+ }
468
+
469
+ // ZodNanoID
470
+ export interface ZodNanoID extends ZodStringFormat<"nanoid"> {
471
+ _zod: core.$ZodNanoIDInternals;
472
+ }
473
+ export const ZodNanoID: core.$constructor<ZodNanoID> = /*@__PURE__*/ core.$constructor("ZodNanoID", (inst, def) => {
474
+ // ZodStringFormat.init(inst, def);
475
+ core.$ZodNanoID.init(inst, def);
476
+ ZodStringFormat.init(inst, def);
477
+ });
478
+
479
+ export function nanoid(params?: string | core.$ZodNanoIDParams): ZodNanoID {
480
+ return core._nanoid(ZodNanoID, params);
481
+ }
482
+
483
+ // ZodCUID
484
+ export interface ZodCUID extends ZodStringFormat<"cuid"> {
485
+ _zod: core.$ZodCUIDInternals;
486
+ }
487
+ export const ZodCUID: core.$constructor<ZodCUID> = /*@__PURE__*/ core.$constructor("ZodCUID", (inst, def) => {
488
+ // ZodStringFormat.init(inst, def);
489
+ core.$ZodCUID.init(inst, def);
490
+ ZodStringFormat.init(inst, def);
491
+ });
492
+
493
+ export function cuid(params?: string | core.$ZodCUIDParams): ZodCUID {
494
+ return core._cuid(ZodCUID, params);
495
+ }
496
+
497
+ // ZodCUID2
498
+ export interface ZodCUID2 extends ZodStringFormat<"cuid2"> {
499
+ _zod: core.$ZodCUID2Internals;
500
+ }
501
+ export const ZodCUID2: core.$constructor<ZodCUID2> = /*@__PURE__*/ core.$constructor("ZodCUID2", (inst, def) => {
502
+ // ZodStringFormat.init(inst, def);
503
+ core.$ZodCUID2.init(inst, def);
504
+ ZodStringFormat.init(inst, def);
505
+ });
506
+
507
+ export function cuid2(params?: string | core.$ZodCUID2Params): ZodCUID2 {
508
+ return core._cuid2(ZodCUID2, params);
509
+ }
510
+
511
+ // ZodULID
512
+ export interface ZodULID extends ZodStringFormat<"ulid"> {
513
+ _zod: core.$ZodULIDInternals;
514
+ }
515
+ export const ZodULID: core.$constructor<ZodULID> = /*@__PURE__*/ core.$constructor("ZodULID", (inst, def) => {
516
+ // ZodStringFormat.init(inst, def);
517
+ core.$ZodULID.init(inst, def);
518
+ ZodStringFormat.init(inst, def);
519
+ });
520
+
521
+ export function ulid(params?: string | core.$ZodULIDParams): ZodULID {
522
+ return core._ulid(ZodULID, params);
523
+ }
524
+
525
+ // ZodXID
526
+ export interface ZodXID extends ZodStringFormat<"xid"> {
527
+ _zod: core.$ZodXIDInternals;
528
+ }
529
+ export const ZodXID: core.$constructor<ZodXID> = /*@__PURE__*/ core.$constructor("ZodXID", (inst, def) => {
530
+ // ZodStringFormat.init(inst, def);
531
+ core.$ZodXID.init(inst, def);
532
+ ZodStringFormat.init(inst, def);
533
+ });
534
+
535
+ export function xid(params?: string | core.$ZodXIDParams): ZodXID {
536
+ return core._xid(ZodXID, params);
537
+ }
538
+
539
+ // ZodKSUID
540
+ export interface ZodKSUID extends ZodStringFormat<"ksuid"> {
541
+ _zod: core.$ZodKSUIDInternals;
542
+ }
543
+ export const ZodKSUID: core.$constructor<ZodKSUID> = /*@__PURE__*/ core.$constructor("ZodKSUID", (inst, def) => {
544
+ // ZodStringFormat.init(inst, def);
545
+ core.$ZodKSUID.init(inst, def);
546
+ ZodStringFormat.init(inst, def);
547
+ });
548
+
549
+ export function ksuid(params?: string | core.$ZodKSUIDParams): ZodKSUID {
550
+ return core._ksuid(ZodKSUID, params);
551
+ }
552
+
553
+ // ZodIP
554
+ // export interface ZodIP extends ZodStringFormat<"ip"> {
555
+ // _zod: core.$ZodIPInternals;
556
+ // }
557
+ // export const ZodIP: core.$constructor<ZodIP> = /*@__PURE__*/ core.$constructor("ZodIP", (inst, def) => {
558
+ // // ZodStringFormat.init(inst, def);
559
+ // core.$ZodIP.init(inst, def);
560
+ // ZodStringFormat.init(inst, def);
561
+ // });
562
+
563
+ // export function ip(params?: string | core.$ZodIPParams): ZodIP {
564
+ // return core._ip(ZodIP, params);
565
+ // }
566
+
567
+ // ZodIPv4
568
+ export interface ZodIPv4 extends ZodStringFormat<"ipv4"> {
569
+ _zod: core.$ZodIPv4Internals;
570
+ }
571
+ export const ZodIPv4: core.$constructor<ZodIPv4> = /*@__PURE__*/ core.$constructor("ZodIPv4", (inst, def) => {
572
+ // ZodStringFormat.init(inst, def);
573
+ core.$ZodIPv4.init(inst, def);
574
+ ZodStringFormat.init(inst, def);
575
+ });
576
+
577
+ export function ipv4(params?: string | core.$ZodIPv4Params): ZodIPv4 {
578
+ return core._ipv4(ZodIPv4, params);
579
+ }
580
+
581
+ // ZodIPv6
582
+ export interface ZodIPv6 extends ZodStringFormat<"ipv6"> {
583
+ _zod: core.$ZodIPv6Internals;
584
+ }
585
+ export const ZodIPv6: core.$constructor<ZodIPv6> = /*@__PURE__*/ core.$constructor("ZodIPv6", (inst, def) => {
586
+ // ZodStringFormat.init(inst, def);
587
+ core.$ZodIPv6.init(inst, def);
588
+ ZodStringFormat.init(inst, def);
589
+ });
590
+ export function ipv6(params?: string | core.$ZodIPv6Params): ZodIPv6 {
591
+ return core._ipv6(ZodIPv6, params);
592
+ }
593
+
594
+ // ZodCIDRv4
595
+ export interface ZodCIDRv4 extends ZodStringFormat<"cidrv4"> {
596
+ _zod: core.$ZodCIDRv4Internals;
597
+ }
598
+ export const ZodCIDRv4: core.$constructor<ZodCIDRv4> = /*@__PURE__*/ core.$constructor("ZodCIDRv4", (inst, def) => {
599
+ core.$ZodCIDRv4.init(inst, def);
600
+ ZodStringFormat.init(inst, def);
601
+ });
602
+
603
+ export function cidrv4(params?: string | core.$ZodCIDRv4Params): ZodCIDRv4 {
604
+ return core._cidrv4(ZodCIDRv4, params);
605
+ }
606
+
607
+ // ZodCIDRv6
608
+ export interface ZodCIDRv6 extends ZodStringFormat<"cidrv6"> {
609
+ _zod: core.$ZodCIDRv6Internals;
610
+ }
611
+ export const ZodCIDRv6: core.$constructor<ZodCIDRv6> = /*@__PURE__*/ core.$constructor("ZodCIDRv6", (inst, def) => {
612
+ core.$ZodCIDRv6.init(inst, def);
613
+ ZodStringFormat.init(inst, def);
614
+ });
615
+
616
+ export function cidrv6(params?: string | core.$ZodCIDRv6Params): ZodCIDRv6 {
617
+ return core._cidrv6(ZodCIDRv6, params);
618
+ }
619
+
620
+ // ZodBase64
621
+ export interface ZodBase64 extends ZodStringFormat<"base64"> {
622
+ _zod: core.$ZodBase64Internals;
623
+ }
624
+ export const ZodBase64: core.$constructor<ZodBase64> = /*@__PURE__*/ core.$constructor("ZodBase64", (inst, def) => {
625
+ // ZodStringFormat.init(inst, def);
626
+ core.$ZodBase64.init(inst, def);
627
+ ZodStringFormat.init(inst, def);
628
+ });
629
+ export function base64(params?: string | core.$ZodBase64Params): ZodBase64 {
630
+ return core._base64(ZodBase64, params);
631
+ }
632
+
633
+ // ZodBase64URL
634
+ export interface ZodBase64URL extends ZodStringFormat<"base64url"> {
635
+ _zod: core.$ZodBase64URLInternals;
636
+ }
637
+ export const ZodBase64URL: core.$constructor<ZodBase64URL> = /*@__PURE__*/ core.$constructor(
638
+ "ZodBase64URL",
639
+ (inst, def) => {
640
+ // ZodStringFormat.init(inst, def);
641
+ core.$ZodBase64URL.init(inst, def);
642
+ ZodStringFormat.init(inst, def);
643
+ }
644
+ );
645
+ export function base64url(params?: string | core.$ZodBase64URLParams): ZodBase64URL {
646
+ return core._base64url(ZodBase64URL, params);
647
+ }
648
+
649
+ // ZodE164
650
+ export interface ZodE164 extends ZodStringFormat<"e164"> {
651
+ _zod: core.$ZodE164Internals;
652
+ }
653
+ export const ZodE164: core.$constructor<ZodE164> = /*@__PURE__*/ core.$constructor("ZodE164", (inst, def) => {
654
+ // ZodStringFormat.init(inst, def);
655
+ core.$ZodE164.init(inst, def);
656
+ ZodStringFormat.init(inst, def);
657
+ });
658
+
659
+ export function e164(params?: string | core.$ZodE164Params): ZodE164 {
660
+ return core._e164(ZodE164, params);
661
+ }
662
+
663
+ // ZodJWT
664
+ export interface ZodJWT extends ZodStringFormat<"jwt"> {
665
+ _zod: core.$ZodJWTInternals;
666
+ }
667
+ export const ZodJWT: core.$constructor<ZodJWT> = /*@__PURE__*/ core.$constructor("ZodJWT", (inst, def) => {
668
+ // ZodStringFormat.init(inst, def);
669
+ core.$ZodJWT.init(inst, def);
670
+ ZodStringFormat.init(inst, def);
671
+ });
672
+
673
+ export function jwt(params?: string | core.$ZodJWTParams): ZodJWT {
674
+ return core._jwt(ZodJWT, params);
675
+ }
676
+
677
+ // ZodCustomStringFormat
678
+ export interface ZodCustomStringFormat<Format extends string = string>
679
+ extends ZodStringFormat<Format>,
680
+ core.$ZodCustomStringFormat<Format> {
681
+ _zod: core.$ZodCustomStringFormatInternals<Format>;
682
+ }
683
+ export const ZodCustomStringFormat: core.$constructor<ZodCustomStringFormat> = /*@__PURE__*/ core.$constructor(
684
+ "ZodCustomStringFormat",
685
+ (inst, def) => {
686
+ // ZodStringFormat.init(inst, def);
687
+ core.$ZodCustomStringFormat.init(inst, def);
688
+ ZodStringFormat.init(inst, def);
689
+ }
690
+ );
691
+ export function stringFormat<Format extends string>(
692
+ format: Format,
693
+ fnOrRegex: ((arg: string) => util.MaybeAsync<unknown>) | RegExp,
694
+ _params: string | core.$ZodStringFormatParams = {}
695
+ ): ZodCustomStringFormat<Format> {
696
+ return core._stringFormat(ZodCustomStringFormat, format, fnOrRegex, _params) as any;
697
+ }
698
+
699
+ // ZodNumber
700
+ export interface _ZodNumber<Internals extends core.$ZodNumberInternals = core.$ZodNumberInternals>
701
+ extends _ZodType<Internals> {
702
+ gt(value: number, params?: string | core.$ZodCheckGreaterThanParams): this;
703
+ /** Identical to .min() */
704
+ gte(value: number, params?: string | core.$ZodCheckGreaterThanParams): this;
705
+ min(value: number, params?: string | core.$ZodCheckGreaterThanParams): this;
706
+ lt(value: number, params?: string | core.$ZodCheckLessThanParams): this;
707
+ /** Identical to .max() */
708
+ lte(value: number, params?: string | core.$ZodCheckLessThanParams): this;
709
+ max(value: number, params?: string | core.$ZodCheckLessThanParams): this;
710
+ /** Consider `z.int()` instead. This API is considered *legacy*; it will never be removed but a better alternative exists. */
711
+ int(params?: string | core.$ZodCheckNumberFormatParams): this;
712
+ /** @deprecated This is now identical to `.int()`. Only numbers in the safe integer range are accepted. */
713
+ safe(params?: string | core.$ZodCheckNumberFormatParams): this;
714
+ positive(params?: string | core.$ZodCheckGreaterThanParams): this;
715
+ nonnegative(params?: string | core.$ZodCheckGreaterThanParams): this;
716
+ negative(params?: string | core.$ZodCheckLessThanParams): this;
717
+ nonpositive(params?: string | core.$ZodCheckLessThanParams): this;
718
+ multipleOf(value: number, params?: string | core.$ZodCheckMultipleOfParams): this;
719
+ /** @deprecated Use `.multipleOf()` instead. */
720
+ step(value: number, params?: string | core.$ZodCheckMultipleOfParams): this;
721
+
722
+ /** @deprecated In v4 and later, z.number() does not allow infinite values by default. This is a no-op. */
723
+ finite(params?: unknown): this;
724
+
725
+ minValue: number | null;
726
+ maxValue: number | null;
727
+ /** @deprecated Check the `format` property instead. */
728
+ isInt: boolean;
729
+ /** @deprecated Number schemas no longer accept infinite values, so this always returns `true`. */
730
+ isFinite: boolean;
731
+ format: string | null;
732
+ }
733
+
734
+ export interface ZodNumber extends _ZodNumber<core.$ZodNumberInternals<number>> {}
735
+
736
+ export const ZodNumber: core.$constructor<ZodNumber> = /*@__PURE__*/ core.$constructor("ZodNumber", (inst, def) => {
737
+ core.$ZodNumber.init(inst, def);
738
+ ZodType.init(inst, def);
739
+
740
+ inst.gt = (value, params) => inst.check(checks.gt(value, params));
741
+ inst.gte = (value, params) => inst.check(checks.gte(value, params));
742
+ inst.min = (value, params) => inst.check(checks.gte(value, params));
743
+ inst.lt = (value, params) => inst.check(checks.lt(value, params));
744
+ inst.lte = (value, params) => inst.check(checks.lte(value, params));
745
+ inst.max = (value, params) => inst.check(checks.lte(value, params));
746
+ inst.int = (params) => inst.check(int(params));
747
+ inst.safe = (params) => inst.check(int(params));
748
+ inst.positive = (params) => inst.check(checks.gt(0, params));
749
+ inst.nonnegative = (params) => inst.check(checks.gte(0, params));
750
+ inst.negative = (params) => inst.check(checks.lt(0, params));
751
+ inst.nonpositive = (params) => inst.check(checks.lte(0, params));
752
+ inst.multipleOf = (value, params) => inst.check(checks.multipleOf(value, params));
753
+ inst.step = (value, params) => inst.check(checks.multipleOf(value, params));
754
+
755
+ // inst.finite = (params) => inst.check(core.finite(params));
756
+ inst.finite = () => inst;
757
+
758
+ const bag = inst._zod.bag;
759
+ inst.minValue =
760
+ Math.max(bag.minimum ?? Number.NEGATIVE_INFINITY, bag.exclusiveMinimum ?? Number.NEGATIVE_INFINITY) ?? null;
761
+ inst.maxValue =
762
+ Math.min(bag.maximum ?? Number.POSITIVE_INFINITY, bag.exclusiveMaximum ?? Number.POSITIVE_INFINITY) ?? null;
763
+ inst.isInt = (bag.format ?? "").includes("int") || Number.isSafeInteger(bag.multipleOf ?? 0.5);
764
+ inst.isFinite = true;
765
+ inst.format = bag.format ?? null;
766
+ });
767
+
768
+ export function number(params?: string | core.$ZodNumberParams): ZodNumber {
769
+ return core._number(ZodNumber, params) as any;
770
+ }
771
+
772
+ // ZodNumberFormat
773
+ export interface ZodNumberFormat extends ZodNumber {
774
+ _zod: core.$ZodNumberFormatInternals;
775
+ }
776
+ export const ZodNumberFormat: core.$constructor<ZodNumberFormat> = /*@__PURE__*/ core.$constructor(
777
+ "ZodNumberFormat",
778
+ (inst, def) => {
779
+ core.$ZodNumberFormat.init(inst, def);
780
+ ZodNumber.init(inst, def);
781
+ }
782
+ );
783
+
784
+ // int
785
+ export interface ZodInt extends ZodNumberFormat {}
786
+ export function int(params?: string | core.$ZodCheckNumberFormatParams): ZodInt {
787
+ return core._int(ZodNumberFormat, params);
788
+ }
789
+
790
+ // float32
791
+ export interface ZodFloat32 extends ZodNumberFormat {}
792
+ export function float32(params?: string | core.$ZodCheckNumberFormatParams): ZodFloat32 {
793
+ return core._float32(ZodNumberFormat, params);
794
+ }
795
+
796
+ // float64
797
+ export interface ZodFloat64 extends ZodNumberFormat {}
798
+ export function float64(params?: string | core.$ZodCheckNumberFormatParams): ZodFloat64 {
799
+ return core._float64(ZodNumberFormat, params);
800
+ }
801
+
802
+ // int32
803
+ export interface ZodInt32 extends ZodNumberFormat {}
804
+ export function int32(params?: string | core.$ZodCheckNumberFormatParams): ZodInt32 {
805
+ return core._int32(ZodNumberFormat, params);
806
+ }
807
+
808
+ // uint32
809
+ export interface ZodUInt32 extends ZodNumberFormat {}
810
+ export function uint32(params?: string | core.$ZodCheckNumberFormatParams): ZodUInt32 {
811
+ return core._uint32(ZodNumberFormat, params);
812
+ }
813
+
814
+ // boolean
815
+ export interface _ZodBoolean<T extends core.$ZodBooleanInternals = core.$ZodBooleanInternals> extends _ZodType<T> {}
816
+ export interface ZodBoolean extends _ZodBoolean<core.$ZodBooleanInternals<boolean>> {}
817
+ export const ZodBoolean: core.$constructor<ZodBoolean> = /*@__PURE__*/ core.$constructor("ZodBoolean", (inst, def) => {
818
+ core.$ZodBoolean.init(inst, def);
819
+ ZodType.init(inst, def);
820
+ });
821
+
822
+ export function boolean(params?: string | core.$ZodBooleanParams): ZodBoolean {
823
+ return core._boolean(ZodBoolean, params) as any;
824
+ }
825
+
826
+ // bigint
827
+ export interface _ZodBigInt<T extends core.$ZodBigIntInternals = core.$ZodBigIntInternals> extends _ZodType<T> {
828
+ gte(value: bigint, params?: string | core.$ZodCheckGreaterThanParams): this;
829
+ /** Alias of `.gte()` */
830
+ min(value: bigint, params?: string | core.$ZodCheckGreaterThanParams): this;
831
+ gt(value: bigint, params?: string | core.$ZodCheckGreaterThanParams): this;
832
+ /** Alias of `.lte()` */
833
+ lte(value: bigint, params?: string | core.$ZodCheckLessThanParams): this;
834
+ max(value: bigint, params?: string | core.$ZodCheckLessThanParams): this;
835
+ lt(value: bigint, params?: string | core.$ZodCheckLessThanParams): this;
836
+ positive(params?: string | core.$ZodCheckGreaterThanParams): this;
837
+ negative(params?: string | core.$ZodCheckLessThanParams): this;
838
+ nonpositive(params?: string | core.$ZodCheckLessThanParams): this;
839
+ nonnegative(params?: string | core.$ZodCheckGreaterThanParams): this;
840
+ multipleOf(value: bigint, params?: string | core.$ZodCheckMultipleOfParams): this;
841
+
842
+ minValue: bigint | null;
843
+ maxValue: bigint | null;
844
+ format: string | null;
845
+ }
846
+
847
+ export interface ZodBigInt extends _ZodBigInt<core.$ZodBigIntInternals<bigint>> {}
848
+ export const ZodBigInt: core.$constructor<ZodBigInt> = /*@__PURE__*/ core.$constructor("ZodBigInt", (inst, def) => {
849
+ core.$ZodBigInt.init(inst, def);
850
+ ZodType.init(inst, def);
851
+
852
+ inst.gte = (value, params) => inst.check(checks.gte(value, params));
853
+ inst.min = (value, params) => inst.check(checks.gte(value, params));
854
+ inst.gt = (value, params) => inst.check(checks.gt(value, params));
855
+ inst.gte = (value, params) => inst.check(checks.gte(value, params));
856
+ inst.min = (value, params) => inst.check(checks.gte(value, params));
857
+ inst.lt = (value, params) => inst.check(checks.lt(value, params));
858
+ inst.lte = (value, params) => inst.check(checks.lte(value, params));
859
+ inst.max = (value, params) => inst.check(checks.lte(value, params));
860
+ inst.positive = (params) => inst.check(checks.gt(BigInt(0), params));
861
+ inst.negative = (params) => inst.check(checks.lt(BigInt(0), params));
862
+ inst.nonpositive = (params) => inst.check(checks.lte(BigInt(0), params));
863
+ inst.nonnegative = (params) => inst.check(checks.gte(BigInt(0), params));
864
+ inst.multipleOf = (value, params) => inst.check(checks.multipleOf(value, params));
865
+
866
+ const bag = inst._zod.bag;
867
+ inst.minValue = bag.minimum ?? null;
868
+ inst.maxValue = bag.maximum ?? null;
869
+ inst.format = bag.format ?? null;
870
+ });
871
+
872
+ export function bigint(params?: string | core.$ZodBigIntParams): ZodBigInt {
873
+ return core._bigint(ZodBigInt, params) as any;
874
+ }
875
+ // bigint formats
876
+
877
+ // ZodBigIntFormat
878
+ export interface ZodBigIntFormat extends ZodBigInt {
879
+ _zod: core.$ZodBigIntFormatInternals;
880
+ }
881
+ export const ZodBigIntFormat: core.$constructor<ZodBigIntFormat> = /*@__PURE__*/ core.$constructor(
882
+ "ZodBigIntFormat",
883
+ (inst, def) => {
884
+ core.$ZodBigIntFormat.init(inst, def);
885
+ ZodBigInt.init(inst, def);
886
+ }
887
+ );
888
+
889
+ // int64
890
+ export function int64(params?: string | core.$ZodBigIntFormatParams): ZodBigIntFormat {
891
+ return core._int64(ZodBigIntFormat, params);
892
+ }
893
+
894
+ // uint64
895
+ export function uint64(params?: string | core.$ZodBigIntFormatParams): ZodBigIntFormat {
896
+ return core._uint64(ZodBigIntFormat, params);
897
+ }
898
+
899
+ // symbol
900
+ export interface ZodSymbol extends _ZodType<core.$ZodSymbolInternals> {}
901
+ export const ZodSymbol: core.$constructor<ZodSymbol> = /*@__PURE__*/ core.$constructor("ZodSymbol", (inst, def) => {
902
+ core.$ZodSymbol.init(inst, def);
903
+ ZodType.init(inst, def);
904
+ });
905
+
906
+ export function symbol(params?: string | core.$ZodSymbolParams): ZodSymbol {
907
+ return core._symbol(ZodSymbol, params);
908
+ }
909
+
910
+ // ZodUndefined
911
+ export interface ZodUndefined extends _ZodType<core.$ZodUndefinedInternals> {}
912
+ export const ZodUndefined: core.$constructor<ZodUndefined> = /*@__PURE__*/ core.$constructor(
913
+ "ZodUndefined",
914
+ (inst, def) => {
915
+ core.$ZodUndefined.init(inst, def);
916
+ ZodType.init(inst, def);
917
+ }
918
+ );
919
+
920
+ function _undefined(params?: string | core.$ZodUndefinedParams): ZodUndefined {
921
+ return core._undefined(ZodUndefined, params);
922
+ }
923
+ export { _undefined as undefined };
924
+
925
+ // ZodNull
926
+ export interface ZodNull extends _ZodType<core.$ZodNullInternals> {}
927
+ export const ZodNull: core.$constructor<ZodNull> = /*@__PURE__*/ core.$constructor("ZodNull", (inst, def) => {
928
+ core.$ZodNull.init(inst, def);
929
+ ZodType.init(inst, def);
930
+ });
931
+
932
+ function _null(params?: string | core.$ZodNullParams): ZodNull {
933
+ return core._null(ZodNull, params);
934
+ }
935
+ export { _null as null };
936
+
937
+ // ZodAny
938
+ export interface ZodAny extends _ZodType<core.$ZodAnyInternals> {}
939
+ export const ZodAny: core.$constructor<ZodAny> = /*@__PURE__*/ core.$constructor("ZodAny", (inst, def) => {
940
+ core.$ZodAny.init(inst, def);
941
+ ZodType.init(inst, def);
942
+ });
943
+
944
+ export function any(): ZodAny {
945
+ return core._any(ZodAny);
946
+ }
947
+
948
+ // ZodUnknown
949
+ export interface ZodUnknown extends _ZodType<core.$ZodUnknownInternals> {}
950
+ export const ZodUnknown: core.$constructor<ZodUnknown> = /*@__PURE__*/ core.$constructor("ZodUnknown", (inst, def) => {
951
+ core.$ZodUnknown.init(inst, def);
952
+ ZodType.init(inst, def);
953
+ });
954
+
955
+ export function unknown(): ZodUnknown {
956
+ return core._unknown(ZodUnknown);
957
+ }
958
+
959
+ // ZodNever
960
+ export interface ZodNever extends _ZodType<core.$ZodNeverInternals> {}
961
+ export const ZodNever: core.$constructor<ZodNever> = /*@__PURE__*/ core.$constructor("ZodNever", (inst, def) => {
962
+ core.$ZodNever.init(inst, def);
963
+ ZodType.init(inst, def);
964
+ });
965
+
966
+ export function never(params?: string | core.$ZodNeverParams): ZodNever {
967
+ return core._never(ZodNever, params);
968
+ }
969
+
970
+ // ZodVoid
971
+ export interface ZodVoid extends _ZodType<core.$ZodVoidInternals> {}
972
+ export const ZodVoid: core.$constructor<ZodVoid> = /*@__PURE__*/ core.$constructor("ZodVoid", (inst, def) => {
973
+ core.$ZodVoid.init(inst, def);
974
+ ZodType.init(inst, def);
975
+ });
976
+
977
+ function _void(params?: string | core.$ZodVoidParams): ZodVoid {
978
+ return core._void(ZodVoid, params);
979
+ }
980
+ export { _void as void };
981
+
982
+ // ZodDate
983
+ export interface _ZodDate<T extends core.$ZodDateInternals = core.$ZodDateInternals> extends _ZodType<T> {
984
+ min(value: number | Date, params?: string | core.$ZodCheckGreaterThanParams): this;
985
+ max(value: number | Date, params?: string | core.$ZodCheckLessThanParams): this;
986
+
987
+ /** @deprecated Not recommended. */
988
+ minDate: Date | null;
989
+ /** @deprecated Not recommended. */
990
+ maxDate: Date | null;
991
+ }
992
+
993
+ export interface ZodDate extends _ZodDate<core.$ZodDateInternals<Date>> {}
994
+ export const ZodDate: core.$constructor<ZodDate> = /*@__PURE__*/ core.$constructor("ZodDate", (inst, def) => {
995
+ core.$ZodDate.init(inst, def);
996
+ ZodType.init(inst, def);
997
+
998
+ inst.min = (value, params) => inst.check(checks.gte(value, params));
999
+ inst.max = (value, params) => inst.check(checks.lte(value, params));
1000
+
1001
+ const c = inst._zod.bag;
1002
+ inst.minDate = c.minimum ? new Date(c.minimum) : null;
1003
+ inst.maxDate = c.maximum ? new Date(c.maximum) : null;
1004
+ });
1005
+
1006
+ export function date(params?: string | core.$ZodDateParams): ZodDate {
1007
+ return core._date(ZodDate, params);
1008
+ }
1009
+
1010
+ // ZodArray
1011
+ export interface ZodArray<T extends core.SomeType = core.$ZodType>
1012
+ extends _ZodType<core.$ZodArrayInternals<T>>,
1013
+ core.$ZodArray<T> {
1014
+ element: T;
1015
+ min(minLength: number, params?: string | core.$ZodCheckMinLengthParams): this;
1016
+ nonempty(params?: string | core.$ZodCheckMinLengthParams): this;
1017
+ max(maxLength: number, params?: string | core.$ZodCheckMaxLengthParams): this;
1018
+ length(len: number, params?: string | core.$ZodCheckLengthEqualsParams): this;
1019
+
1020
+ unwrap(): T;
1021
+ }
1022
+ export const ZodArray: core.$constructor<ZodArray> = /*@__PURE__*/ core.$constructor("ZodArray", (inst, def) => {
1023
+ core.$ZodArray.init(inst, def);
1024
+ ZodType.init(inst, def);
1025
+
1026
+ inst.element = def.element as any;
1027
+ inst.min = (minLength, params) => inst.check(checks.minLength(minLength, params));
1028
+ inst.nonempty = (params) => inst.check(checks.minLength(1, params));
1029
+ inst.max = (maxLength, params) => inst.check(checks.maxLength(maxLength, params));
1030
+ inst.length = (len, params) => inst.check(checks.length(len, params));
1031
+
1032
+ inst.unwrap = () => inst.element;
1033
+ });
1034
+
1035
+ export function array<T extends core.SomeType>(element: T, params?: string | core.$ZodArrayParams): ZodArray<T> {
1036
+ return core._array(ZodArray, element as any, params) as any;
1037
+ }
1038
+
1039
+ // .keyof
1040
+ export function keyof<T extends ZodObject>(schema: T): ZodLiteral<Exclude<keyof T["_zod"]["output"], symbol>> {
1041
+ const shape = schema._zod.def.shape;
1042
+ return literal(Object.keys(shape)) as any;
1043
+ }
1044
+
1045
+ // ZodObject
1046
+
1047
+ export interface ZodObject<
1048
+ /** @ts-ignore Cast variance */
1049
+ out Shape extends core.$ZodShape = core.$ZodLooseShape,
1050
+ out Config extends core.$ZodObjectConfig = core.$strip,
1051
+ > extends _ZodType<core.$ZodObjectInternals<Shape, Config>>,
1052
+ core.$ZodObject<Shape, Config> {
1053
+ shape: Shape;
1054
+
1055
+ keyof(): ZodEnum<util.ToEnum<keyof Shape & string>>;
1056
+ /** Define a schema to validate all unrecognized keys. This overrides the existing strict/loose behavior. */
1057
+ catchall<T extends core.SomeType>(schema: T): ZodObject<Shape, core.$catchall<T>>;
1058
+
1059
+ /** @deprecated Use `z.looseObject()` or `.loose()` instead. */
1060
+ passthrough(): ZodObject<Shape, core.$loose>;
1061
+ /** Consider `z.looseObject(A.shape)` instead */
1062
+ loose(): ZodObject<Shape, core.$loose>;
1063
+
1064
+ /** Consider `z.strictObject(A.shape)` instead */
1065
+ strict(): ZodObject<Shape, core.$strict>;
1066
+
1067
+ /** This is the default behavior. This method call is likely unnecessary. */
1068
+ strip(): ZodObject<Shape, core.$strip>;
1069
+
1070
+ extend<U extends core.$ZodLooseShape & Partial<Record<keyof Shape, core.SomeType>>>(
1071
+ shape: U
1072
+ ): ZodObject<util.Extend<Shape, U>, Config>;
1073
+
1074
+ /**
1075
+ * @deprecated Use spread syntax and the `.shape` property to combine two object schemas:
1076
+ *
1077
+ * ```ts
1078
+ * const A = z.object({ a: z.string() });
1079
+ * const B = z.object({ b: z.number() });
1080
+ *
1081
+ * const C = z.object({
1082
+ * ...A.shape,
1083
+ * ...B.shape
1084
+ * });
1085
+ * ```
1086
+ */
1087
+ merge<U extends ZodObject>(other: U): ZodObject<util.Extend<Shape, U["shape"]>, U["_zod"]["config"]>;
1088
+
1089
+ pick<M extends util.Mask<keyof Shape>>(
1090
+ mask: M
1091
+ ): ZodObject<util.Flatten<Pick<Shape, Extract<keyof Shape, keyof M>>>, Config>;
1092
+
1093
+ omit<M extends util.Mask<keyof Shape>>(
1094
+ mask: M
1095
+ ): ZodObject<util.Flatten<Omit<Shape, Extract<keyof Shape, keyof M>>>, Config>;
1096
+
1097
+ partial(): ZodObject<
1098
+ {
1099
+ [k in keyof Shape]: ZodOptional<Shape[k]>;
1100
+ },
1101
+ Config
1102
+ >;
1103
+ partial<M extends util.Mask<keyof Shape>>(
1104
+ mask: M
1105
+ ): ZodObject<
1106
+ {
1107
+ [k in keyof Shape]: k extends keyof M
1108
+ ? // Shape[k] extends OptionalInSchema
1109
+ // ? Shape[k]
1110
+ // :
1111
+ ZodOptional<Shape[k]>
1112
+ : Shape[k];
1113
+ },
1114
+ Config
1115
+ >;
1116
+
1117
+ // required
1118
+ required(): ZodObject<
1119
+ {
1120
+ [k in keyof Shape]: ZodNonOptional<Shape[k]>;
1121
+ },
1122
+ Config
1123
+ >;
1124
+ required<M extends util.Mask<keyof Shape>>(
1125
+ mask: M
1126
+ ): ZodObject<
1127
+ {
1128
+ [k in keyof Shape]: k extends keyof M ? ZodNonOptional<Shape[k]> : Shape[k];
1129
+ },
1130
+ Config
1131
+ >;
1132
+ }
1133
+
1134
+ export const ZodObject: core.$constructor<ZodObject> = /*@__PURE__*/ core.$constructor("ZodObject", (inst, def) => {
1135
+ core.$ZodObject.init(inst, def);
1136
+ ZodType.init(inst, def);
1137
+
1138
+ util.defineLazy(inst, "shape", () => def.shape);
1139
+ inst.keyof = () => _enum(Object.keys(inst._zod.def.shape)) as any;
1140
+ inst.catchall = (catchall) => inst.clone({ ...inst._zod.def, catchall: catchall as any as core.$ZodType }) as any;
1141
+ inst.passthrough = () => inst.clone({ ...inst._zod.def, catchall: unknown() });
1142
+ // inst.nonstrict = () => inst.clone({ ...inst._zod.def, catchall: api.unknown() });
1143
+ inst.loose = () => inst.clone({ ...inst._zod.def, catchall: unknown() });
1144
+ inst.strict = () => inst.clone({ ...inst._zod.def, catchall: never() });
1145
+ inst.strip = () => inst.clone({ ...inst._zod.def, catchall: undefined });
1146
+
1147
+ inst.extend = (incoming: any) => {
1148
+ return util.extend(inst, incoming);
1149
+ };
1150
+ inst.merge = (other) => util.merge(inst, other);
1151
+ inst.pick = (mask) => util.pick(inst, mask);
1152
+ inst.omit = (mask) => util.omit(inst, mask);
1153
+ inst.partial = (...args: any[]) => util.partial(ZodOptional, inst, args[0] as object);
1154
+ inst.required = (...args: any[]) => util.required(ZodNonOptional, inst, args[0] as object);
1155
+ });
1156
+
1157
+ export function object<T extends core.$ZodLooseShape = Partial<Record<never, core.SomeType>>>(
1158
+ shape?: T,
1159
+ params?: string | core.$ZodObjectParams
1160
+ ): ZodObject<util.Writeable<T>, core.$strip> {
1161
+ const def: core.$ZodObjectDef = {
1162
+ type: "object",
1163
+ get shape() {
1164
+ util.assignProp(this, "shape", { ...shape });
1165
+ return this.shape;
1166
+ },
1167
+ ...util.normalizeParams(params),
1168
+ };
1169
+ return new ZodObject(def) as any;
1170
+ }
1171
+
1172
+ // strictObject
1173
+
1174
+ export function strictObject<T extends core.$ZodLooseShape>(
1175
+ shape: T,
1176
+ params?: string | core.$ZodObjectParams
1177
+ ): ZodObject<T, core.$strict> {
1178
+ return new ZodObject({
1179
+ type: "object",
1180
+ get shape() {
1181
+ util.assignProp(this, "shape", { ...shape });
1182
+ return this.shape;
1183
+ },
1184
+ catchall: never(),
1185
+ ...util.normalizeParams(params),
1186
+ }) as any;
1187
+ }
1188
+
1189
+ // looseObject
1190
+
1191
+ export function looseObject<T extends core.$ZodLooseShape>(
1192
+ shape: T,
1193
+ params?: string | core.$ZodObjectParams
1194
+ ): ZodObject<T, core.$loose> {
1195
+ return new ZodObject({
1196
+ type: "object",
1197
+ get shape() {
1198
+ util.assignProp(this, "shape", { ...shape });
1199
+ return this.shape;
1200
+ },
1201
+ catchall: unknown(),
1202
+ ...util.normalizeParams(params),
1203
+ }) as any;
1204
+ }
1205
+
1206
+ // ZodUnion
1207
+ export interface ZodUnion<T extends readonly core.SomeType[] = readonly core.$ZodType[]>
1208
+ extends _ZodType<core.$ZodUnionInternals<T>>,
1209
+ core.$ZodUnion<T> {
1210
+ options: T;
1211
+ }
1212
+ export const ZodUnion: core.$constructor<ZodUnion> = /*@__PURE__*/ core.$constructor("ZodUnion", (inst, def) => {
1213
+ core.$ZodUnion.init(inst, def);
1214
+ ZodType.init(inst, def);
1215
+ inst.options = def.options;
1216
+ });
1217
+
1218
+ export function union<const T extends readonly core.SomeType[]>(
1219
+ options: T,
1220
+ params?: string | core.$ZodUnionParams
1221
+ ): ZodUnion<T> {
1222
+ return new ZodUnion({
1223
+ type: "union",
1224
+ options: options as any as core.$ZodType[],
1225
+ ...util.normalizeParams(params),
1226
+ }) as any;
1227
+ }
1228
+
1229
+ // ZodDiscriminatedUnion
1230
+ export interface ZodDiscriminatedUnion<Options extends readonly core.SomeType[] = readonly core.$ZodType[]>
1231
+ extends ZodUnion<Options>,
1232
+ core.$ZodDiscriminatedUnion<Options> {
1233
+ _zod: core.$ZodDiscriminatedUnionInternals<Options>;
1234
+ }
1235
+ export const ZodDiscriminatedUnion: core.$constructor<ZodDiscriminatedUnion> = /*@__PURE__*/ core.$constructor(
1236
+ "ZodDiscriminatedUnion",
1237
+ (inst, def) => {
1238
+ ZodUnion.init(inst, def);
1239
+ core.$ZodDiscriminatedUnion.init(inst, def);
1240
+ }
1241
+ );
1242
+
1243
+ export function discriminatedUnion<
1244
+ Types extends readonly [core.$ZodTypeDiscriminable, ...core.$ZodTypeDiscriminable[]],
1245
+ >(
1246
+ discriminator: string,
1247
+ options: Types,
1248
+ params?: string | core.$ZodDiscriminatedUnionParams
1249
+ ): ZodDiscriminatedUnion<Types> {
1250
+ // const [options, params] = args;
1251
+ return new ZodDiscriminatedUnion({
1252
+ type: "union",
1253
+ options,
1254
+ discriminator,
1255
+ ...util.normalizeParams(params),
1256
+ }) as any;
1257
+ }
1258
+
1259
+ // ZodIntersection
1260
+ export interface ZodIntersection<A extends core.SomeType = core.$ZodType, B extends core.SomeType = core.$ZodType>
1261
+ extends _ZodType<core.$ZodIntersectionInternals<A, B>>,
1262
+ core.$ZodIntersection<A, B> {}
1263
+ export const ZodIntersection: core.$constructor<ZodIntersection> = /*@__PURE__*/ core.$constructor(
1264
+ "ZodIntersection",
1265
+ (inst, def) => {
1266
+ core.$ZodIntersection.init(inst, def);
1267
+ ZodType.init(inst, def);
1268
+ }
1269
+ );
1270
+
1271
+ export function intersection<T extends core.SomeType, U extends core.SomeType>(
1272
+ left: T,
1273
+ right: U
1274
+ ): ZodIntersection<T, U> {
1275
+ return new ZodIntersection({
1276
+ type: "intersection",
1277
+ left: left as any as core.$ZodType,
1278
+ right: right as any as core.$ZodType,
1279
+ }) as any;
1280
+ }
1281
+
1282
+ // ZodTuple
1283
+ export interface ZodTuple<
1284
+ T extends util.TupleItems = readonly core.$ZodType[],
1285
+ Rest extends core.SomeType | null = core.$ZodType | null,
1286
+ > extends _ZodType<core.$ZodTupleInternals<T, Rest>>,
1287
+ core.$ZodTuple<T, Rest> {
1288
+ rest<Rest extends core.SomeType = core.$ZodType>(rest: Rest): ZodTuple<T, Rest>;
1289
+ }
1290
+ export const ZodTuple: core.$constructor<ZodTuple> = /*@__PURE__*/ core.$constructor("ZodTuple", (inst, def) => {
1291
+ core.$ZodTuple.init(inst, def);
1292
+ ZodType.init(inst, def);
1293
+ inst.rest = (rest) =>
1294
+ inst.clone({
1295
+ ...inst._zod.def,
1296
+ rest: rest as any as core.$ZodType,
1297
+ }) as any;
1298
+ });
1299
+
1300
+ export function tuple<T extends readonly [core.SomeType, ...core.SomeType[]]>(
1301
+ items: T,
1302
+ params?: string | core.$ZodTupleParams
1303
+ ): ZodTuple<T, null>;
1304
+ export function tuple<T extends readonly [core.SomeType, ...core.SomeType[]], Rest extends core.SomeType>(
1305
+ items: T,
1306
+ rest: Rest,
1307
+ params?: string | core.$ZodTupleParams
1308
+ ): ZodTuple<T, Rest>;
1309
+ export function tuple(items: [], params?: string | core.$ZodTupleParams): ZodTuple<[], null>;
1310
+ export function tuple(
1311
+ items: core.SomeType[],
1312
+ _paramsOrRest?: string | core.$ZodTupleParams | core.SomeType,
1313
+ _params?: string | core.$ZodTupleParams
1314
+ ) {
1315
+ const hasRest = _paramsOrRest instanceof core.$ZodType;
1316
+ const params = hasRest ? _params : _paramsOrRest;
1317
+ const rest = hasRest ? _paramsOrRest : null;
1318
+ return new ZodTuple({
1319
+ type: "tuple",
1320
+ items: items as any as core.$ZodType[],
1321
+ rest,
1322
+ ...util.normalizeParams(params),
1323
+ });
1324
+ }
1325
+
1326
+ // ZodRecord
1327
+ export interface ZodRecord<
1328
+ Key extends core.$ZodRecordKey = core.$ZodRecordKey,
1329
+ Value extends core.SomeType = core.$ZodType,
1330
+ > extends _ZodType<core.$ZodRecordInternals<Key, Value>>,
1331
+ core.$ZodRecord<Key, Value> {
1332
+ keyType: Key;
1333
+ valueType: Value;
1334
+ }
1335
+ export const ZodRecord: core.$constructor<ZodRecord> = /*@__PURE__*/ core.$constructor("ZodRecord", (inst, def) => {
1336
+ core.$ZodRecord.init(inst, def);
1337
+ ZodType.init(inst, def);
1338
+
1339
+ inst.keyType = def.keyType;
1340
+ inst.valueType = def.valueType;
1341
+ });
1342
+
1343
+ export function record<Key extends core.$ZodRecordKey, Value extends core.SomeType>(
1344
+ keyType: Key,
1345
+ valueType: Value,
1346
+ params?: string | core.$ZodRecordParams
1347
+ ): ZodRecord<Key, Value> {
1348
+ return new ZodRecord({
1349
+ type: "record",
1350
+ keyType,
1351
+ valueType: valueType as any as core.$ZodType,
1352
+ ...util.normalizeParams(params),
1353
+ }) as any;
1354
+ }
1355
+ // type alksjf = core.output<core.$ZodRecordKey>;
1356
+ export function partialRecord<Key extends core.$ZodRecordKey, Value extends core.SomeType>(
1357
+ keyType: Key,
1358
+ valueType: Value,
1359
+ params?: string | core.$ZodRecordParams
1360
+ ): ZodRecord<ZodUnion<[Key, ZodNever]>, Value> {
1361
+ return new ZodRecord({
1362
+ type: "record",
1363
+ keyType: union([keyType, never()]),
1364
+ valueType: valueType as any as core.$ZodType,
1365
+ ...util.normalizeParams(params),
1366
+ }) as any;
1367
+ }
1368
+
1369
+ // ZodMap
1370
+ export interface ZodMap<Key extends core.SomeType = core.$ZodType, Value extends core.SomeType = core.$ZodType>
1371
+ extends _ZodType<core.$ZodMapInternals<Key, Value>>,
1372
+ core.$ZodMap<Key, Value> {
1373
+ keyType: Key;
1374
+ valueType: Value;
1375
+ }
1376
+ export const ZodMap: core.$constructor<ZodMap> = /*@__PURE__*/ core.$constructor("ZodMap", (inst, def) => {
1377
+ core.$ZodMap.init(inst, def);
1378
+ ZodType.init(inst, def);
1379
+ inst.keyType = def.keyType;
1380
+ inst.valueType = def.valueType;
1381
+ });
1382
+
1383
+ export function map<Key extends core.SomeType, Value extends core.SomeType>(
1384
+ keyType: Key,
1385
+ valueType: Value,
1386
+ params?: string | core.$ZodMapParams
1387
+ ): ZodMap<Key, Value> {
1388
+ return new ZodMap({
1389
+ type: "map",
1390
+ keyType: keyType as any as core.$ZodType,
1391
+ valueType: valueType as any as core.$ZodType,
1392
+ ...util.normalizeParams(params),
1393
+ }) as any;
1394
+ }
1395
+
1396
+ // ZodSet
1397
+ export interface ZodSet<T extends core.SomeType = core.$ZodType>
1398
+ extends _ZodType<core.$ZodSetInternals<T>>,
1399
+ core.$ZodSet<T> {
1400
+ min(minSize: number, params?: string | core.$ZodCheckMinSizeParams): this;
1401
+ /** */
1402
+ nonempty(params?: string | core.$ZodCheckMinSizeParams): this;
1403
+ max(maxSize: number, params?: string | core.$ZodCheckMaxSizeParams): this;
1404
+ size(size: number, params?: string | core.$ZodCheckSizeEqualsParams): this;
1405
+ }
1406
+ export const ZodSet: core.$constructor<ZodSet> = /*@__PURE__*/ core.$constructor("ZodSet", (inst, def) => {
1407
+ core.$ZodSet.init(inst, def);
1408
+ ZodType.init(inst, def);
1409
+
1410
+ inst.min = (...args) => inst.check(core._minSize(...args));
1411
+ inst.nonempty = (params) => inst.check(core._minSize(1, params));
1412
+ inst.max = (...args) => inst.check(core._maxSize(...args));
1413
+ inst.size = (...args) => inst.check(core._size(...args));
1414
+ });
1415
+
1416
+ export function set<Value extends core.SomeType>(
1417
+ valueType: Value,
1418
+ params?: string | core.$ZodSetParams
1419
+ ): ZodSet<Value> {
1420
+ return new ZodSet({
1421
+ type: "set",
1422
+ valueType: valueType as any as core.$ZodType,
1423
+ ...util.normalizeParams(params),
1424
+ }) as any;
1425
+ }
1426
+
1427
+ // ZodEnum
1428
+ export interface ZodEnum<
1429
+ /** @ts-ignore Cast variance */
1430
+ out T extends util.EnumLike = util.EnumLike,
1431
+ > extends _ZodType<core.$ZodEnumInternals<T>>,
1432
+ core.$ZodEnum<T> {
1433
+ enum: T;
1434
+ options: Array<T[keyof T]>;
1435
+
1436
+ extract<const U extends readonly (keyof T)[]>(
1437
+ values: U,
1438
+ params?: string | core.$ZodEnumParams
1439
+ ): ZodEnum<util.Flatten<Pick<T, U[number]>>>;
1440
+ exclude<const U extends readonly (keyof T)[]>(
1441
+ values: U,
1442
+ params?: string | core.$ZodEnumParams
1443
+ ): ZodEnum<util.Flatten<Omit<T, U[number]>>>;
1444
+ }
1445
+ export const ZodEnum: core.$constructor<ZodEnum> = /*@__PURE__*/ core.$constructor("ZodEnum", (inst, def) => {
1446
+ core.$ZodEnum.init(inst, def);
1447
+ ZodType.init(inst, def);
1448
+
1449
+ inst.enum = def.entries;
1450
+ inst.options = Object.values(def.entries);
1451
+
1452
+ const keys = new Set(Object.keys(def.entries));
1453
+
1454
+ inst.extract = (values, params) => {
1455
+ const newEntries: Record<string, any> = {};
1456
+ for (const value of values) {
1457
+ if (keys.has(value)) {
1458
+ newEntries[value] = def.entries[value];
1459
+ } else throw new Error(`Key ${value} not found in enum`);
1460
+ }
1461
+ return new ZodEnum({
1462
+ ...def,
1463
+ checks: [],
1464
+ ...util.normalizeParams(params),
1465
+ entries: newEntries,
1466
+ }) as any;
1467
+ };
1468
+
1469
+ inst.exclude = (values, params) => {
1470
+ const newEntries: Record<string, any> = { ...def.entries };
1471
+ for (const value of values) {
1472
+ if (keys.has(value)) {
1473
+ delete newEntries[value];
1474
+ } else throw new Error(`Key ${value} not found in enum`);
1475
+ }
1476
+ return new ZodEnum({
1477
+ ...def,
1478
+ checks: [],
1479
+ ...util.normalizeParams(params),
1480
+ entries: newEntries,
1481
+ }) as any;
1482
+ };
1483
+ });
1484
+
1485
+ function _enum<const T extends readonly string[]>(
1486
+ values: T,
1487
+ params?: string | core.$ZodEnumParams
1488
+ ): ZodEnum<util.ToEnum<T[number]>>;
1489
+ function _enum<const T extends util.EnumLike>(entries: T, params?: string | core.$ZodEnumParams): ZodEnum<T>;
1490
+ function _enum(values: any, params?: string | core.$ZodEnumParams) {
1491
+ const entries: any = Array.isArray(values) ? Object.fromEntries(values.map((v) => [v, v])) : values;
1492
+
1493
+ return new ZodEnum({
1494
+ type: "enum",
1495
+ entries,
1496
+ ...util.normalizeParams(params),
1497
+ }) as any;
1498
+ }
1499
+ export { _enum as enum };
1500
+
1501
+ /** @deprecated This API has been merged into `z.enum()`. Use `z.enum()` instead.
1502
+ *
1503
+ * ```ts
1504
+ * enum Colors { red, green, blue }
1505
+ * z.enum(Colors);
1506
+ * ```
1507
+ */
1508
+ export function nativeEnum<T extends util.EnumLike>(entries: T, params?: string | core.$ZodEnumParams): ZodEnum<T> {
1509
+ return new ZodEnum({
1510
+ type: "enum",
1511
+ entries,
1512
+ ...util.normalizeParams(params),
1513
+ }) as any as ZodEnum<T>;
1514
+ }
1515
+
1516
+ // ZodLiteral
1517
+ export interface ZodLiteral<T extends util.Literal = util.Literal>
1518
+ extends _ZodType<core.$ZodLiteralInternals<T>>,
1519
+ core.$ZodLiteral<T> {
1520
+ values: Set<T>;
1521
+ /** @legacy Use `.values` instead. Accessing this property will throw an error if the literal accepts multiple values. */
1522
+ value: T;
1523
+ }
1524
+ export const ZodLiteral: core.$constructor<ZodLiteral> = /*@__PURE__*/ core.$constructor("ZodLiteral", (inst, def) => {
1525
+ core.$ZodLiteral.init(inst, def);
1526
+ ZodType.init(inst, def);
1527
+ inst.values = new Set(def.values);
1528
+ Object.defineProperty(inst, "value", {
1529
+ get() {
1530
+ if (def.values.length > 1) {
1531
+ throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");
1532
+ }
1533
+ return def.values[0];
1534
+ },
1535
+ });
1536
+ });
1537
+
1538
+ export function literal<const T extends ReadonlyArray<util.Literal>>(
1539
+ value: T,
1540
+ params?: string | core.$ZodLiteralParams
1541
+ ): ZodLiteral<T[number]>;
1542
+ export function literal<const T extends util.Literal>(
1543
+ value: T,
1544
+ params?: string | core.$ZodLiteralParams
1545
+ ): ZodLiteral<T>;
1546
+ export function literal(value: any, params: any) {
1547
+ return new ZodLiteral({
1548
+ type: "literal",
1549
+ values: Array.isArray(value) ? value : [value],
1550
+ ...util.normalizeParams(params),
1551
+ });
1552
+ }
1553
+
1554
+ // ZodFile
1555
+ export interface ZodFile extends _ZodType<core.$ZodFileInternals>, core.$ZodFile {
1556
+ min(size: number, params?: string | core.$ZodCheckMinSizeParams): this;
1557
+ max(size: number, params?: string | core.$ZodCheckMaxSizeParams): this;
1558
+ mime(types: util.MimeTypes | Array<util.MimeTypes>, params?: string | core.$ZodCheckMimeTypeParams): this;
1559
+ }
1560
+ export const ZodFile: core.$constructor<ZodFile> = /*@__PURE__*/ core.$constructor("ZodFile", (inst, def) => {
1561
+ core.$ZodFile.init(inst, def);
1562
+ ZodType.init(inst, def);
1563
+
1564
+ inst.min = (size, params) => inst.check(core._minSize(size, params));
1565
+ inst.max = (size, params) => inst.check(core._maxSize(size, params));
1566
+ inst.mime = (types, params) => inst.check(core._mime(Array.isArray(types) ? types : [types], params));
1567
+ });
1568
+
1569
+ export function file(params?: string | core.$ZodFileParams): ZodFile {
1570
+ return core._file(ZodFile, params) as any;
1571
+ }
1572
+
1573
+ // ZodTransform
1574
+ export interface ZodTransform<O = unknown, I = unknown>
1575
+ extends _ZodType<core.$ZodTransformInternals<O, I>>,
1576
+ core.$ZodTransform<O, I> {}
1577
+ export const ZodTransform: core.$constructor<ZodTransform> = /*@__PURE__*/ core.$constructor(
1578
+ "ZodTransform",
1579
+ (inst, def) => {
1580
+ core.$ZodTransform.init(inst, def);
1581
+ ZodType.init(inst, def);
1582
+
1583
+ inst._zod.parse = (payload, _ctx) => {
1584
+ (payload as RefinementCtx).addIssue = (issue) => {
1585
+ if (typeof issue === "string") {
1586
+ payload.issues.push(util.issue(issue, payload.value, def));
1587
+ } else {
1588
+ // for Zod 3 backwards compatibility
1589
+ const _issue = issue as any;
1590
+
1591
+ if (_issue.fatal) _issue.continue = false;
1592
+ _issue.code ??= "custom";
1593
+ _issue.input ??= payload.value;
1594
+ _issue.inst ??= inst;
1595
+ _issue.continue ??= true;
1596
+ payload.issues.push(util.issue(_issue));
1597
+ }
1598
+ };
1599
+
1600
+ const output = def.transform(payload.value, payload);
1601
+ if (output instanceof Promise) {
1602
+ return output.then((output) => {
1603
+ payload.value = output;
1604
+ return payload;
1605
+ });
1606
+ }
1607
+ payload.value = output;
1608
+ return payload;
1609
+ };
1610
+ }
1611
+ );
1612
+
1613
+ export function transform<I = unknown, O = I>(
1614
+ fn: (input: I, ctx: core.ParsePayload) => O
1615
+ ): ZodTransform<Awaited<O>, I> {
1616
+ return new ZodTransform({
1617
+ type: "transform",
1618
+ transform: fn as any,
1619
+ }) as any;
1620
+ }
1621
+
1622
+ // ZodOptional
1623
+ export interface ZodOptional<T extends core.SomeType = core.$ZodType>
1624
+ extends _ZodType<core.$ZodOptionalInternals<T>>,
1625
+ core.$ZodOptional<T> {
1626
+ unwrap(): T;
1627
+ }
1628
+ export const ZodOptional: core.$constructor<ZodOptional> = /*@__PURE__*/ core.$constructor(
1629
+ "ZodOptional",
1630
+ (inst, def) => {
1631
+ core.$ZodOptional.init(inst, def);
1632
+ ZodType.init(inst, def);
1633
+
1634
+ inst.unwrap = () => inst._zod.def.innerType;
1635
+ }
1636
+ );
1637
+
1638
+ export function optional<T extends core.SomeType>(innerType: T): ZodOptional<T> {
1639
+ return new ZodOptional({
1640
+ type: "optional",
1641
+ innerType: innerType as any as core.$ZodType,
1642
+ }) as any;
1643
+ }
1644
+
1645
+ // ZodNullable
1646
+ export interface ZodNullable<T extends core.SomeType = core.$ZodType>
1647
+ extends _ZodType<core.$ZodNullableInternals<T>>,
1648
+ core.$ZodNullable<T> {
1649
+ unwrap(): T;
1650
+ }
1651
+ export const ZodNullable: core.$constructor<ZodNullable> = /*@__PURE__*/ core.$constructor(
1652
+ "ZodNullable",
1653
+ (inst, def) => {
1654
+ core.$ZodNullable.init(inst, def);
1655
+ ZodType.init(inst, def);
1656
+
1657
+ inst.unwrap = () => inst._zod.def.innerType;
1658
+ }
1659
+ );
1660
+
1661
+ export function nullable<T extends core.SomeType>(innerType: T): ZodNullable<T> {
1662
+ return new ZodNullable({
1663
+ type: "nullable",
1664
+ innerType: innerType as any as core.$ZodType,
1665
+ }) as any;
1666
+ }
1667
+
1668
+ // nullish
1669
+ export function nullish<T extends core.SomeType>(innerType: T): ZodOptional<ZodNullable<T>> {
1670
+ return optional(nullable(innerType));
1671
+ }
1672
+
1673
+ // ZodDefault
1674
+ export interface ZodDefault<T extends core.SomeType = core.$ZodType>
1675
+ extends _ZodType<core.$ZodDefaultInternals<T>>,
1676
+ core.$ZodDefault<T> {
1677
+ unwrap(): T;
1678
+ /** @deprecated Use `.unwrap()` instead. */
1679
+ removeDefault(): T;
1680
+ }
1681
+ export const ZodDefault: core.$constructor<ZodDefault> = /*@__PURE__*/ core.$constructor("ZodDefault", (inst, def) => {
1682
+ core.$ZodDefault.init(inst, def);
1683
+ ZodType.init(inst, def);
1684
+
1685
+ inst.unwrap = () => inst._zod.def.innerType;
1686
+ inst.removeDefault = inst.unwrap;
1687
+ });
1688
+
1689
+ export function _default<T extends core.SomeType>(
1690
+ innerType: T,
1691
+ defaultValue: util.NoUndefined<core.output<T>> | (() => util.NoUndefined<core.output<T>>)
1692
+ ): ZodDefault<T> {
1693
+ return new ZodDefault({
1694
+ type: "default",
1695
+ innerType: innerType as any as core.$ZodType,
1696
+ get defaultValue() {
1697
+ return typeof defaultValue === "function" ? (defaultValue as Function)() : defaultValue;
1698
+ },
1699
+ }) as any;
1700
+ }
1701
+
1702
+ // ZodPrefault
1703
+ export interface ZodPrefault<T extends core.SomeType = core.$ZodType>
1704
+ extends _ZodType<core.$ZodPrefaultInternals<T>>,
1705
+ core.$ZodPrefault<T> {
1706
+ unwrap(): T;
1707
+ }
1708
+ export const ZodPrefault: core.$constructor<ZodPrefault> = /*@__PURE__*/ core.$constructor(
1709
+ "ZodPrefault",
1710
+ (inst, def) => {
1711
+ core.$ZodPrefault.init(inst, def);
1712
+ ZodType.init(inst, def);
1713
+ inst.unwrap = () => inst._zod.def.innerType;
1714
+ }
1715
+ );
1716
+
1717
+ export function prefault<T extends core.SomeType>(
1718
+ innerType: T,
1719
+ defaultValue: core.input<T> | (() => core.input<T>)
1720
+ ): ZodPrefault<T> {
1721
+ return new ZodPrefault({
1722
+ type: "prefault",
1723
+ innerType: innerType as any as core.$ZodType,
1724
+ get defaultValue() {
1725
+ return typeof defaultValue === "function" ? (defaultValue as Function)() : defaultValue;
1726
+ },
1727
+ }) as any;
1728
+ }
1729
+
1730
+ // ZodNonOptional
1731
+ export interface ZodNonOptional<T extends core.SomeType = core.$ZodType>
1732
+ extends _ZodType<core.$ZodNonOptionalInternals<T>>,
1733
+ core.$ZodNonOptional<T> {
1734
+ unwrap(): T;
1735
+ }
1736
+ export const ZodNonOptional: core.$constructor<ZodNonOptional> = /*@__PURE__*/ core.$constructor(
1737
+ "ZodNonOptional",
1738
+ (inst, def) => {
1739
+ core.$ZodNonOptional.init(inst, def);
1740
+ ZodType.init(inst, def);
1741
+
1742
+ inst.unwrap = () => inst._zod.def.innerType;
1743
+ }
1744
+ );
1745
+
1746
+ export function nonoptional<T extends core.SomeType>(
1747
+ innerType: T,
1748
+ params?: string | core.$ZodNonOptionalParams
1749
+ ): ZodNonOptional<T> {
1750
+ return new ZodNonOptional({
1751
+ type: "nonoptional",
1752
+ innerType: innerType as any as core.$ZodType,
1753
+ ...util.normalizeParams(params),
1754
+ }) as any;
1755
+ }
1756
+
1757
+ // ZodSuccess
1758
+ export interface ZodSuccess<T extends core.SomeType = core.$ZodType>
1759
+ extends _ZodType<core.$ZodSuccessInternals<T>>,
1760
+ core.$ZodSuccess<T> {
1761
+ unwrap(): T;
1762
+ }
1763
+ export const ZodSuccess: core.$constructor<ZodSuccess> = /*@__PURE__*/ core.$constructor("ZodSuccess", (inst, def) => {
1764
+ core.$ZodSuccess.init(inst, def);
1765
+ ZodType.init(inst, def);
1766
+
1767
+ inst.unwrap = () => inst._zod.def.innerType;
1768
+ });
1769
+
1770
+ export function success<T extends core.SomeType>(innerType: T): ZodSuccess<T> {
1771
+ return new ZodSuccess({
1772
+ type: "success",
1773
+ innerType: innerType as any as core.$ZodType,
1774
+ }) as any;
1775
+ }
1776
+
1777
+ // ZodCatch
1778
+ export interface ZodCatch<T extends core.SomeType = core.$ZodType>
1779
+ extends _ZodType<core.$ZodCatchInternals<T>>,
1780
+ core.$ZodCatch<T> {
1781
+ unwrap(): T;
1782
+ /** @deprecated Use `.unwrap()` instead. */
1783
+ removeCatch(): T;
1784
+ }
1785
+ export const ZodCatch: core.$constructor<ZodCatch> = /*@__PURE__*/ core.$constructor("ZodCatch", (inst, def) => {
1786
+ core.$ZodCatch.init(inst, def);
1787
+ ZodType.init(inst, def);
1788
+
1789
+ inst.unwrap = () => inst._zod.def.innerType;
1790
+ inst.removeCatch = inst.unwrap;
1791
+ });
1792
+
1793
+ function _catch<T extends core.SomeType>(
1794
+ innerType: T,
1795
+ catchValue: core.output<T> | ((ctx: core.$ZodCatchCtx) => core.output<T>)
1796
+ ): ZodCatch<T> {
1797
+ return new ZodCatch({
1798
+ type: "catch",
1799
+ innerType: innerType as any as core.$ZodType,
1800
+ catchValue: (typeof catchValue === "function" ? catchValue : () => catchValue) as (
1801
+ ctx: core.$ZodCatchCtx
1802
+ ) => core.output<T>,
1803
+ }) as any;
1804
+ }
1805
+ export { _catch as catch };
1806
+
1807
+ // ZodNaN
1808
+ export interface ZodNaN extends _ZodType<core.$ZodNaNInternals>, core.$ZodNaN {}
1809
+ export const ZodNaN: core.$constructor<ZodNaN> = /*@__PURE__*/ core.$constructor("ZodNaN", (inst, def) => {
1810
+ core.$ZodNaN.init(inst, def);
1811
+ ZodType.init(inst, def);
1812
+ });
1813
+
1814
+ export function nan(params?: string | core.$ZodNaNParams): ZodNaN {
1815
+ return core._nan(ZodNaN, params);
1816
+ }
1817
+
1818
+ // ZodPipe
1819
+ export interface ZodPipe<A extends core.SomeType = core.$ZodType, B extends core.SomeType = core.$ZodType>
1820
+ extends _ZodType<core.$ZodPipeInternals<A, B>>,
1821
+ core.$ZodPipe<A, B> {
1822
+ in: A;
1823
+ out: B;
1824
+ }
1825
+ export const ZodPipe: core.$constructor<ZodPipe> = /*@__PURE__*/ core.$constructor("ZodPipe", (inst, def) => {
1826
+ core.$ZodPipe.init(inst, def);
1827
+ ZodType.init(inst, def);
1828
+
1829
+ inst.in = def.in;
1830
+ inst.out = def.out;
1831
+ });
1832
+
1833
+ export function pipe<
1834
+ const A extends core.SomeType,
1835
+ B extends core.$ZodType<unknown, core.output<A>> = core.$ZodType<unknown, core.output<A>>,
1836
+ >(in_: A, out: B | core.$ZodType<unknown, core.output<A>>): ZodPipe<A, B>;
1837
+ export function pipe(in_: core.SomeType, out: core.SomeType) {
1838
+ return new ZodPipe({
1839
+ type: "pipe",
1840
+ in: in_ as unknown as core.$ZodType,
1841
+ out: out as unknown as core.$ZodType,
1842
+ // ...util.normalizeParams(params),
1843
+ });
1844
+ }
1845
+
1846
+ // ZodReadonly
1847
+ export interface ZodReadonly<T extends core.SomeType = core.$ZodType>
1848
+ extends _ZodType<core.$ZodReadonlyInternals<T>>,
1849
+ core.$ZodReadonly<T> {}
1850
+ export const ZodReadonly: core.$constructor<ZodReadonly> = /*@__PURE__*/ core.$constructor(
1851
+ "ZodReadonly",
1852
+ (inst, def) => {
1853
+ core.$ZodReadonly.init(inst, def);
1854
+ ZodType.init(inst, def);
1855
+ }
1856
+ );
1857
+
1858
+ export function readonly<T extends core.SomeType>(innerType: T): ZodReadonly<T> {
1859
+ return new ZodReadonly({
1860
+ type: "readonly",
1861
+ innerType: innerType as any as core.$ZodType,
1862
+ }) as any;
1863
+ }
1864
+
1865
+ // ZodTemplateLiteral
1866
+ export interface ZodTemplateLiteral<Template extends string = string>
1867
+ extends _ZodType<core.$ZodTemplateLiteralInternals<Template>>,
1868
+ core.$ZodTemplateLiteral<Template> {}
1869
+ export const ZodTemplateLiteral: core.$constructor<ZodTemplateLiteral> = /*@__PURE__*/ core.$constructor(
1870
+ "ZodTemplateLiteral",
1871
+ (inst, def) => {
1872
+ core.$ZodTemplateLiteral.init(inst, def);
1873
+ ZodType.init(inst, def);
1874
+ }
1875
+ );
1876
+
1877
+ export function templateLiteral<const Parts extends core.$ZodTemplateLiteralPart[]>(
1878
+ parts: Parts,
1879
+ params?: string | core.$ZodTemplateLiteralParams
1880
+ ): ZodTemplateLiteral<core.$PartsToTemplateLiteral<Parts>> {
1881
+ return new ZodTemplateLiteral({
1882
+ type: "template_literal",
1883
+ parts,
1884
+ ...util.normalizeParams(params),
1885
+ }) as any;
1886
+ }
1887
+
1888
+ // ZodLazy
1889
+ export interface ZodLazy<T extends core.SomeType = core.$ZodType>
1890
+ extends _ZodType<core.$ZodLazyInternals<T>>,
1891
+ core.$ZodLazy<T> {
1892
+ unwrap(): T;
1893
+ }
1894
+ export const ZodLazy: core.$constructor<ZodLazy> = /*@__PURE__*/ core.$constructor("ZodLazy", (inst, def) => {
1895
+ core.$ZodLazy.init(inst, def);
1896
+ ZodType.init(inst, def);
1897
+
1898
+ inst.unwrap = () => inst._zod.def.getter();
1899
+ });
1900
+
1901
+ export function lazy<T extends core.SomeType>(getter: () => T): ZodLazy<T> {
1902
+ return new ZodLazy({
1903
+ type: "lazy",
1904
+ getter: getter as any,
1905
+ }) as any;
1906
+ }
1907
+
1908
+ // ZodPromise
1909
+ export interface ZodPromise<T extends core.SomeType = core.$ZodType>
1910
+ extends _ZodType<core.$ZodPromiseInternals<T>>,
1911
+ core.$ZodPromise<T> {
1912
+ unwrap(): T;
1913
+ }
1914
+ export const ZodPromise: core.$constructor<ZodPromise> = /*@__PURE__*/ core.$constructor("ZodPromise", (inst, def) => {
1915
+ core.$ZodPromise.init(inst, def);
1916
+ ZodType.init(inst, def);
1917
+
1918
+ inst.unwrap = () => inst._zod.def.innerType;
1919
+ });
1920
+
1921
+ export function promise<T extends core.SomeType>(innerType: T): ZodPromise<T> {
1922
+ return new ZodPromise({
1923
+ type: "promise",
1924
+ innerType: innerType as any as core.$ZodType,
1925
+ }) as any;
1926
+ }
1927
+
1928
+ // ZodCustom
1929
+ export interface ZodCustom<O = unknown, I = unknown>
1930
+ extends _ZodType<core.$ZodCustomInternals<O, I>>,
1931
+ core.$ZodCustom<O, I> {}
1932
+ export const ZodCustom: core.$constructor<ZodCustom> = /*@__PURE__*/ core.$constructor("ZodCustom", (inst, def) => {
1933
+ core.$ZodCustom.init(inst, def);
1934
+ ZodType.init(inst, def);
1935
+ });
1936
+
1937
+ // custom checks
1938
+ export function check<O = unknown>(fn: core.CheckFn<O>, params?: string | core.$ZodCustomParams): core.$ZodCheck<O> {
1939
+ const ch = new core.$ZodCheck({
1940
+ check: "custom",
1941
+ ...util.normalizeParams(params),
1942
+ });
1943
+
1944
+ ch._zod.check = fn;
1945
+ return ch;
1946
+ }
1947
+
1948
+ export function custom<O>(
1949
+ fn?: (data: unknown) => unknown,
1950
+ _params?: string | core.$ZodCustomParams | undefined
1951
+ ): ZodCustom<O, O> {
1952
+ return core._custom(ZodCustom, fn ?? (() => true), _params) as any;
1953
+ }
1954
+
1955
+ export function refine<T>(
1956
+ fn: (arg: NoInfer<T>) => util.MaybeAsync<unknown>,
1957
+ _params: string | core.$ZodCustomParams = {}
1958
+ ): core.$ZodCheck<T> {
1959
+ return core._refine(ZodCustom, fn, _params);
1960
+ }
1961
+
1962
+ // superRefine
1963
+ export function superRefine<T>(
1964
+ fn: (arg: T, payload: RefinementCtx<T>) => void | Promise<void>,
1965
+ params?: string | core.$ZodCustomParams
1966
+ ): core.$ZodCheck<T> {
1967
+ const ch = check<T>((payload) => {
1968
+ (payload as RefinementCtx).addIssue = (issue) => {
1969
+ if (typeof issue === "string") {
1970
+ payload.issues.push(util.issue(issue, payload.value, ch._zod.def));
1971
+ } else {
1972
+ // for Zod 3 backwards compatibility
1973
+ const _issue: any = issue;
1974
+ if (_issue.fatal) _issue.continue = false;
1975
+ _issue.code ??= "custom";
1976
+ _issue.input ??= payload.value;
1977
+ _issue.inst ??= ch;
1978
+ _issue.continue ??= !ch._zod.def.abort;
1979
+ payload.issues.push(util.issue(_issue));
1980
+ }
1981
+ };
1982
+
1983
+ return fn(payload.value, payload as RefinementCtx<T>);
1984
+ }, params);
1985
+ return ch;
1986
+ }
1987
+
1988
+ type ZodInstanceOfParams = core.Params<
1989
+ ZodCustom,
1990
+ core.$ZodIssueCustom,
1991
+ "type" | "check" | "checks" | "fn" | "abort" | "error" | "params" | "path"
1992
+ >;
1993
+ function _instanceof<T extends typeof util.Class>(
1994
+ cls: T,
1995
+ params: ZodInstanceOfParams = {
1996
+ error: `Input not instance of ${cls.name}`,
1997
+ }
1998
+ ): ZodCustom<InstanceType<T>, InstanceType<T>> {
1999
+ const inst = new ZodCustom({
2000
+ type: "custom",
2001
+ check: "custom",
2002
+ fn: (data) => data instanceof cls,
2003
+ abort: true,
2004
+ ...(util.normalizeParams(params) as any),
2005
+ });
2006
+ inst._zod.bag.Class = cls;
2007
+ return inst as any;
2008
+ }
2009
+ export { _instanceof as instanceof };
2010
+
2011
+ // stringbool
2012
+ export const stringbool: (
2013
+ _params?: string | core.$ZodStringBoolParams
2014
+ ) => ZodPipe<ZodPipe<ZodString, ZodTransform<boolean, string>>, ZodBoolean> = (...args) =>
2015
+ core._stringbool(
2016
+ {
2017
+ Pipe: ZodPipe,
2018
+ Boolean: ZodBoolean,
2019
+ String: ZodString,
2020
+ Transform: ZodTransform,
2021
+ },
2022
+ ...args
2023
+ ) as any;
2024
+
2025
+ // json
2026
+ type _ZodJSONSchema = ZodUnion<
2027
+ [ZodString, ZodNumber, ZodBoolean, ZodNull, ZodArray<ZodJSONSchema>, ZodRecord<ZodString, ZodJSONSchema>]
2028
+ >;
2029
+ type _ZodJSONSchemaInternals = _ZodJSONSchema["_zod"];
2030
+
2031
+ export interface ZodJSONSchemaInternals extends _ZodJSONSchemaInternals {
2032
+ output: util.JSONType;
2033
+ input: util.JSONType;
2034
+ }
2035
+ export interface ZodJSONSchema extends _ZodJSONSchema {
2036
+ _zod: ZodJSONSchemaInternals;
2037
+ }
2038
+
2039
+ export function json(params?: string | core.$ZodCustomParams): ZodJSONSchema {
2040
+ const jsonSchema: any = lazy(() => {
2041
+ return union([string(params), number(), boolean(), _null(), array(jsonSchema), record(string(), jsonSchema)]);
2042
+ });
2043
+
2044
+ return jsonSchema;
2045
+ }
2046
+
2047
+ // preprocess
2048
+
2049
+ // /** @deprecated Use `z.pipe()` and `z.transform()` instead. */
2050
+ export function preprocess<A, U extends core.SomeType, B = unknown>(
2051
+ fn: (arg: B, ctx: RefinementCtx) => A,
2052
+ schema: U
2053
+ ): ZodPipe<ZodTransform<A, B>, U> {
2054
+ return pipe(transform(fn as any), schema as any) as any;
2055
+ }