zod 4.0.0-beta.1 → 4.0.0-beta.20250409T222615

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