zod 3.20.6 → 3.21.4

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.
package/lib/locales/en.js CHANGED
@@ -39,7 +39,13 @@ const errorMap = (issue, _ctx) => {
39
39
  break;
40
40
  case ZodError_1.ZodIssueCode.invalid_string:
41
41
  if (typeof issue.validation === "object") {
42
- if ("startsWith" in issue.validation) {
42
+ if ("includes" in issue.validation) {
43
+ message = `Invalid input: must include "${issue.validation.includes}"`;
44
+ if (typeof issue.validation.position === "number") {
45
+ message = `${message} at one or more positions greater than or equal to ${issue.validation.position}`;
46
+ }
47
+ }
48
+ else if ("startsWith" in issue.validation) {
43
49
  message = `Invalid input: must start with "${issue.validation.startsWith}"`;
44
50
  }
45
51
  else if ("endsWith" in issue.validation) {
@@ -72,7 +78,7 @@ const errorMap = (issue, _ctx) => {
72
78
  ? `exactly equal to `
73
79
  : issue.inclusive
74
80
  ? `greater than or equal to `
75
- : `greater than `}${new Date(issue.minimum)}`;
81
+ : `greater than `}${new Date(Number(issue.minimum))}`;
76
82
  else
77
83
  message = "Invalid input";
78
84
  break;
@@ -87,12 +93,18 @@ const errorMap = (issue, _ctx) => {
87
93
  : issue.inclusive
88
94
  ? `less than or equal to`
89
95
  : `less than`} ${issue.maximum}`;
96
+ else if (issue.type === "bigint")
97
+ message = `BigInt must be ${issue.exact
98
+ ? `exactly`
99
+ : issue.inclusive
100
+ ? `less than or equal to`
101
+ : `less than`} ${issue.maximum}`;
90
102
  else if (issue.type === "date")
91
103
  message = `Date must be ${issue.exact
92
104
  ? `exactly`
93
105
  : issue.inclusive
94
106
  ? `smaller than or equal to`
95
- : `smaller than`} ${new Date(issue.maximum)}`;
107
+ : `smaller than`} ${new Date(Number(issue.maximum))}`;
96
108
  else
97
109
  message = "Invalid input";
98
110
  break;
package/lib/types.d.ts CHANGED
@@ -3,7 +3,7 @@ import { errorUtil } from "./helpers/errorUtil";
3
3
  import { AsyncParseReturnType, ParseContext, ParseInput, ParseParams, ParseReturnType, ParseStatus, SyncParseReturnType } from "./helpers/parseUtil";
4
4
  import { partialUtil } from "./helpers/partialUtil";
5
5
  import { Primitive } from "./helpers/typeAliases";
6
- import { util } from "./helpers/util";
6
+ import { objectUtil, util } from "./helpers/util";
7
7
  import { IssueData, StringValidation, ZodCustomIssue, ZodError, ZodErrorMap } from "./ZodError";
8
8
  export declare type RefinementCtx = {
9
9
  addIssue: (arg: IssueData) => void;
@@ -60,7 +60,6 @@ export declare abstract class ZodType<Output = any, Def extends ZodTypeDef = Zod
60
60
  safeParse(data: unknown, params?: Partial<ParseParams>): SafeParseReturnType<Input, Output>;
61
61
  parseAsync(data: unknown, params?: Partial<ParseParams>): Promise<Output>;
62
62
  safeParseAsync(data: unknown, params?: Partial<ParseParams>): Promise<SafeParseReturnType<Input, Output>>;
63
- /** Alias of safeParseAsync */
64
63
  spa: (data: unknown, params?: Partial<ParseParams> | undefined) => Promise<SafeParseReturnType<Input, Output>>;
65
64
  refine<RefinedOutput extends Output>(check: (arg: Output) => arg is RefinedOutput, message?: string | CustomErrorParams | ((arg: Output) => CustomErrorParams)): ZodEffects<this, RefinedOutput, Input>;
66
65
  refine(check: (arg: Output) => unknown | Promise<unknown>, message?: string | CustomErrorParams | ((arg: Output) => CustomErrorParams)): ZodEffects<this, Output, Input>;
@@ -82,12 +81,16 @@ export declare abstract class ZodType<Output = any, Def extends ZodTypeDef = Zod
82
81
  default(def: () => util.noUndefined<Input>): ZodDefault<this>;
83
82
  brand<B extends string | number | symbol>(brand?: B): ZodBranded<this, B>;
84
83
  catch(def: Output): ZodCatch<this>;
85
- catch(def: () => Output): ZodCatch<this>;
84
+ catch(def: (ctx: {
85
+ error: ZodError;
86
+ input: Input;
87
+ }) => Output): ZodCatch<this>;
86
88
  describe(description: string): this;
87
89
  pipe<T extends ZodTypeAny>(target: T): ZodPipeline<this, T>;
88
90
  isOptional(): boolean;
89
91
  isNullable(): boolean;
90
92
  }
93
+ export declare type IpVersion = "v4" | "v6";
91
94
  export declare type ZodStringCheck = {
92
95
  kind: "min";
93
96
  value: number;
@@ -106,15 +109,26 @@ export declare type ZodStringCheck = {
106
109
  } | {
107
110
  kind: "url";
108
111
  message?: string;
112
+ } | {
113
+ kind: "emoji";
114
+ message?: string;
109
115
  } | {
110
116
  kind: "uuid";
111
117
  message?: string;
112
118
  } | {
113
119
  kind: "cuid";
114
120
  message?: string;
121
+ } | {
122
+ kind: "includes";
123
+ value: string;
124
+ position?: number;
125
+ message?: string;
115
126
  } | {
116
127
  kind: "cuid2";
117
128
  message?: string;
129
+ } | {
130
+ kind: "ulid";
131
+ message?: string;
118
132
  } | {
119
133
  kind: "startsWith";
120
134
  value: string;
@@ -130,11 +144,21 @@ export declare type ZodStringCheck = {
130
144
  } | {
131
145
  kind: "trim";
132
146
  message?: string;
147
+ } | {
148
+ kind: "toLowerCase";
149
+ message?: string;
150
+ } | {
151
+ kind: "toUpperCase";
152
+ message?: string;
133
153
  } | {
134
154
  kind: "datetime";
135
155
  offset: boolean;
136
156
  precision: number | null;
137
157
  message?: string;
158
+ } | {
159
+ kind: "ip";
160
+ version?: IpVersion;
161
+ message?: string;
138
162
  };
139
163
  export interface ZodStringDef extends ZodTypeDef {
140
164
  checks: ZodStringCheck[];
@@ -147,32 +171,43 @@ export declare class ZodString extends ZodType<string, ZodStringDef> {
147
171
  _addCheck(check: ZodStringCheck): ZodString;
148
172
  email(message?: errorUtil.ErrMessage): ZodString;
149
173
  url(message?: errorUtil.ErrMessage): ZodString;
174
+ emoji(message?: errorUtil.ErrMessage): ZodString;
150
175
  uuid(message?: errorUtil.ErrMessage): ZodString;
151
176
  cuid(message?: errorUtil.ErrMessage): ZodString;
152
177
  cuid2(message?: errorUtil.ErrMessage): ZodString;
178
+ ulid(message?: errorUtil.ErrMessage): ZodString;
179
+ ip(options?: string | {
180
+ version?: "v4" | "v6";
181
+ message?: string;
182
+ }): ZodString;
153
183
  datetime(options?: string | {
154
184
  message?: string | undefined;
155
185
  precision?: number | null;
156
186
  offset?: boolean;
157
187
  }): ZodString;
158
188
  regex(regex: RegExp, message?: errorUtil.ErrMessage): ZodString;
189
+ includes(value: string, options?: {
190
+ message?: string;
191
+ position?: number;
192
+ }): ZodString;
159
193
  startsWith(value: string, message?: errorUtil.ErrMessage): ZodString;
160
194
  endsWith(value: string, message?: errorUtil.ErrMessage): ZodString;
161
195
  min(minLength: number, message?: errorUtil.ErrMessage): ZodString;
162
196
  max(maxLength: number, message?: errorUtil.ErrMessage): ZodString;
163
197
  length(len: number, message?: errorUtil.ErrMessage): ZodString;
164
- /**
165
- * @deprecated Use z.string().min(1) instead.
166
- * @see {@link ZodString.min}
167
- */
168
198
  nonempty: (message?: errorUtil.ErrMessage | undefined) => ZodString;
169
199
  trim: () => ZodString;
200
+ toLowerCase: () => ZodString;
201
+ toUpperCase: () => ZodString;
170
202
  get isDatetime(): boolean;
171
203
  get isEmail(): boolean;
172
204
  get isURL(): boolean;
205
+ get isEmoji(): boolean;
173
206
  get isUUID(): boolean;
174
207
  get isCUID(): boolean;
175
208
  get isCUID2(): boolean;
209
+ get isULID(): boolean;
210
+ get isIP(): boolean;
176
211
  get minLength(): number | null;
177
212
  get maxLength(): number | null;
178
213
  static create: (params?: ({
@@ -234,14 +269,31 @@ export declare class ZodNumber extends ZodType<number, ZodNumberDef> {
234
269
  nonpositive(message?: errorUtil.ErrMessage): ZodNumber;
235
270
  nonnegative(message?: errorUtil.ErrMessage): ZodNumber;
236
271
  multipleOf(value: number, message?: errorUtil.ErrMessage): ZodNumber;
237
- finite(message?: errorUtil.ErrMessage): ZodNumber;
238
272
  step: (value: number, message?: errorUtil.ErrMessage | undefined) => ZodNumber;
273
+ finite(message?: errorUtil.ErrMessage): ZodNumber;
274
+ safe(message?: errorUtil.ErrMessage): ZodNumber;
239
275
  get minValue(): number | null;
240
276
  get maxValue(): number | null;
241
277
  get isInt(): boolean;
242
278
  get isFinite(): boolean;
243
279
  }
280
+ export declare type ZodBigIntCheck = {
281
+ kind: "min";
282
+ value: bigint;
283
+ inclusive: boolean;
284
+ message?: string;
285
+ } | {
286
+ kind: "max";
287
+ value: bigint;
288
+ inclusive: boolean;
289
+ message?: string;
290
+ } | {
291
+ kind: "multipleOf";
292
+ value: bigint;
293
+ message?: string;
294
+ };
244
295
  export interface ZodBigIntDef extends ZodTypeDef {
296
+ checks: ZodBigIntCheck[];
245
297
  typeName: ZodFirstPartyTypeKind.ZodBigInt;
246
298
  coerce: boolean;
247
299
  }
@@ -255,6 +307,21 @@ export declare class ZodBigInt extends ZodType<bigint, ZodBigIntDef> {
255
307
  } & {
256
308
  coerce?: boolean | undefined;
257
309
  }) | undefined) => ZodBigInt;
310
+ gte(value: bigint, message?: errorUtil.ErrMessage): ZodBigInt;
311
+ min: (value: bigint, message?: errorUtil.ErrMessage | undefined) => ZodBigInt;
312
+ gt(value: bigint, message?: errorUtil.ErrMessage): ZodBigInt;
313
+ lte(value: bigint, message?: errorUtil.ErrMessage): ZodBigInt;
314
+ max: (value: bigint, message?: errorUtil.ErrMessage | undefined) => ZodBigInt;
315
+ lt(value: bigint, message?: errorUtil.ErrMessage): ZodBigInt;
316
+ protected setLimit(kind: "min" | "max", value: bigint, inclusive: boolean, message?: string): ZodBigInt;
317
+ _addCheck(check: ZodBigIntCheck): ZodBigInt;
318
+ positive(message?: errorUtil.ErrMessage): ZodBigInt;
319
+ negative(message?: errorUtil.ErrMessage): ZodBigInt;
320
+ nonpositive(message?: errorUtil.ErrMessage): ZodBigInt;
321
+ nonnegative(message?: errorUtil.ErrMessage): ZodBigInt;
322
+ multipleOf(value: bigint, message?: errorUtil.ErrMessage): ZodBigInt;
323
+ get minValue(): bigint | null;
324
+ get maxValue(): bigint | null;
258
325
  }
259
326
  export interface ZodBooleanDef extends ZodTypeDef {
260
327
  typeName: ZodFirstPartyTypeKind.ZodBoolean;
@@ -381,31 +448,6 @@ export declare class ZodArray<T extends ZodTypeAny, Cardinality extends ArrayCar
381
448
  static create: <T_1 extends ZodTypeAny>(schema: T_1, params?: RawCreateParams) => ZodArray<T_1, "many">;
382
449
  }
383
450
  export declare type ZodNonEmptyArray<T extends ZodTypeAny> = ZodArray<T, "atleastone">;
384
- export declare namespace objectUtil {
385
- export type MergeShapes<U extends ZodRawShape, V extends ZodRawShape> = {
386
- [k in Exclude<keyof U, keyof V>]: U[k];
387
- } & V;
388
- type optionalKeys<T extends object> = {
389
- [k in keyof T]: undefined extends T[k] ? k : never;
390
- }[keyof T];
391
- type requiredKeys<T extends object> = {
392
- [k in keyof T]: undefined extends T[k] ? never : k;
393
- }[keyof T];
394
- export type addQuestionMarks<T extends object> = Partial<Pick<T, optionalKeys<T>>> & Pick<T, requiredKeys<T>>;
395
- export type identity<T> = T;
396
- export type flatten<T extends object> = identity<{
397
- [k in keyof T]: T[k];
398
- }>;
399
- export type noNeverKeys<T extends ZodRawShape> = {
400
- [k in keyof T]: [T[k]] extends [never] ? never : k;
401
- }[keyof T];
402
- export type noNever<T extends ZodRawShape> = identity<{
403
- [k in noNeverKeys<T>]: k extends keyof T ? T[k] : never;
404
- }>;
405
- export const mergeShapes: <U extends ZodRawShape, T extends ZodRawShape>(first: U, second: T) => T & U;
406
- export {};
407
- }
408
- export declare type extendShape<A, B> = util.flatten<Omit<A, keyof B> & B>;
409
451
  export declare type UnknownKeysParam = "passthrough" | "strict" | "strip";
410
452
  export interface ZodObjectDef<T extends ZodRawShape = ZodRawShape, UnknownKeys extends UnknownKeysParam = UnknownKeysParam, Catchall extends ZodTypeAny = ZodTypeAny> extends ZodTypeDef {
411
453
  typeName: ZodFirstPartyTypeKind.ZodObject;
@@ -416,28 +458,29 @@ export interface ZodObjectDef<T extends ZodRawShape = ZodRawShape, UnknownKeys e
416
458
  export declare type mergeTypes<A, B> = {
417
459
  [k in keyof A | keyof B]: k extends keyof B ? B[k] : k extends keyof A ? A[k] : never;
418
460
  };
419
- export declare type processType<T extends object> = util.flatten<objectUtil.addQuestionMarks<T>>;
420
- export declare type baseObjectOutputType<Shape extends ZodRawShape> = objectUtil.addQuestionMarks<{
461
+ export declare type objectOutputType<Shape extends ZodRawShape, Catchall extends ZodTypeAny, UnknownKeys extends UnknownKeysParam = UnknownKeysParam> = objectUtil.flatten<objectUtil.addQuestionMarks<baseObjectOutputType<Shape>>> & CatchallOutput<Catchall> & PassthroughType<UnknownKeys>;
462
+ export declare type baseObjectOutputType<Shape extends ZodRawShape> = {
421
463
  [k in keyof Shape]: Shape[k]["_output"];
422
- }>;
423
- export declare type objectOutputType<Shape extends ZodRawShape, Catchall extends ZodTypeAny> = ZodTypeAny extends Catchall ? objectUtil.flatten<baseObjectOutputType<Shape>> : objectUtil.flatten<baseObjectOutputType<Shape> & {
424
- [k: string]: Catchall["_output"];
425
- }>;
426
- export declare type baseObjectInputType<Shape extends ZodRawShape> = objectUtil.flatten<objectUtil.addQuestionMarks<{
464
+ };
465
+ export declare type objectInputType<Shape extends ZodRawShape, Catchall extends ZodTypeAny, UnknownKeys extends UnknownKeysParam = UnknownKeysParam> = objectUtil.flatten<baseObjectInputType<Shape>> & CatchallInput<Catchall> & PassthroughType<UnknownKeys>;
466
+ export declare type baseObjectInputType<Shape extends ZodRawShape> = objectUtil.addQuestionMarks<{
427
467
  [k in keyof Shape]: Shape[k]["_input"];
428
- }>>;
429
- export declare type objectInputType<Shape extends ZodRawShape, Catchall extends ZodTypeAny> = ZodTypeAny extends Catchall ? baseObjectInputType<Shape> : objectUtil.flatten<baseObjectInputType<Shape> & {
430
- [k: string]: Catchall["_input"];
431
468
  }>;
469
+ export declare type CatchallOutput<T extends ZodTypeAny> = ZodTypeAny extends T ? unknown : {
470
+ [k: string]: T["_output"];
471
+ };
472
+ export declare type CatchallInput<T extends ZodTypeAny> = ZodTypeAny extends T ? unknown : {
473
+ [k: string]: T["_input"];
474
+ };
475
+ export declare type PassthroughType<T extends UnknownKeysParam> = T extends "passthrough" ? {
476
+ [k: string]: unknown;
477
+ } : unknown;
432
478
  export declare type deoptional<T extends ZodTypeAny> = T extends ZodOptional<infer U> ? deoptional<U> : T extends ZodNullable<infer U> ? ZodNullable<deoptional<U>> : T;
433
479
  export declare type SomeZodObject = ZodObject<ZodRawShape, UnknownKeysParam, ZodTypeAny>;
434
- export declare type objectKeyMask<Obj> = {
435
- [k in keyof Obj]?: true;
436
- };
437
480
  export declare type noUnrecognized<Obj extends object, Shape extends object> = {
438
481
  [k in keyof Obj]: k extends keyof Shape ? Obj[k] : never;
439
482
  };
440
- export declare class ZodObject<T extends ZodRawShape, UnknownKeys extends UnknownKeysParam = UnknownKeysParam, Catchall extends ZodTypeAny = ZodTypeAny, Output = objectOutputType<T, Catchall>, Input = objectInputType<T, Catchall>> extends ZodType<Output, ZodObjectDef<T, UnknownKeys, Catchall>, Input> {
483
+ export declare class ZodObject<T extends ZodRawShape, UnknownKeys extends UnknownKeysParam = UnknownKeysParam, Catchall extends ZodTypeAny = ZodTypeAny, Output = objectOutputType<T, Catchall, UnknownKeys>, Input = objectInputType<T, Catchall, UnknownKeys>> extends ZodType<Output, ZodObjectDef<T, UnknownKeys, Catchall>, Input> {
441
484
  private _cached;
442
485
  _getCached(): {
443
486
  shape: T;
@@ -448,45 +491,41 @@ export declare class ZodObject<T extends ZodRawShape, UnknownKeys extends Unknow
448
491
  strict(message?: errorUtil.ErrMessage): ZodObject<T, "strict", Catchall>;
449
492
  strip(): ZodObject<T, "strip", Catchall>;
450
493
  passthrough(): ZodObject<T, "passthrough", Catchall>;
451
- /**
452
- * @deprecated In most cases, this is no longer needed - unknown properties are now silently stripped.
453
- * If you want to pass through unknown properties, use `.passthrough()` instead.
454
- */
455
494
  nonstrict: () => ZodObject<T, "passthrough", Catchall>;
456
- extend<Augmentation extends ZodRawShape>(augmentation: Augmentation): ZodObject<extendShape<T, Augmentation>, UnknownKeys, Catchall>;
457
- /**
458
- * @deprecated Use `.extend` instead
459
- * */
460
- augment: <Augmentation extends ZodRawShape>(augmentation: Augmentation) => ZodObject<{ [k in keyof (Omit<T, keyof Augmentation> & Augmentation)]: (Omit<T, keyof Augmentation> & Augmentation)[k]; }, UnknownKeys, Catchall, objectOutputType<{ [k in keyof (Omit<T, keyof Augmentation> & Augmentation)]: (Omit<T, keyof Augmentation> & Augmentation)[k]; }, Catchall>, objectInputType<{ [k in keyof (Omit<T, keyof Augmentation> & Augmentation)]: (Omit<T, keyof Augmentation> & Augmentation)[k]; }, Catchall>>;
461
- /**
462
- * Prior to zod@1.0.12 there was a bug in the
463
- * inferred type of merged objects. Please
464
- * upgrade if you are experiencing issues.
465
- */
466
- merge<Incoming extends AnyZodObject, Augmentation extends Incoming["shape"]>(merging: Incoming): ZodObject<extendShape<T, Augmentation>, Incoming["_def"]["unknownKeys"], Incoming["_def"]["catchall"]>;
495
+ extend<Augmentation extends ZodRawShape>(augmentation: Augmentation): ZodObject<objectUtil.extendShape<T, Augmentation>, UnknownKeys, Catchall>;
496
+ augment: <Augmentation extends ZodRawShape>(augmentation: Augmentation) => ZodObject<{ [k in keyof (Omit<T, keyof Augmentation> & Augmentation)]: (Omit<T, keyof Augmentation> & Augmentation)[k]; }, UnknownKeys, Catchall, objectOutputType<{ [k in keyof (Omit<T, keyof Augmentation> & Augmentation)]: (Omit<T, keyof Augmentation> & Augmentation)[k]; }, Catchall, UnknownKeys>, objectInputType<{ [k in keyof (Omit<T, keyof Augmentation> & Augmentation)]: (Omit<T, keyof Augmentation> & Augmentation)[k]; }, Catchall, UnknownKeys>>;
497
+ merge<Incoming extends AnyZodObject, Augmentation extends Incoming["shape"]>(merging: Incoming): ZodObject<objectUtil.extendShape<T, Augmentation>, Incoming["_def"]["unknownKeys"], Incoming["_def"]["catchall"]>;
467
498
  setKey<Key extends string, Schema extends ZodTypeAny>(key: Key, schema: Schema): ZodObject<T & {
468
499
  [k in Key]: Schema;
469
500
  }, UnknownKeys, Catchall>;
470
501
  catchall<Index extends ZodTypeAny>(index: Index): ZodObject<T, UnknownKeys, Index>;
471
- pick<Mask extends objectKeyMask<T>>(mask: noUnrecognized<Mask, T>): ZodObject<Pick<T, Extract<keyof T, keyof Mask>>, UnknownKeys, Catchall>;
472
- omit<Mask extends objectKeyMask<T>>(mask: noUnrecognized<Mask, objectKeyMask<T>>): ZodObject<Omit<T, keyof Mask>, UnknownKeys, Catchall>;
502
+ pick<Mask extends {
503
+ [k in keyof T]?: true;
504
+ }>(mask: Mask): ZodObject<Pick<T, Extract<keyof T, keyof Mask>>, UnknownKeys, Catchall>;
505
+ omit<Mask extends {
506
+ [k in keyof T]?: true;
507
+ }>(mask: Mask): ZodObject<Omit<T, keyof Mask>, UnknownKeys, Catchall>;
473
508
  deepPartial(): partialUtil.DeepPartial<this>;
474
509
  partial(): ZodObject<{
475
510
  [k in keyof T]: ZodOptional<T[k]>;
476
511
  }, UnknownKeys, Catchall>;
477
- partial<Mask extends objectKeyMask<T>>(mask: noUnrecognized<Mask, objectKeyMask<T>>): ZodObject<objectUtil.noNever<{
512
+ partial<Mask extends {
513
+ [k in keyof T]?: true;
514
+ }>(mask: Mask): ZodObject<objectUtil.noNever<{
478
515
  [k in keyof T]: k extends keyof Mask ? ZodOptional<T[k]> : T[k];
479
516
  }>, UnknownKeys, Catchall>;
480
517
  required(): ZodObject<{
481
518
  [k in keyof T]: deoptional<T[k]>;
482
519
  }, UnknownKeys, Catchall>;
483
- required<Mask extends objectKeyMask<T>>(mask: noUnrecognized<Mask, objectKeyMask<T>>): ZodObject<objectUtil.noNever<{
520
+ required<Mask extends {
521
+ [k in keyof T]?: true;
522
+ }>(mask: Mask): ZodObject<objectUtil.noNever<{
484
523
  [k in keyof T]: k extends keyof Mask ? deoptional<T[k]> : T[k];
485
524
  }>, UnknownKeys, Catchall>;
486
525
  keyof(): ZodEnum<enumUtil.UnionToTupleString<keyof T>>;
487
- static create: <T_1 extends ZodRawShape>(shape: T_1, params?: RawCreateParams) => ZodObject<T_1, "strip", ZodTypeAny, { [k in keyof baseObjectOutputType<T_1>]: baseObjectOutputType<T_1>[k]; }, { [k_2 in keyof objectUtil.addQuestionMarks<{ [k_1 in keyof T_1]: T_1[k_1]["_input"]; }>]: objectUtil.addQuestionMarks<{ [k_1 in keyof T_1]: T_1[k_1]["_input"]; }>[k_2]; }>;
488
- static strictCreate: <T_1 extends ZodRawShape>(shape: T_1, params?: RawCreateParams) => ZodObject<T_1, "strict", ZodTypeAny, { [k in keyof baseObjectOutputType<T_1>]: baseObjectOutputType<T_1>[k]; }, { [k_2 in keyof objectUtil.addQuestionMarks<{ [k_1 in keyof T_1]: T_1[k_1]["_input"]; }>]: objectUtil.addQuestionMarks<{ [k_1 in keyof T_1]: T_1[k_1]["_input"]; }>[k_2]; }>;
489
- static lazycreate: <T_1 extends ZodRawShape>(shape: () => T_1, params?: RawCreateParams) => ZodObject<T_1, "strip", ZodTypeAny, { [k in keyof baseObjectOutputType<T_1>]: baseObjectOutputType<T_1>[k]; }, { [k_2 in keyof objectUtil.addQuestionMarks<{ [k_1 in keyof T_1]: T_1[k_1]["_input"]; }>]: objectUtil.addQuestionMarks<{ [k_1 in keyof T_1]: T_1[k_1]["_input"]; }>[k_2]; }>;
526
+ static create: <T_1 extends ZodRawShape>(shape: T_1, params?: RawCreateParams) => ZodObject<T_1, "strip", ZodTypeAny, { [k_1 in keyof objectUtil.addQuestionMarks<baseObjectOutputType<T_1>, { [k in keyof baseObjectOutputType<T_1>]: undefined extends baseObjectOutputType<T_1>[k] ? never : k; }[keyof T_1]>]: objectUtil.addQuestionMarks<baseObjectOutputType<T_1>, { [k in keyof baseObjectOutputType<T_1>]: undefined extends baseObjectOutputType<T_1>[k] ? never : k; }[keyof T_1]>[k_1]; }, { [k_2 in keyof baseObjectInputType<T_1>]: baseObjectInputType<T_1>[k_2]; }>;
527
+ static strictCreate: <T_1 extends ZodRawShape>(shape: T_1, params?: RawCreateParams) => ZodObject<T_1, "strict", ZodTypeAny, { [k_1 in keyof objectUtil.addQuestionMarks<baseObjectOutputType<T_1>, { [k in keyof baseObjectOutputType<T_1>]: undefined extends baseObjectOutputType<T_1>[k] ? never : k; }[keyof T_1]>]: objectUtil.addQuestionMarks<baseObjectOutputType<T_1>, { [k in keyof baseObjectOutputType<T_1>]: undefined extends baseObjectOutputType<T_1>[k] ? never : k; }[keyof T_1]>[k_1]; }, { [k_2 in keyof baseObjectInputType<T_1>]: baseObjectInputType<T_1>[k_2]; }>;
528
+ static lazycreate: <T_1 extends ZodRawShape>(shape: () => T_1, params?: RawCreateParams) => ZodObject<T_1, "strip", ZodTypeAny, { [k_1 in keyof objectUtil.addQuestionMarks<baseObjectOutputType<T_1>, { [k in keyof baseObjectOutputType<T_1>]: undefined extends baseObjectOutputType<T_1>[k] ? never : k; }[keyof T_1]>]: objectUtil.addQuestionMarks<baseObjectOutputType<T_1>, { [k in keyof baseObjectOutputType<T_1>]: undefined extends baseObjectOutputType<T_1>[k] ? never : k; }[keyof T_1]>[k_1]; }, { [k_2 in keyof baseObjectInputType<T_1>]: baseObjectInputType<T_1>[k_2]; }>;
490
529
  }
491
530
  export declare type AnyZodObject = ZodObject<any, any, any>;
492
531
  export declare type ZodUnionOptions = Readonly<[ZodTypeAny, ...ZodTypeAny[]]>;
@@ -517,14 +556,6 @@ export declare class ZodDiscriminatedUnion<Discriminator extends string, Options
517
556
  get discriminator(): Discriminator;
518
557
  get options(): Options;
519
558
  get optionsMap(): Map<Primitive, ZodDiscriminatedUnionOption<any>>;
520
- /**
521
- * The constructor of the discriminated union schema. Its behaviour is very similar to that of the normal z.union() constructor.
522
- * However, it only allows a union of objects, all of which need to share a discriminator property. This property must
523
- * have a different value for each object in the union.
524
- * @param discriminator the name of the discriminator property
525
- * @param types an array of object schemas
526
- * @param params
527
- */
528
559
  static create<Discriminator extends string, Types extends [
529
560
  ZodDiscriminatedUnionOption<Discriminator>,
530
561
  ...ZodDiscriminatedUnionOption<Discriminator>[]
@@ -572,7 +603,7 @@ export interface ZodRecordDef<Key extends KeySchema = ZodString, Value extends Z
572
603
  export declare type KeySchema = ZodType<string | number | symbol, any, any>;
573
604
  export declare type RecordType<K extends string | number | symbol, V> = [
574
605
  string
575
- ] extends [K] ? Record<K, V> : [number] extends [K] ? Record<K, V> : [symbol] extends [K] ? Record<K, V> : Partial<Record<K, V>>;
606
+ ] extends [K] ? Record<K, V> : [number] extends [K] ? Record<K, V> : [symbol] extends [K] ? Record<K, V> : [BRAND<string | number | symbol>] extends [K] ? Record<K, V> : Partial<Record<K, V>>;
576
607
  export declare class ZodRecord<Key extends KeySchema = ZodString, Value extends ZodTypeAny = ZodTypeAny> extends ZodType<RecordType<Key["_output"], Value["_output"]>, ZodRecordDef<Key, Value>, RecordType<Key["_input"], Value["_input"]>> {
577
608
  get keySchema(): Key;
578
609
  get valueSchema(): Value;
@@ -621,7 +652,7 @@ export declare class ZodFunction<Args extends ZodTuple<any, any>, Returns extend
621
652
  _parse(input: ParseInput): ParseReturnType<any>;
622
653
  parameters(): Args;
623
654
  returnType(): Returns;
624
- args<Items extends Parameters<typeof ZodTuple["create"]>[0]>(...items: Items): ZodFunction<ZodTuple<Items, ZodUnknown>, Returns>;
655
+ args<Items extends Parameters<(typeof ZodTuple)["create"]>[0]>(...items: Items): ZodFunction<ZodTuple<Items, ZodUnknown>, Returns>;
625
656
  returns<NewReturnType extends ZodType<any, any>>(returnType: NewReturnType): ZodFunction<Args, NewReturnType>;
626
657
  implement<F extends InnerTypeOfFunction<Args, Returns>>(func: F): ReturnType<F> extends Returns["_output"] ? (...args: Args["_input"]) => ReturnType<F> : OuterTypeOfFunction<Args, Returns>;
627
658
  strictImplement(func: InnerTypeOfFunction<Args, Returns>): InnerTypeOfFunction<Args, Returns>;
@@ -763,9 +794,12 @@ export declare class ZodDefault<T extends ZodTypeAny> extends ZodType<util.noUnd
763
794
  default: T_1["_input"] | (() => util.noUndefined<T_1["_input"]>);
764
795
  }) => ZodDefault<T_1>;
765
796
  }
766
- export interface ZodCatchDef<T extends ZodTypeAny = ZodTypeAny, C extends T["_input"] = T["_input"]> extends ZodTypeDef {
797
+ export interface ZodCatchDef<T extends ZodTypeAny = ZodTypeAny> extends ZodTypeDef {
767
798
  innerType: T;
768
- catchValue: () => C;
799
+ catchValue: (ctx: {
800
+ error: ZodError;
801
+ input: unknown;
802
+ }) => T["_input"];
769
803
  typeName: ZodFirstPartyTypeKind.ZodCatch;
770
804
  }
771
805
  export declare class ZodCatch<T extends ZodTypeAny> extends ZodType<T["_output"], ZodCatchDef<T>, unknown> {
@@ -810,10 +844,13 @@ export declare class ZodPipeline<A extends ZodTypeAny, B extends ZodTypeAny> ext
810
844
  _parse(input: ParseInput): ParseReturnType<any>;
811
845
  static create<A extends ZodTypeAny, B extends ZodTypeAny>(a: A, b: B): ZodPipeline<A, B>;
812
846
  }
813
- export declare const custom: <T>(check?: ((data: unknown) => any) | undefined, params?: Parameters<ZodTypeAny["refine"]>[1], fatal?: boolean | undefined) => ZodType<T, ZodTypeDef, T>;
847
+ declare type CustomParams = CustomErrorParams & {
848
+ fatal?: boolean;
849
+ };
850
+ export declare const custom: <T>(check?: ((data: unknown) => any) | undefined, params?: string | CustomParams | ((input: any) => CustomParams), fatal?: boolean | undefined) => ZodType<T, ZodTypeDef, T>;
814
851
  export { ZodType as Schema, ZodType as ZodSchema };
815
852
  export declare const late: {
816
- object: <T extends ZodRawShape>(shape: () => T, params?: RawCreateParams) => ZodObject<T, "strip", ZodTypeAny, { [k in keyof baseObjectOutputType<T>]: baseObjectOutputType<T>[k]; }, { [k_2 in keyof objectUtil.addQuestionMarks<{ [k_1 in keyof T]: T[k_1]["_input"]; }>]: objectUtil.addQuestionMarks<{ [k_1 in keyof T]: T[k_1]["_input"]; }>[k_2]; }>;
853
+ object: <T extends ZodRawShape>(shape: () => T, params?: RawCreateParams) => ZodObject<T, "strip", ZodTypeAny, { [k_1 in keyof objectUtil.addQuestionMarks<baseObjectOutputType<T>, { [k in keyof baseObjectOutputType<T>]: undefined extends baseObjectOutputType<T>[k] ? never : k; }[keyof T]>]: objectUtil.addQuestionMarks<baseObjectOutputType<T>, { [k in keyof baseObjectOutputType<T>]: undefined extends baseObjectOutputType<T>[k] ? never : k; }[keyof T]>[k_1]; }, { [k_2 in keyof baseObjectInputType<T>]: baseObjectInputType<T>[k_2]; }>;
817
854
  };
818
855
  export declare enum ZodFirstPartyTypeKind {
819
856
  ZodString = "ZodString",
@@ -856,7 +893,7 @@ export declare type ZodFirstPartySchemaTypes = ZodString | ZodNumber | ZodNaN |
856
893
  declare abstract class Class {
857
894
  constructor(..._: any[]);
858
895
  }
859
- declare const instanceOfType: <T extends typeof Class>(cls: T, params?: Parameters<ZodTypeAny["refine"]>[1]) => ZodType<InstanceType<T>, ZodTypeDef, InstanceType<T>>;
896
+ declare const instanceOfType: <T extends typeof Class>(cls: T, params?: CustomParams) => ZodType<InstanceType<T>, ZodTypeDef, InstanceType<T>>;
860
897
  declare const stringType: (params?: ({
861
898
  errorMap?: ZodErrorMap | undefined;
862
899
  invalid_type_error?: string | undefined;
@@ -906,8 +943,8 @@ declare const unknownType: (params?: RawCreateParams) => ZodUnknown;
906
943
  declare const neverType: (params?: RawCreateParams) => ZodNever;
907
944
  declare const voidType: (params?: RawCreateParams) => ZodVoid;
908
945
  declare const arrayType: <T extends ZodTypeAny>(schema: T, params?: RawCreateParams) => ZodArray<T, "many">;
909
- declare const objectType: <T extends ZodRawShape>(shape: T, params?: RawCreateParams) => ZodObject<T, "strip", ZodTypeAny, { [k in keyof baseObjectOutputType<T>]: baseObjectOutputType<T>[k]; }, { [k_2 in keyof objectUtil.addQuestionMarks<{ [k_1 in keyof T]: T[k_1]["_input"]; }>]: objectUtil.addQuestionMarks<{ [k_1 in keyof T]: T[k_1]["_input"]; }>[k_2]; }>;
910
- declare const strictObjectType: <T extends ZodRawShape>(shape: T, params?: RawCreateParams) => ZodObject<T, "strict", ZodTypeAny, { [k in keyof baseObjectOutputType<T>]: baseObjectOutputType<T>[k]; }, { [k_2 in keyof objectUtil.addQuestionMarks<{ [k_1 in keyof T]: T[k_1]["_input"]; }>]: objectUtil.addQuestionMarks<{ [k_1 in keyof T]: T[k_1]["_input"]; }>[k_2]; }>;
946
+ declare const objectType: <T extends ZodRawShape>(shape: T, params?: RawCreateParams) => ZodObject<T, "strip", ZodTypeAny, { [k_1 in keyof objectUtil.addQuestionMarks<baseObjectOutputType<T>, { [k in keyof baseObjectOutputType<T>]: undefined extends baseObjectOutputType<T>[k] ? never : k; }[keyof T]>]: objectUtil.addQuestionMarks<baseObjectOutputType<T>, { [k in keyof baseObjectOutputType<T>]: undefined extends baseObjectOutputType<T>[k] ? never : k; }[keyof T]>[k_1]; }, { [k_2 in keyof baseObjectInputType<T>]: baseObjectInputType<T>[k_2]; }>;
947
+ declare const strictObjectType: <T extends ZodRawShape>(shape: T, params?: RawCreateParams) => ZodObject<T, "strict", ZodTypeAny, { [k_1 in keyof objectUtil.addQuestionMarks<baseObjectOutputType<T>, { [k in keyof baseObjectOutputType<T>]: undefined extends baseObjectOutputType<T>[k] ? never : k; }[keyof T]>]: objectUtil.addQuestionMarks<baseObjectOutputType<T>, { [k in keyof baseObjectOutputType<T>]: undefined extends baseObjectOutputType<T>[k] ? never : k; }[keyof T]>[k_1]; }, { [k_2 in keyof baseObjectInputType<T>]: baseObjectInputType<T>[k_2]; }>;
911
948
  declare const unionType: <T extends readonly [ZodTypeAny, ZodTypeAny, ...ZodTypeAny[]]>(types: T, params?: RawCreateParams) => ZodUnion<T>;
912
949
  declare const discriminatedUnionType: typeof ZodDiscriminatedUnion.create;
913
950
  declare const intersectionType: <T extends ZodTypeAny, U extends ZodTypeAny>(left: T, right: U, params?: RawCreateParams) => ZodIntersection<T, U>;