zod 3.22.4 → 3.23.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/types.d.ts CHANGED
@@ -5,10 +5,10 @@ import { partialUtil } from "./helpers/partialUtil";
5
5
  import { Primitive } from "./helpers/typeAliases";
6
6
  import { objectUtil, util } from "./helpers/util";
7
7
  import { IssueData, StringValidation, ZodCustomIssue, ZodError, ZodErrorMap } from "./ZodError";
8
- export declare type RefinementCtx = {
8
+ export interface RefinementCtx {
9
9
  addIssue: (arg: IssueData) => void;
10
10
  path: (string | number)[];
11
- };
11
+ }
12
12
  export declare type ZodRawShape = {
13
13
  [k: string]: ZodTypeAny;
14
14
  };
@@ -26,6 +26,7 @@ export declare type RawCreateParams = {
26
26
  errorMap?: ZodErrorMap;
27
27
  invalid_type_error?: string;
28
28
  required_error?: string;
29
+ message?: string;
29
30
  description?: string;
30
31
  } | undefined;
31
32
  export declare type ProcessedCreateParams = {
@@ -35,10 +36,12 @@ export declare type ProcessedCreateParams = {
35
36
  export declare type SafeParseSuccess<Output> = {
36
37
  success: true;
37
38
  data: Output;
39
+ error?: never;
38
40
  };
39
41
  export declare type SafeParseError<Input> = {
40
42
  success: false;
41
43
  error: ZodError<Input>;
44
+ data?: never;
42
45
  };
43
46
  export declare type SafeParseReturnType<Input, Output> = SafeParseSuccess<Output> | SafeParseError<Input>;
44
47
  export declare abstract class ZodType<Output = any, Def extends ZodTypeDef = ZodTypeDef, Input = Output> {
@@ -118,6 +121,9 @@ export declare type ZodStringCheck = {
118
121
  } | {
119
122
  kind: "uuid";
120
123
  message?: string;
124
+ } | {
125
+ kind: "nanoid";
126
+ message?: string;
121
127
  } | {
122
128
  kind: "cuid";
123
129
  message?: string;
@@ -156,19 +162,38 @@ export declare type ZodStringCheck = {
156
162
  } | {
157
163
  kind: "datetime";
158
164
  offset: boolean;
165
+ local: boolean;
159
166
  precision: number | null;
160
167
  message?: string;
168
+ } | {
169
+ kind: "date";
170
+ message?: string;
171
+ } | {
172
+ kind: "time";
173
+ precision: number | null;
174
+ message?: string;
175
+ } | {
176
+ kind: "duration";
177
+ message?: string;
161
178
  } | {
162
179
  kind: "ip";
163
180
  version?: IpVersion;
164
181
  message?: string;
182
+ } | {
183
+ kind: "base64";
184
+ message?: string;
165
185
  };
166
186
  export interface ZodStringDef extends ZodTypeDef {
167
187
  checks: ZodStringCheck[];
168
188
  typeName: ZodFirstPartyTypeKind.ZodString;
169
189
  coerce: boolean;
170
190
  }
171
- export declare class ZodString extends ZodType<string, ZodStringDef> {
191
+ export declare function datetimeRegex(args: {
192
+ precision?: number | null;
193
+ offset?: boolean;
194
+ local?: boolean;
195
+ }): RegExp;
196
+ export declare class ZodString extends ZodType<string, ZodStringDef, string> {
172
197
  _parse(input: ParseInput): ParseReturnType<string>;
173
198
  protected _regex(regex: RegExp, validation: StringValidation, message?: errorUtil.ErrMessage): ZodEffects<this, string, string>;
174
199
  _addCheck(check: ZodStringCheck): ZodString;
@@ -176,9 +201,11 @@ export declare class ZodString extends ZodType<string, ZodStringDef> {
176
201
  url(message?: errorUtil.ErrMessage): ZodString;
177
202
  emoji(message?: errorUtil.ErrMessage): ZodString;
178
203
  uuid(message?: errorUtil.ErrMessage): ZodString;
204
+ nanoid(message?: errorUtil.ErrMessage): ZodString;
179
205
  cuid(message?: errorUtil.ErrMessage): ZodString;
180
206
  cuid2(message?: errorUtil.ErrMessage): ZodString;
181
207
  ulid(message?: errorUtil.ErrMessage): ZodString;
208
+ base64(message?: errorUtil.ErrMessage): ZodString;
182
209
  ip(options?: string | {
183
210
  version?: "v4" | "v6";
184
211
  message?: string;
@@ -187,7 +214,14 @@ export declare class ZodString extends ZodType<string, ZodStringDef> {
187
214
  message?: string | undefined;
188
215
  precision?: number | null;
189
216
  offset?: boolean;
217
+ local?: boolean;
218
+ }): ZodString;
219
+ date(message?: string): ZodString;
220
+ time(options?: string | {
221
+ message?: string | undefined;
222
+ precision?: number | null;
190
223
  }): ZodString;
224
+ duration(message?: errorUtil.ErrMessage): ZodString;
191
225
  regex(regex: RegExp, message?: errorUtil.ErrMessage): ZodString;
192
226
  includes(value: string, options?: {
193
227
  message?: string;
@@ -207,20 +241,26 @@ export declare class ZodString extends ZodType<string, ZodStringDef> {
207
241
  toLowerCase(): ZodString;
208
242
  toUpperCase(): ZodString;
209
243
  get isDatetime(): boolean;
244
+ get isDate(): boolean;
245
+ get isTime(): boolean;
246
+ get isDuration(): boolean;
210
247
  get isEmail(): boolean;
211
248
  get isURL(): boolean;
212
249
  get isEmoji(): boolean;
213
250
  get isUUID(): boolean;
251
+ get isNANOID(): boolean;
214
252
  get isCUID(): boolean;
215
253
  get isCUID2(): boolean;
216
254
  get isULID(): boolean;
217
255
  get isIP(): boolean;
256
+ get isBase64(): boolean;
218
257
  get minLength(): number | null;
219
258
  get maxLength(): number | null;
220
259
  static create: (params?: ({
221
260
  errorMap?: ZodErrorMap | undefined;
222
261
  invalid_type_error?: string | undefined;
223
262
  required_error?: string | undefined;
263
+ message?: string | undefined;
224
264
  description?: string | undefined;
225
265
  } & {
226
266
  coerce?: true | undefined;
@@ -252,12 +292,13 @@ export interface ZodNumberDef extends ZodTypeDef {
252
292
  typeName: ZodFirstPartyTypeKind.ZodNumber;
253
293
  coerce: boolean;
254
294
  }
255
- export declare class ZodNumber extends ZodType<number, ZodNumberDef> {
295
+ export declare class ZodNumber extends ZodType<number, ZodNumberDef, number> {
256
296
  _parse(input: ParseInput): ParseReturnType<number>;
257
297
  static create: (params?: ({
258
298
  errorMap?: ZodErrorMap | undefined;
259
299
  invalid_type_error?: string | undefined;
260
300
  required_error?: string | undefined;
301
+ message?: string | undefined;
261
302
  description?: string | undefined;
262
303
  } & {
263
304
  coerce?: boolean | undefined;
@@ -304,12 +345,13 @@ export interface ZodBigIntDef extends ZodTypeDef {
304
345
  typeName: ZodFirstPartyTypeKind.ZodBigInt;
305
346
  coerce: boolean;
306
347
  }
307
- export declare class ZodBigInt extends ZodType<bigint, ZodBigIntDef> {
348
+ export declare class ZodBigInt extends ZodType<bigint, ZodBigIntDef, bigint> {
308
349
  _parse(input: ParseInput): ParseReturnType<bigint>;
309
350
  static create: (params?: ({
310
351
  errorMap?: ZodErrorMap | undefined;
311
352
  invalid_type_error?: string | undefined;
312
353
  required_error?: string | undefined;
354
+ message?: string | undefined;
313
355
  description?: string | undefined;
314
356
  } & {
315
357
  coerce?: boolean | undefined;
@@ -334,12 +376,13 @@ export interface ZodBooleanDef extends ZodTypeDef {
334
376
  typeName: ZodFirstPartyTypeKind.ZodBoolean;
335
377
  coerce: boolean;
336
378
  }
337
- export declare class ZodBoolean extends ZodType<boolean, ZodBooleanDef> {
379
+ export declare class ZodBoolean extends ZodType<boolean, ZodBooleanDef, boolean> {
338
380
  _parse(input: ParseInput): ParseReturnType<boolean>;
339
381
  static create: (params?: ({
340
382
  errorMap?: ZodErrorMap | undefined;
341
383
  invalid_type_error?: string | undefined;
342
384
  required_error?: string | undefined;
385
+ message?: string | undefined;
343
386
  description?: string | undefined;
344
387
  } & {
345
388
  coerce?: boolean | undefined;
@@ -359,7 +402,7 @@ export interface ZodDateDef extends ZodTypeDef {
359
402
  coerce: boolean;
360
403
  typeName: ZodFirstPartyTypeKind.ZodDate;
361
404
  }
362
- export declare class ZodDate extends ZodType<Date, ZodDateDef> {
405
+ export declare class ZodDate extends ZodType<Date, ZodDateDef, Date> {
363
406
  _parse(input: ParseInput): ParseReturnType<this["_output"]>;
364
407
  _addCheck(check: ZodDateCheck): ZodDate;
365
408
  min(minDate: Date, message?: errorUtil.ErrMessage): ZodDate;
@@ -370,6 +413,7 @@ export declare class ZodDate extends ZodType<Date, ZodDateDef> {
370
413
  errorMap?: ZodErrorMap | undefined;
371
414
  invalid_type_error?: string | undefined;
372
415
  required_error?: string | undefined;
416
+ message?: string | undefined;
373
417
  description?: string | undefined;
374
418
  } & {
375
419
  coerce?: boolean | undefined;
@@ -385,7 +429,7 @@ export declare class ZodSymbol extends ZodType<symbol, ZodSymbolDef, symbol> {
385
429
  export interface ZodUndefinedDef extends ZodTypeDef {
386
430
  typeName: ZodFirstPartyTypeKind.ZodUndefined;
387
431
  }
388
- export declare class ZodUndefined extends ZodType<undefined, ZodUndefinedDef> {
432
+ export declare class ZodUndefined extends ZodType<undefined, ZodUndefinedDef, undefined> {
389
433
  _parse(input: ParseInput): ParseReturnType<this["_output"]>;
390
434
  params?: RawCreateParams;
391
435
  static create: (params?: RawCreateParams) => ZodUndefined;
@@ -393,14 +437,14 @@ export declare class ZodUndefined extends ZodType<undefined, ZodUndefinedDef> {
393
437
  export interface ZodNullDef extends ZodTypeDef {
394
438
  typeName: ZodFirstPartyTypeKind.ZodNull;
395
439
  }
396
- export declare class ZodNull extends ZodType<null, ZodNullDef> {
440
+ export declare class ZodNull extends ZodType<null, ZodNullDef, null> {
397
441
  _parse(input: ParseInput): ParseReturnType<this["_output"]>;
398
442
  static create: (params?: RawCreateParams) => ZodNull;
399
443
  }
400
444
  export interface ZodAnyDef extends ZodTypeDef {
401
445
  typeName: ZodFirstPartyTypeKind.ZodAny;
402
446
  }
403
- export declare class ZodAny extends ZodType<any, ZodAnyDef> {
447
+ export declare class ZodAny extends ZodType<any, ZodAnyDef, any> {
404
448
  _any: true;
405
449
  _parse(input: ParseInput): ParseReturnType<this["_output"]>;
406
450
  static create: (params?: RawCreateParams) => ZodAny;
@@ -408,7 +452,7 @@ export declare class ZodAny extends ZodType<any, ZodAnyDef> {
408
452
  export interface ZodUnknownDef extends ZodTypeDef {
409
453
  typeName: ZodFirstPartyTypeKind.ZodUnknown;
410
454
  }
411
- export declare class ZodUnknown extends ZodType<unknown, ZodUnknownDef> {
455
+ export declare class ZodUnknown extends ZodType<unknown, ZodUnknownDef, unknown> {
412
456
  _unknown: true;
413
457
  _parse(input: ParseInput): ParseReturnType<this["_output"]>;
414
458
  static create: (params?: RawCreateParams) => ZodUnknown;
@@ -416,14 +460,14 @@ export declare class ZodUnknown extends ZodType<unknown, ZodUnknownDef> {
416
460
  export interface ZodNeverDef extends ZodTypeDef {
417
461
  typeName: ZodFirstPartyTypeKind.ZodNever;
418
462
  }
419
- export declare class ZodNever extends ZodType<never, ZodNeverDef> {
463
+ export declare class ZodNever extends ZodType<never, ZodNeverDef, never> {
420
464
  _parse(input: ParseInput): ParseReturnType<this["_output"]>;
421
465
  static create: (params?: RawCreateParams) => ZodNever;
422
466
  }
423
467
  export interface ZodVoidDef extends ZodTypeDef {
424
468
  typeName: ZodFirstPartyTypeKind.ZodVoid;
425
469
  }
426
- export declare class ZodVoid extends ZodType<void, ZodVoidDef> {
470
+ export declare class ZodVoid extends ZodType<void, ZodVoidDef, void> {
427
471
  _parse(input: ParseInput): ParseReturnType<this["_output"]>;
428
472
  static create: (params?: RawCreateParams) => ZodVoid;
429
473
  }
@@ -473,10 +517,10 @@ export declare type objectInputType<Shape extends ZodRawShape, Catchall extends
473
517
  export declare type baseObjectInputType<Shape extends ZodRawShape> = objectUtil.addQuestionMarks<{
474
518
  [k in keyof Shape]: Shape[k]["_input"];
475
519
  }>;
476
- export declare type CatchallOutput<T extends ZodTypeAny> = ZodTypeAny extends T ? unknown : {
520
+ export declare type CatchallOutput<T extends ZodType> = ZodType extends T ? unknown : {
477
521
  [k: string]: T["_output"];
478
522
  };
479
- export declare type CatchallInput<T extends ZodTypeAny> = ZodTypeAny extends T ? unknown : {
523
+ export declare type CatchallInput<T extends ZodType> = ZodType extends T ? unknown : {
480
524
  [k: string]: T["_input"];
481
525
  };
482
526
  export declare type PassthroughType<T extends UnknownKeysParam> = T extends "passthrough" ? {
@@ -507,7 +551,7 @@ export declare class ZodObject<T extends ZodRawShape, UnknownKeys extends Unknow
507
551
  /**
508
552
  * @deprecated Use `.extend` instead
509
553
  * */
510
- 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>>;
554
+ augment: <Augmentation extends ZodRawShape>(augmentation: Augmentation) => ZodObject<objectUtil.extendShape<T, Augmentation>, UnknownKeys, Catchall, objectOutputType<objectUtil.extendShape<T, Augmentation>, Catchall, UnknownKeys>, objectInputType<objectUtil.extendShape<T, Augmentation>, Catchall, UnknownKeys>>;
511
555
  /**
512
556
  * Prior to zod@1.0.12 there was a bug in the
513
557
  * inferred type of merged objects. Please
@@ -518,12 +562,12 @@ export declare class ZodObject<T extends ZodRawShape, UnknownKeys extends Unknow
518
562
  [k in Key]: Schema;
519
563
  }, UnknownKeys, Catchall>;
520
564
  catchall<Index extends ZodTypeAny>(index: Index): ZodObject<T, UnknownKeys, Index>;
521
- pick<Mask extends {
565
+ pick<Mask extends util.Exactly<{
522
566
  [k in keyof T]?: true;
523
- }>(mask: Mask): ZodObject<Pick<T, Extract<keyof T, keyof Mask>>, UnknownKeys, Catchall>;
524
- omit<Mask extends {
567
+ }, Mask>>(mask: Mask): ZodObject<Pick<T, Extract<keyof T, keyof Mask>>, UnknownKeys, Catchall>;
568
+ omit<Mask extends util.Exactly<{
525
569
  [k in keyof T]?: true;
526
- }>(mask: Mask): ZodObject<Omit<T, keyof Mask>, UnknownKeys, Catchall>;
570
+ }, Mask>>(mask: Mask): ZodObject<Omit<T, keyof Mask>, UnknownKeys, Catchall>;
527
571
  /**
528
572
  * @deprecated
529
573
  */
@@ -531,23 +575,23 @@ export declare class ZodObject<T extends ZodRawShape, UnknownKeys extends Unknow
531
575
  partial(): ZodObject<{
532
576
  [k in keyof T]: ZodOptional<T[k]>;
533
577
  }, UnknownKeys, Catchall>;
534
- partial<Mask extends {
578
+ partial<Mask extends util.Exactly<{
535
579
  [k in keyof T]?: true;
536
- }>(mask: Mask): ZodObject<objectUtil.noNever<{
580
+ }, Mask>>(mask: Mask): ZodObject<objectUtil.noNever<{
537
581
  [k in keyof T]: k extends keyof Mask ? ZodOptional<T[k]> : T[k];
538
582
  }>, UnknownKeys, Catchall>;
539
583
  required(): ZodObject<{
540
584
  [k in keyof T]: deoptional<T[k]>;
541
585
  }, UnknownKeys, Catchall>;
542
- required<Mask extends {
586
+ required<Mask extends util.Exactly<{
543
587
  [k in keyof T]?: true;
544
- }>(mask: Mask): ZodObject<objectUtil.noNever<{
588
+ }, Mask>>(mask: Mask): ZodObject<objectUtil.noNever<{
545
589
  [k in keyof T]: k extends keyof Mask ? deoptional<T[k]> : T[k];
546
590
  }>, UnknownKeys, Catchall>;
547
591
  keyof(): ZodEnum<enumUtil.UnionToTupleString<keyof T>>;
548
- 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]; }>;
549
- 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]; }>;
550
- 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]; }>;
592
+ static create: <T_1 extends ZodRawShape>(shape: T_1, params?: RawCreateParams) => ZodObject<T_1, "strip", ZodTypeAny, { [k in keyof objectUtil.addQuestionMarks<baseObjectOutputType<T_1>, any>]: objectUtil.addQuestionMarks<baseObjectOutputType<T_1>, any>[k]; }, { [k_1 in keyof baseObjectInputType<T_1>]: baseObjectInputType<T_1>[k_1]; }>;
593
+ static strictCreate: <T_1 extends ZodRawShape>(shape: T_1, params?: RawCreateParams) => ZodObject<T_1, "strict", ZodTypeAny, { [k in keyof objectUtil.addQuestionMarks<baseObjectOutputType<T_1>, any>]: objectUtil.addQuestionMarks<baseObjectOutputType<T_1>, any>[k]; }, { [k_1 in keyof baseObjectInputType<T_1>]: baseObjectInputType<T_1>[k_1]; }>;
594
+ static lazycreate: <T_1 extends ZodRawShape>(shape: () => T_1, params?: RawCreateParams) => ZodObject<T_1, "strip", ZodTypeAny, { [k in keyof objectUtil.addQuestionMarks<baseObjectOutputType<T_1>, any>]: objectUtil.addQuestionMarks<baseObjectOutputType<T_1>, any>[k]; }, { [k_1 in keyof baseObjectInputType<T_1>]: baseObjectInputType<T_1>[k_1]; }>;
551
595
  }
552
596
  export declare type AnyZodObject = ZodObject<any, any, any>;
553
597
  export declare type ZodUnionOptions = Readonly<[ZodTypeAny, ...ZodTypeAny[]]>;
@@ -603,11 +647,11 @@ export declare class ZodIntersection<T extends ZodTypeAny, U extends ZodTypeAny>
603
647
  export declare type ZodTupleItems = [ZodTypeAny, ...ZodTypeAny[]];
604
648
  export declare type AssertArray<T> = T extends any[] ? T : never;
605
649
  export declare type OutputTypeOfTuple<T extends ZodTupleItems | []> = AssertArray<{
606
- [k in keyof T]: T[k] extends ZodType<any, any> ? T[k]["_output"] : never;
650
+ [k in keyof T]: T[k] extends ZodType<any, any, any> ? T[k]["_output"] : never;
607
651
  }>;
608
652
  export declare type OutputTypeOfTupleWithRest<T extends ZodTupleItems | [], Rest extends ZodTypeAny | null = null> = Rest extends ZodTypeAny ? [...OutputTypeOfTuple<T>, ...Rest["_output"][]] : OutputTypeOfTuple<T>;
609
653
  export declare type InputTypeOfTuple<T extends ZodTupleItems | []> = AssertArray<{
610
- [k in keyof T]: T[k] extends ZodType<any, any> ? T[k]["_input"] : never;
654
+ [k in keyof T]: T[k] extends ZodType<any, any, any> ? T[k]["_input"] : never;
611
655
  }>;
612
656
  export declare type InputTypeOfTupleWithRest<T extends ZodTupleItems | [], Rest extends ZodTypeAny | null = null> = Rest extends ZodTypeAny ? [...InputTypeOfTuple<T>, ...Rest["_input"][]] : InputTypeOfTuple<T>;
613
657
  export interface ZodTupleDef<T extends ZodTupleItems | [] = ZodTupleItems, Rest extends ZodTypeAny | null = null> extends ZodTypeDef {
@@ -685,7 +729,7 @@ export declare class ZodFunction<Args extends ZodTuple<any, any>, Returns extend
685
729
  parameters(): Args;
686
730
  returnType(): Returns;
687
731
  args<Items extends Parameters<(typeof ZodTuple)["create"]>[0]>(...items: Items): ZodFunction<ZodTuple<Items, ZodUnknown>, Returns>;
688
- returns<NewReturnType extends ZodType<any, any>>(returnType: NewReturnType): ZodFunction<Args, NewReturnType>;
732
+ returns<NewReturnType extends ZodType<any, any, any>>(returnType: NewReturnType): ZodFunction<Args, NewReturnType>;
689
733
  implement<F extends InnerTypeOfFunction<Args, Returns>>(func: F): ReturnType<F> extends Returns["_output"] ? (...args: Args["_input"]) => ReturnType<F> : OuterTypeOfFunction<Args, Returns>;
690
734
  strictImplement(func: InnerTypeOfFunction<Args, Returns>): InnerTypeOfFunction<Args, Returns>;
691
735
  validate: <F extends InnerTypeOfFunction<Args, Returns>>(func: F) => ReturnType<F> extends Returns["_output"] ? (...args: Args["_input"]) => ReturnType<F> : OuterTypeOfFunction<Args, Returns>;
@@ -707,14 +751,14 @@ export interface ZodLiteralDef<T = any> extends ZodTypeDef {
707
751
  value: T;
708
752
  typeName: ZodFirstPartyTypeKind.ZodLiteral;
709
753
  }
710
- export declare class ZodLiteral<T> extends ZodType<T, ZodLiteralDef<T>> {
754
+ export declare class ZodLiteral<T> extends ZodType<T, ZodLiteralDef<T>, T> {
711
755
  _parse(input: ParseInput): ParseReturnType<this["_output"]>;
712
756
  get value(): T;
713
757
  static create: <T_1 extends Primitive>(value: T_1, params?: RawCreateParams) => ZodLiteral<T_1>;
714
758
  }
715
759
  export declare type ArrayKeys = keyof any[];
716
760
  export declare type Indices<T> = Exclude<keyof T, ArrayKeys>;
717
- export declare type EnumValues = [string, ...string[]];
761
+ export declare type EnumValues<T extends string = string> = readonly [T, ...T[]];
718
762
  export declare type Values<T extends EnumValues> = {
719
763
  [k in T[number]]: k;
720
764
  };
@@ -729,14 +773,15 @@ export declare type FilterEnum<Values, ToExclude> = Values extends [] ? [] : Val
729
773
  export declare type typecast<A, T> = A extends T ? A : never;
730
774
  declare function createZodEnum<U extends string, T extends Readonly<[U, ...U[]]>>(values: T, params?: RawCreateParams): ZodEnum<Writeable<T>>;
731
775
  declare function createZodEnum<U extends string, T extends [U, ...U[]]>(values: T, params?: RawCreateParams): ZodEnum<T>;
732
- export declare class ZodEnum<T extends [string, ...string[]]> extends ZodType<T[number], ZodEnumDef<T>> {
776
+ export declare class ZodEnum<T extends [string, ...string[]]> extends ZodType<T[number], ZodEnumDef<T>, T[number]> {
777
+ #private;
733
778
  _parse(input: ParseInput): ParseReturnType<this["_output"]>;
734
779
  get options(): T;
735
780
  get enum(): Values<T>;
736
781
  get Values(): Values<T>;
737
782
  get Enum(): Values<T>;
738
- extract<ToExtract extends readonly [T[number], ...T[number][]]>(values: ToExtract): ZodEnum<Writeable<ToExtract>>;
739
- exclude<ToExclude extends readonly [T[number], ...T[number][]]>(values: ToExclude): ZodEnum<typecast<Writeable<FilterEnum<T, ToExclude[number]>>, [string, ...string[]]>>;
783
+ extract<ToExtract extends readonly [T[number], ...T[number][]]>(values: ToExtract, newDef?: RawCreateParams): ZodEnum<Writeable<ToExtract>>;
784
+ exclude<ToExclude extends readonly [T[number], ...T[number][]]>(values: ToExclude, newDef?: RawCreateParams): ZodEnum<typecast<Writeable<FilterEnum<T, ToExclude[number]>>, [string, ...string[]]>>;
740
785
  static create: typeof createZodEnum;
741
786
  }
742
787
  export interface ZodNativeEnumDef<T extends EnumLike = EnumLike> extends ZodTypeDef {
@@ -747,7 +792,8 @@ export declare type EnumLike = {
747
792
  [k: string]: string | number;
748
793
  [nu: number]: string;
749
794
  };
750
- export declare class ZodNativeEnum<T extends EnumLike> extends ZodType<T[keyof T], ZodNativeEnumDef<T>> {
795
+ export declare class ZodNativeEnum<T extends EnumLike> extends ZodType<T[keyof T], ZodNativeEnumDef<T>, T[keyof T]> {
796
+ #private;
751
797
  _parse(input: ParseInput): ParseReturnType<T[keyof T]>;
752
798
  get enum(): T;
753
799
  static create: <T_1 extends EnumLike>(values: T_1, params?: RawCreateParams) => ZodNativeEnum<T_1>;
@@ -821,6 +867,7 @@ export declare class ZodDefault<T extends ZodTypeAny> extends ZodType<util.noUnd
821
867
  errorMap?: ZodErrorMap | undefined;
822
868
  invalid_type_error?: string | undefined;
823
869
  required_error?: string | undefined;
870
+ message?: string | undefined;
824
871
  description?: string | undefined;
825
872
  } & {
826
873
  default: T_1["_input"] | (() => util.noUndefined<T_1["_input"]>);
@@ -841,6 +888,7 @@ export declare class ZodCatch<T extends ZodTypeAny> extends ZodType<T["_output"]
841
888
  errorMap?: ZodErrorMap | undefined;
842
889
  invalid_type_error?: string | undefined;
843
890
  required_error?: string | undefined;
891
+ message?: string | undefined;
844
892
  description?: string | undefined;
845
893
  } & {
846
894
  catch: T_1["_output"] | (() => T_1["_output"]);
@@ -849,7 +897,7 @@ export declare class ZodCatch<T extends ZodTypeAny> extends ZodType<T["_output"]
849
897
  export interface ZodNaNDef extends ZodTypeDef {
850
898
  typeName: ZodFirstPartyTypeKind.ZodNaN;
851
899
  }
852
- export declare class ZodNaN extends ZodType<number, ZodNaNDef> {
900
+ export declare class ZodNaN extends ZodType<number, ZodNaNDef, number> {
853
901
  _parse(input: ParseInput): ParseReturnType<any>;
854
902
  static create: (params?: RawCreateParams) => ZodNaN;
855
903
  }
@@ -884,17 +932,29 @@ export interface ZodReadonlyDef<T extends ZodTypeAny = ZodTypeAny> extends ZodTy
884
932
  innerType: T;
885
933
  typeName: ZodFirstPartyTypeKind.ZodReadonly;
886
934
  }
887
- export declare class ZodReadonly<T extends ZodTypeAny> extends ZodType<MakeReadonly<T["_output"]>, ZodReadonlyDef<T>, T["_input"]> {
935
+ export declare class ZodReadonly<T extends ZodTypeAny> extends ZodType<MakeReadonly<T["_output"]>, ZodReadonlyDef<T>, MakeReadonly<T["_input"]>> {
888
936
  _parse(input: ParseInput): ParseReturnType<this["_output"]>;
889
937
  static create: <T_1 extends ZodTypeAny>(type: T_1, params?: RawCreateParams) => ZodReadonly<T_1>;
938
+ unwrap(): T;
890
939
  }
891
940
  declare type CustomParams = CustomErrorParams & {
892
941
  fatal?: boolean;
893
942
  };
894
- export declare const custom: <T>(check?: ((data: unknown) => any) | undefined, params?: string | CustomParams | ((input: any) => CustomParams), fatal?: boolean | undefined) => ZodType<T, ZodTypeDef, T>;
943
+ export declare function custom<T>(check?: (data: any) => any, params?: string | CustomParams | ((input: any) => CustomParams),
944
+ /**
945
+ * @deprecated
946
+ *
947
+ * Pass `fatal` into the params object instead:
948
+ *
949
+ * ```ts
950
+ * z.string().custom((val) => val.length > 5, { fatal: false })
951
+ * ```
952
+ *
953
+ */
954
+ fatal?: boolean): ZodType<T, ZodTypeDef, T>;
895
955
  export { ZodType as Schema, ZodType as ZodSchema };
896
956
  export declare const late: {
897
- 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]; }>;
957
+ object: <T extends ZodRawShape>(shape: () => T, params?: RawCreateParams) => ZodObject<T, "strip", ZodTypeAny, { [k in keyof objectUtil.addQuestionMarks<baseObjectOutputType<T>, any>]: objectUtil.addQuestionMarks<baseObjectOutputType<T>, any>[k]; }, { [k_1 in keyof baseObjectInputType<T>]: baseObjectInputType<T>[k_1]; }>;
898
958
  };
899
959
  export declare enum ZodFirstPartyTypeKind {
900
960
  ZodString = "ZodString",
@@ -934,7 +994,7 @@ export declare enum ZodFirstPartyTypeKind {
934
994
  ZodPipeline = "ZodPipeline",
935
995
  ZodReadonly = "ZodReadonly"
936
996
  }
937
- export declare type ZodFirstPartySchemaTypes = ZodString | ZodNumber | ZodNaN | ZodBigInt | ZodBoolean | ZodDate | ZodUndefined | ZodNull | ZodAny | ZodUnknown | ZodNever | ZodVoid | ZodArray<any, any> | ZodObject<any, any, any> | ZodUnion<any> | ZodDiscriminatedUnion<any, any> | ZodIntersection<any, any> | ZodTuple<any, any> | ZodRecord<any, any> | ZodMap<any> | ZodSet<any> | ZodFunction<any, any> | ZodLazy<any> | ZodLiteral<any> | ZodEnum<any> | ZodEffects<any, any, any> | ZodNativeEnum<any> | ZodOptional<any> | ZodNullable<any> | ZodDefault<any> | ZodCatch<any> | ZodPromise<any> | ZodBranded<any, any> | ZodPipeline<any, any>;
997
+ export declare type ZodFirstPartySchemaTypes = ZodString | ZodNumber | ZodNaN | ZodBigInt | ZodBoolean | ZodDate | ZodUndefined | ZodNull | ZodAny | ZodUnknown | ZodNever | ZodVoid | ZodArray<any, any> | ZodObject<any, any, any> | ZodUnion<any> | ZodDiscriminatedUnion<any, any> | ZodIntersection<any, any> | ZodTuple<any, any> | ZodRecord<any, any> | ZodMap<any> | ZodSet<any> | ZodFunction<any, any> | ZodLazy<any> | ZodLiteral<any> | ZodEnum<any> | ZodEffects<any, any, any> | ZodNativeEnum<any> | ZodOptional<any> | ZodNullable<any> | ZodDefault<any> | ZodCatch<any> | ZodPromise<any> | ZodBranded<any, any> | ZodPipeline<any, any> | ZodReadonly<any> | ZodSymbol;
938
998
  declare abstract class Class {
939
999
  constructor(..._: any[]);
940
1000
  }
@@ -943,6 +1003,7 @@ declare const stringType: (params?: ({
943
1003
  errorMap?: ZodErrorMap | undefined;
944
1004
  invalid_type_error?: string | undefined;
945
1005
  required_error?: string | undefined;
1006
+ message?: string | undefined;
946
1007
  description?: string | undefined;
947
1008
  } & {
948
1009
  coerce?: true | undefined;
@@ -951,6 +1012,7 @@ declare const numberType: (params?: ({
951
1012
  errorMap?: ZodErrorMap | undefined;
952
1013
  invalid_type_error?: string | undefined;
953
1014
  required_error?: string | undefined;
1015
+ message?: string | undefined;
954
1016
  description?: string | undefined;
955
1017
  } & {
956
1018
  coerce?: boolean | undefined;
@@ -960,6 +1022,7 @@ declare const bigIntType: (params?: ({
960
1022
  errorMap?: ZodErrorMap | undefined;
961
1023
  invalid_type_error?: string | undefined;
962
1024
  required_error?: string | undefined;
1025
+ message?: string | undefined;
963
1026
  description?: string | undefined;
964
1027
  } & {
965
1028
  coerce?: boolean | undefined;
@@ -968,6 +1031,7 @@ declare const booleanType: (params?: ({
968
1031
  errorMap?: ZodErrorMap | undefined;
969
1032
  invalid_type_error?: string | undefined;
970
1033
  required_error?: string | undefined;
1034
+ message?: string | undefined;
971
1035
  description?: string | undefined;
972
1036
  } & {
973
1037
  coerce?: boolean | undefined;
@@ -976,6 +1040,7 @@ declare const dateType: (params?: ({
976
1040
  errorMap?: ZodErrorMap | undefined;
977
1041
  invalid_type_error?: string | undefined;
978
1042
  required_error?: string | undefined;
1043
+ message?: string | undefined;
979
1044
  description?: string | undefined;
980
1045
  } & {
981
1046
  coerce?: boolean | undefined;
@@ -988,8 +1053,8 @@ declare const unknownType: (params?: RawCreateParams) => ZodUnknown;
988
1053
  declare const neverType: (params?: RawCreateParams) => ZodNever;
989
1054
  declare const voidType: (params?: RawCreateParams) => ZodVoid;
990
1055
  declare const arrayType: <T extends ZodTypeAny>(schema: T, params?: RawCreateParams) => ZodArray<T, "many">;
991
- 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]; }>;
992
- 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]; }>;
1056
+ declare const objectType: <T extends ZodRawShape>(shape: T, params?: RawCreateParams) => ZodObject<T, "strip", ZodTypeAny, { [k in keyof objectUtil.addQuestionMarks<baseObjectOutputType<T>, any>]: objectUtil.addQuestionMarks<baseObjectOutputType<T>, any>[k]; }, { [k_1 in keyof baseObjectInputType<T>]: baseObjectInputType<T>[k_1]; }>;
1057
+ declare const strictObjectType: <T extends ZodRawShape>(shape: T, params?: RawCreateParams) => ZodObject<T, "strict", ZodTypeAny, { [k in keyof objectUtil.addQuestionMarks<baseObjectOutputType<T>, any>]: objectUtil.addQuestionMarks<baseObjectOutputType<T>, any>[k]; }, { [k_1 in keyof baseObjectInputType<T>]: baseObjectInputType<T>[k_1]; }>;
993
1058
  declare const unionType: <T extends readonly [ZodTypeAny, ZodTypeAny, ...ZodTypeAny[]]>(types: T, params?: RawCreateParams) => ZodUnion<T>;
994
1059
  declare const discriminatedUnionType: typeof ZodDiscriminatedUnion.create;
995
1060
  declare const intersectionType: <T extends ZodTypeAny, U extends ZodTypeAny>(left: T, right: U, params?: RawCreateParams) => ZodIntersection<T, U>;
@@ -1016,6 +1081,7 @@ export declare const coerce: {
1016
1081
  errorMap?: ZodErrorMap | undefined;
1017
1082
  invalid_type_error?: string | undefined;
1018
1083
  required_error?: string | undefined;
1084
+ message?: string | undefined;
1019
1085
  description?: string | undefined;
1020
1086
  } & {
1021
1087
  coerce?: true | undefined;
@@ -1024,6 +1090,7 @@ export declare const coerce: {
1024
1090
  errorMap?: ZodErrorMap | undefined;
1025
1091
  invalid_type_error?: string | undefined;
1026
1092
  required_error?: string | undefined;
1093
+ message?: string | undefined;
1027
1094
  description?: string | undefined;
1028
1095
  } & {
1029
1096
  coerce?: boolean | undefined;
@@ -1032,6 +1099,7 @@ export declare const coerce: {
1032
1099
  errorMap?: ZodErrorMap | undefined;
1033
1100
  invalid_type_error?: string | undefined;
1034
1101
  required_error?: string | undefined;
1102
+ message?: string | undefined;
1035
1103
  description?: string | undefined;
1036
1104
  } & {
1037
1105
  coerce?: boolean | undefined;
@@ -1040,6 +1108,7 @@ export declare const coerce: {
1040
1108
  errorMap?: ZodErrorMap | undefined;
1041
1109
  invalid_type_error?: string | undefined;
1042
1110
  required_error?: string | undefined;
1111
+ message?: string | undefined;
1043
1112
  description?: string | undefined;
1044
1113
  } & {
1045
1114
  coerce?: boolean | undefined;
@@ -1048,6 +1117,7 @@ export declare const coerce: {
1048
1117
  errorMap?: ZodErrorMap | undefined;
1049
1118
  invalid_type_error?: string | undefined;
1050
1119
  required_error?: string | undefined;
1120
+ message?: string | undefined;
1051
1121
  description?: string | undefined;
1052
1122
  } & {
1053
1123
  coerce?: boolean | undefined;