zod 3.20.2 → 3.20.3

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/index.umd.js CHANGED
@@ -478,7 +478,7 @@
478
478
  const isAborted = (x) => x.status === "aborted";
479
479
  const isDirty = (x) => x.status === "dirty";
480
480
  const isValid = (x) => x.status === "valid";
481
- const isAsync = (x) => typeof Promise !== undefined && x instanceof Promise;
481
+ const isAsync = (x) => typeof Promise !== "undefined" && x instanceof Promise;
482
482
 
483
483
  var errorUtil;
484
484
  (function (errorUtil) {
@@ -707,28 +707,29 @@
707
707
  return this._refinement(refinement);
708
708
  }
709
709
  optional() {
710
- return ZodOptional.create(this);
710
+ return ZodOptional.create(this, this._def);
711
711
  }
712
712
  nullable() {
713
- return ZodNullable.create(this);
713
+ return ZodNullable.create(this, this._def);
714
714
  }
715
715
  nullish() {
716
- return this.optional().nullable();
716
+ return this.nullable().optional();
717
717
  }
718
718
  array() {
719
- return ZodArray.create(this);
719
+ return ZodArray.create(this, this._def);
720
720
  }
721
721
  promise() {
722
- return ZodPromise.create(this);
722
+ return ZodPromise.create(this, this._def);
723
723
  }
724
724
  or(option) {
725
- return ZodUnion.create([this, option]);
725
+ return ZodUnion.create([this, option], this._def);
726
726
  }
727
727
  and(incoming) {
728
- return ZodIntersection.create(this, incoming);
728
+ return ZodIntersection.create(this, incoming, this._def);
729
729
  }
730
730
  transform(transform) {
731
731
  return new ZodEffects({
732
+ ...processCreateParams(this._def),
732
733
  schema: this,
733
734
  typeName: exports.ZodFirstPartyTypeKind.ZodEffects,
734
735
  effect: { type: "transform", transform },
@@ -737,6 +738,7 @@
737
738
  default(def) {
738
739
  const defaultValueFunc = typeof def === "function" ? def : () => def;
739
740
  return new ZodDefault({
741
+ ...processCreateParams(this._def),
740
742
  innerType: this,
741
743
  defaultValue: defaultValueFunc,
742
744
  typeName: exports.ZodFirstPartyTypeKind.ZodDefault,
@@ -746,14 +748,15 @@
746
748
  return new ZodBranded({
747
749
  typeName: exports.ZodFirstPartyTypeKind.ZodBranded,
748
750
  type: this,
749
- ...processCreateParams(undefined),
751
+ ...processCreateParams(this._def),
750
752
  });
751
753
  }
752
754
  catch(def) {
753
- const defaultValueFunc = typeof def === "function" ? def : () => def;
755
+ const catchValueFunc = typeof def === "function" ? def : () => def;
754
756
  return new ZodCatch({
757
+ ...processCreateParams(this._def),
755
758
  innerType: this,
756
- defaultValue: defaultValueFunc,
759
+ catchValue: catchValueFunc,
757
760
  typeName: exports.ZodFirstPartyTypeKind.ZodCatch,
758
761
  });
759
762
  }
@@ -775,12 +778,15 @@
775
778
  }
776
779
  }
777
780
  const cuidRegex = /^c[^\s-]{8,}$/i;
781
+ const cuid2Regex = /^[a-z][a-z0-9]*$/;
778
782
  const uuidRegex = /^([a-f0-9]{8}-[a-f0-9]{4}-[1-5][a-f0-9]{3}-[a-f0-9]{4}-[a-f0-9]{12}|00000000-0000-0000-0000-000000000000)$/i;
779
783
  // from https://stackoverflow.com/a/46181/1550155
780
784
  // old version: too slow, didn't support unicode
781
785
  // const emailRegex = /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))$/i;
786
+ //old email regex
787
+ // const emailRegex = /^(([^<>()[\].,;:\s@"]+(\.[^<>()[\].,;:\s@"]+)*)|(".+"))@((?!-)([^<>()[\].,;:\s@"]+\.)+[^<>()[\].,;:\s@"]{1,})[^-<>()[\].,;:\s@"]$/i;
782
788
  // eslint-disable-next-line
783
- const emailRegex = /^(([^<>()[\]\.,;:\s@\"]+(\.[^<>()[\]\.,;:\s@\"]+)*)|(\".+\"))@(([^<>()[\]\.,;:\s@\"]+\.)+[^<>()[\]\.,;:\s@\"]{2,})$/i;
789
+ const emailRegex = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|([^-]([a-zA-Z0-9-]*\.)+[a-zA-Z]{2,}))$/;
784
790
  // interface IsDateStringOptions extends StringDateOptions {
785
791
  /**
786
792
  * Match any configuration
@@ -791,7 +797,7 @@
791
797
  const datetimeRegex = (args) => {
792
798
  if (args.precision) {
793
799
  if (args.offset) {
794
- return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${args.precision}}(([+-]\\d{2}:\\d{2})|Z)$`);
800
+ return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${args.precision}}(([+-]\\d{2}(:?\\d{2})?)|Z)$`);
795
801
  }
796
802
  else {
797
803
  return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${args.precision}}Z$`);
@@ -799,7 +805,7 @@
799
805
  }
800
806
  else if (args.precision === 0) {
801
807
  if (args.offset) {
802
- return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(([+-]\\d{2}:\\d{2})|Z)$`);
808
+ return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(([+-]\\d{2}(:?\\d{2})?)|Z)$`);
803
809
  }
804
810
  else {
805
811
  return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$`);
@@ -807,7 +813,7 @@
807
813
  }
808
814
  else {
809
815
  if (args.offset) {
810
- return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}:\\d{2})|Z)$`);
816
+ return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}(:?\\d{2})?)|Z)$`);
811
817
  }
812
818
  else {
813
819
  return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$`);
@@ -940,6 +946,17 @@
940
946
  status.dirty();
941
947
  }
942
948
  }
949
+ else if (check.kind === "cuid2") {
950
+ if (!cuid2Regex.test(input.data)) {
951
+ ctx = this._getOrReturnCtx(input, ctx);
952
+ addIssueToContext(ctx, {
953
+ validation: "cuid2",
954
+ code: ZodIssueCode.invalid_string,
955
+ message: check.message,
956
+ });
957
+ status.dirty();
958
+ }
959
+ }
943
960
  else if (check.kind === "url") {
944
961
  try {
945
962
  new URL(input.data);
@@ -1028,6 +1045,9 @@
1028
1045
  cuid(message) {
1029
1046
  return this._addCheck({ kind: "cuid", ...errorUtil.errToObj(message) });
1030
1047
  }
1048
+ cuid2(message) {
1049
+ return this._addCheck({ kind: "cuid2", ...errorUtil.errToObj(message) });
1050
+ }
1031
1051
  datetime(options) {
1032
1052
  var _a;
1033
1053
  if (typeof options === "string") {
@@ -1102,6 +1122,9 @@
1102
1122
  get isCUID() {
1103
1123
  return !!this._def.checks.find((ch) => ch.kind === "cuid");
1104
1124
  }
1125
+ get isCUID2() {
1126
+ return !!this._def.checks.find((ch) => ch.kind === "cuid2");
1127
+ }
1105
1128
  get minLength() {
1106
1129
  let min = null;
1107
1130
  for (const ch of this._def.checks) {
@@ -1342,7 +1365,27 @@
1342
1365
  return max;
1343
1366
  }
1344
1367
  get isInt() {
1345
- return !!this._def.checks.find((ch) => ch.kind === "int");
1368
+ return !!this._def.checks.find((ch) => ch.kind === "int" ||
1369
+ (ch.kind === "multipleOf" && exports.util.isInteger(ch.value)));
1370
+ }
1371
+ get isFinite() {
1372
+ let max = null, min = null;
1373
+ for (const ch of this._def.checks) {
1374
+ if (ch.kind === "finite" ||
1375
+ ch.kind === "int" ||
1376
+ ch.kind === "multipleOf") {
1377
+ return true;
1378
+ }
1379
+ else if (ch.kind === "min") {
1380
+ if (min === null || ch.value > min)
1381
+ min = ch.value;
1382
+ }
1383
+ else if (ch.kind === "max") {
1384
+ if (max === null || ch.value < max)
1385
+ max = ch.value;
1386
+ }
1387
+ }
1388
+ return Number.isFinite(min) && Number.isFinite(max);
1346
1389
  }
1347
1390
  }
1348
1391
  ZodNumber.create = (params) => {
@@ -1703,13 +1746,13 @@
1703
1746
  }
1704
1747
  }
1705
1748
  if (ctx.common.async) {
1706
- return Promise.all(ctx.data.map((item, i) => {
1749
+ return Promise.all([...ctx.data].map((item, i) => {
1707
1750
  return def.type._parseAsync(new ParseInputLazyPath(ctx, item, ctx.path, i));
1708
1751
  })).then((result) => {
1709
1752
  return ParseStatus.mergeArray(status, result);
1710
1753
  });
1711
1754
  }
1712
- const result = ctx.data.map((item, i) => {
1755
+ const result = [...ctx.data].map((item, i) => {
1713
1756
  return def.type._parseSync(new ParseInputLazyPath(ctx, item, ctx.path, i));
1714
1757
  });
1715
1758
  return ParseStatus.mergeArray(status, result);
@@ -1978,10 +2021,10 @@
1978
2021
  }
1979
2022
  pick(mask) {
1980
2023
  const shape = {};
1981
- exports.util.objectKeys(mask).map((key) => {
1982
- // only add to shape if key corresponds to an element of the current shape
1983
- if (this.shape[key])
2024
+ exports.util.objectKeys(mask).forEach((key) => {
2025
+ if (mask[key] && this.shape[key]) {
1984
2026
  shape[key] = this.shape[key];
2027
+ }
1985
2028
  });
1986
2029
  return new ZodObject({
1987
2030
  ...this._def,
@@ -1990,8 +2033,8 @@
1990
2033
  }
1991
2034
  omit(mask) {
1992
2035
  const shape = {};
1993
- exports.util.objectKeys(this.shape).map((key) => {
1994
- if (exports.util.objectKeys(mask).indexOf(key) === -1) {
2036
+ exports.util.objectKeys(this.shape).forEach((key) => {
2037
+ if (!mask[key]) {
1995
2038
  shape[key] = this.shape[key];
1996
2039
  }
1997
2040
  });
@@ -2005,26 +2048,15 @@
2005
2048
  }
2006
2049
  partial(mask) {
2007
2050
  const newShape = {};
2008
- if (mask) {
2009
- exports.util.objectKeys(this.shape).map((key) => {
2010
- if (exports.util.objectKeys(mask).indexOf(key) === -1) {
2011
- newShape[key] = this.shape[key];
2012
- }
2013
- else {
2014
- newShape[key] = this.shape[key].optional();
2015
- }
2016
- });
2017
- return new ZodObject({
2018
- ...this._def,
2019
- shape: () => newShape,
2020
- });
2021
- }
2022
- else {
2023
- for (const key in this.shape) {
2024
- const fieldSchema = this.shape[key];
2051
+ exports.util.objectKeys(this.shape).forEach((key) => {
2052
+ const fieldSchema = this.shape[key];
2053
+ if (mask && !mask[key]) {
2054
+ newShape[key] = fieldSchema;
2055
+ }
2056
+ else {
2025
2057
  newShape[key] = fieldSchema.optional();
2026
2058
  }
2027
- }
2059
+ });
2028
2060
  return new ZodObject({
2029
2061
  ...this._def,
2030
2062
  shape: () => newShape,
@@ -2032,23 +2064,11 @@
2032
2064
  }
2033
2065
  required(mask) {
2034
2066
  const newShape = {};
2035
- if (mask) {
2036
- exports.util.objectKeys(this.shape).map((key) => {
2037
- if (exports.util.objectKeys(mask).indexOf(key) === -1) {
2038
- newShape[key] = this.shape[key];
2039
- }
2040
- else {
2041
- const fieldSchema = this.shape[key];
2042
- let newField = fieldSchema;
2043
- while (newField instanceof ZodOptional) {
2044
- newField = newField._def.innerType;
2045
- }
2046
- newShape[key] = newField;
2047
- }
2048
- });
2049
- }
2050
- else {
2051
- for (const key in this.shape) {
2067
+ exports.util.objectKeys(this.shape).forEach((key) => {
2068
+ if (mask && !mask[key]) {
2069
+ newShape[key] = this.shape[key];
2070
+ }
2071
+ else {
2052
2072
  const fieldSchema = this.shape[key];
2053
2073
  let newField = fieldSchema;
2054
2074
  while (newField instanceof ZodOptional) {
@@ -2056,7 +2076,7 @@
2056
2076
  }
2057
2077
  newShape[key] = newField;
2058
2078
  }
2059
- }
2079
+ });
2060
2080
  return new ZodObject({
2061
2081
  ...this._def,
2062
2082
  shape: () => newShape,
@@ -2437,7 +2457,7 @@
2437
2457
  });
2438
2458
  status.dirty();
2439
2459
  }
2440
- const items = ctx.data
2460
+ const items = [...ctx.data]
2441
2461
  .map((item, itemIndex) => {
2442
2462
  const schema = this._def.items[itemIndex] || this._def.rest;
2443
2463
  if (!schema)
@@ -2817,6 +2837,7 @@
2817
2837
  if (input.data !== this._def.value) {
2818
2838
  const ctx = this._getOrReturnCtx(input);
2819
2839
  addIssueToContext(ctx, {
2840
+ received: ctx.data,
2820
2841
  code: ZodIssueCode.invalid_literal,
2821
2842
  expected: this._def.value,
2822
2843
  });
@@ -2890,6 +2911,12 @@
2890
2911
  }
2891
2912
  return enumValues;
2892
2913
  }
2914
+ extract(values) {
2915
+ return ZodEnum.create(values);
2916
+ }
2917
+ exclude(values) {
2918
+ return ZodEnum.create(this.options.filter((opt) => !values.includes(opt)));
2919
+ }
2893
2920
  }
2894
2921
  ZodEnum.create = createZodEnum;
2895
2922
  class ZodNativeEnum extends ZodType {
@@ -2929,6 +2956,9 @@
2929
2956
  });
2930
2957
  };
2931
2958
  class ZodPromise extends ZodType {
2959
+ unwrap() {
2960
+ return this._def.type;
2961
+ }
2932
2962
  _parse(input) {
2933
2963
  const { ctx } = this._processInputParams(input);
2934
2964
  if (ctx.parsedType !== ZodParsedType.promise &&
@@ -3168,24 +3198,30 @@
3168
3198
  const result = this._def.innerType._parse({
3169
3199
  data: ctx.data,
3170
3200
  path: ctx.path,
3171
- parent: ctx,
3201
+ parent: {
3202
+ ...ctx,
3203
+ common: {
3204
+ ...ctx.common,
3205
+ issues: [], // don't collect issues from inner type
3206
+ },
3207
+ },
3172
3208
  });
3173
3209
  if (isAsync(result)) {
3174
3210
  return result.then((result) => {
3175
3211
  return {
3176
3212
  status: "valid",
3177
- value: result.status === "valid" ? result.value : this._def.defaultValue(),
3213
+ value: result.status === "valid" ? result.value : this._def.catchValue(),
3178
3214
  };
3179
3215
  });
3180
3216
  }
3181
3217
  else {
3182
3218
  return {
3183
3219
  status: "valid",
3184
- value: result.status === "valid" ? result.value : this._def.defaultValue(),
3220
+ value: result.status === "valid" ? result.value : this._def.catchValue(),
3185
3221
  };
3186
3222
  }
3187
3223
  }
3188
- removeDefault() {
3224
+ removeCatch() {
3189
3225
  return this._def.innerType;
3190
3226
  }
3191
3227
  }
@@ -3193,9 +3229,7 @@
3193
3229
  return new ZodCatch({
3194
3230
  innerType: type,
3195
3231
  typeName: exports.ZodFirstPartyTypeKind.ZodCatch,
3196
- defaultValue: typeof params.default === "function"
3197
- ? params.default
3198
- : () => params.default,
3232
+ catchValue: typeof params.catch === "function" ? params.catch : () => params.catch,
3199
3233
  ...processCreateParams(params),
3200
3234
  });
3201
3235
  };
@@ -3390,7 +3424,10 @@
3390
3424
  const coerce = {
3391
3425
  string: ((arg) => ZodString.create({ ...arg, coerce: true })),
3392
3426
  number: ((arg) => ZodNumber.create({ ...arg, coerce: true })),
3393
- boolean: ((arg) => ZodBoolean.create({ ...arg, coerce: true })),
3427
+ boolean: ((arg) => ZodBoolean.create({
3428
+ ...arg,
3429
+ coerce: true,
3430
+ })),
3394
3431
  bigint: ((arg) => ZodBigInt.create({ ...arg, coerce: true })),
3395
3432
  date: ((arg) => ZodDate.create({ ...arg, coerce: true })),
3396
3433
  };
package/lib/types.d.ts CHANGED
@@ -72,7 +72,7 @@ export declare abstract class ZodType<Output = any, Def extends ZodTypeDef = Zod
72
72
  constructor(def: Def);
73
73
  optional(): ZodOptional<this>;
74
74
  nullable(): ZodNullable<this>;
75
- nullish(): ZodNullable<ZodOptional<this>>;
75
+ nullish(): ZodOptional<ZodNullable<this>>;
76
76
  array(): ZodArray<this>;
77
77
  promise(): ZodPromise<this>;
78
78
  or<T extends ZodTypeAny>(option: T): ZodUnion<[this, T]>;
@@ -81,8 +81,8 @@ export declare abstract class ZodType<Output = any, Def extends ZodTypeDef = Zod
81
81
  default(def: util.noUndefined<Input>): ZodDefault<this>;
82
82
  default(def: () => util.noUndefined<Input>): ZodDefault<this>;
83
83
  brand<B extends string | number | symbol>(brand?: B): ZodBranded<this, B>;
84
- catch(def: Input): ZodCatch<this>;
85
- catch(def: () => Input): ZodCatch<this>;
84
+ catch(def: Output): ZodCatch<this>;
85
+ catch(def: () => Output): ZodCatch<this>;
86
86
  describe(description: string): this;
87
87
  pipe<T extends ZodTypeAny>(target: T): ZodPipeline<this, T>;
88
88
  isOptional(): boolean;
@@ -112,6 +112,9 @@ export declare type ZodStringCheck = {
112
112
  } | {
113
113
  kind: "cuid";
114
114
  message?: string;
115
+ } | {
116
+ kind: "cuid2";
117
+ message?: string;
115
118
  } | {
116
119
  kind: "startsWith";
117
120
  value: string;
@@ -146,6 +149,7 @@ export declare class ZodString extends ZodType<string, ZodStringDef> {
146
149
  url(message?: errorUtil.ErrMessage): ZodString;
147
150
  uuid(message?: errorUtil.ErrMessage): ZodString;
148
151
  cuid(message?: errorUtil.ErrMessage): ZodString;
152
+ cuid2(message?: errorUtil.ErrMessage): ZodString;
149
153
  datetime(options?: string | {
150
154
  message?: string | undefined;
151
155
  precision?: number | null;
@@ -168,6 +172,7 @@ export declare class ZodString extends ZodType<string, ZodStringDef> {
168
172
  get isURL(): boolean;
169
173
  get isUUID(): boolean;
170
174
  get isCUID(): boolean;
175
+ get isCUID2(): boolean;
171
176
  get minLength(): number | null;
172
177
  get maxLength(): number | null;
173
178
  static create: (params?: ({
@@ -234,6 +239,7 @@ export declare class ZodNumber extends ZodType<number, ZodNumberDef> {
234
239
  get minValue(): number | null;
235
240
  get maxValue(): number | null;
236
241
  get isInt(): boolean;
242
+ get isFinite(): boolean;
237
243
  }
238
244
  export interface ZodBigIntDef extends ZodTypeDef {
239
245
  typeName: ZodFirstPartyTypeKind.ZodBigInt;
@@ -420,8 +426,14 @@ export declare type objectInputType<Shape extends ZodRawShape, Catchall extends
420
426
  [k: string]: Catchall["_input"];
421
427
  }>;
422
428
  export declare type deoptional<T extends ZodTypeAny> = T extends ZodOptional<infer U> ? deoptional<U> : T extends ZodNullable<infer U> ? ZodNullable<deoptional<U>> : T;
423
- export declare type SomeZodObject = ZodObject<ZodRawShape, UnknownKeysParam, ZodTypeAny, any, any>;
424
- export declare class ZodObject<T extends ZodRawShape, UnknownKeys extends UnknownKeysParam = "strip", Catchall extends ZodTypeAny = ZodTypeAny, Output = objectOutputType<T, Catchall>, Input = objectInputType<T, Catchall>> extends ZodType<Output, ZodObjectDef<T, UnknownKeys, Catchall>, Input> {
429
+ export declare type SomeZodObject = ZodObject<ZodRawShape, UnknownKeysParam, ZodTypeAny>;
430
+ export declare type objectKeyMask<Obj> = {
431
+ [k in keyof Obj]?: true;
432
+ };
433
+ export declare type noUnrecognized<Obj extends object, Shape extends object> = {
434
+ [k in keyof Obj]: k extends keyof Shape ? Obj[k] : never;
435
+ };
436
+ export declare class ZodObject<T extends ZodRawShape, UnknownKeys extends UnknownKeysParam, Catchall extends ZodTypeAny = ZodTypeAny, Output = objectOutputType<T, Catchall>, Input = objectInputType<T, Catchall>> extends ZodType<Output, ZodObjectDef<T, UnknownKeys, Catchall>, Input> {
425
437
  private _cached;
426
438
  _getCached(): {
427
439
  shape: T;
@@ -449,27 +461,19 @@ export declare class ZodObject<T extends ZodRawShape, UnknownKeys extends Unknow
449
461
  */
450
462
  merge<Incoming extends AnyZodObject>(merging: Incoming): ZodObject<extendShape<T, ReturnType<Incoming["_def"]["shape"]>>, Incoming["_def"]["unknownKeys"], Incoming["_def"]["catchall"]>;
451
463
  catchall<Index extends ZodTypeAny>(index: Index): ZodObject<T, UnknownKeys, Index>;
452
- pick<Mask extends {
453
- [k in keyof T]?: true;
454
- }>(mask: Mask): ZodObject<Pick<T, Extract<keyof T, keyof Mask>>, UnknownKeys, Catchall>;
455
- omit<Mask extends {
456
- [k in keyof T]?: true;
457
- }>(mask: Mask): ZodObject<Omit<T, keyof Mask>, UnknownKeys, Catchall>;
464
+ pick<Mask extends objectKeyMask<T>>(mask: noUnrecognized<Mask, T>): ZodObject<Pick<T, Extract<keyof T, keyof Mask>>, UnknownKeys, Catchall>;
465
+ omit<Mask extends objectKeyMask<T>>(mask: noUnrecognized<Mask, objectKeyMask<T>>): ZodObject<Omit<T, keyof Mask>, UnknownKeys, Catchall>;
458
466
  deepPartial(): partialUtil.DeepPartial<this>;
459
467
  partial(): ZodObject<{
460
468
  [k in keyof T]: ZodOptional<T[k]>;
461
469
  }, UnknownKeys, Catchall>;
462
- partial<Mask extends {
463
- [k in keyof T]?: true;
464
- }>(mask: Mask): ZodObject<objectUtil.noNever<{
470
+ partial<Mask extends objectKeyMask<T>>(mask: noUnrecognized<Mask, objectKeyMask<T>>): ZodObject<objectUtil.noNever<{
465
471
  [k in keyof T]: k extends keyof Mask ? ZodOptional<T[k]> : T[k];
466
472
  }>, UnknownKeys, Catchall>;
467
473
  required(): ZodObject<{
468
474
  [k in keyof T]: deoptional<T[k]>;
469
475
  }, UnknownKeys, Catchall>;
470
- required<Mask extends {
471
- [k in keyof T]?: true;
472
- }>(mask: Mask): ZodObject<objectUtil.noNever<{
476
+ required<Mask extends objectKeyMask<T>>(mask: noUnrecognized<Mask, objectKeyMask<T>>): ZodObject<objectUtil.noNever<{
473
477
  [k in keyof T]: k extends keyof Mask ? deoptional<T[k]> : T[k];
474
478
  }>, UnknownKeys, Catchall>;
475
479
  keyof(): ZodEnum<enumUtil.UnionToTupleString<keyof T>>;
@@ -494,8 +498,8 @@ export declare class ZodUnion<T extends ZodUnionOptions> extends ZodType<T[numbe
494
498
  }
495
499
  export declare type ZodDiscriminatedUnionOption<Discriminator extends string> = ZodObject<{
496
500
  [key in Discriminator]: ZodTypeAny;
497
- } & ZodRawShape, any, any>;
498
- export interface ZodDiscriminatedUnionDef<Discriminator extends string, Options extends ZodDiscriminatedUnionOption<any>[] = ZodDiscriminatedUnionOption<any>[]> extends ZodTypeDef {
501
+ } & ZodRawShape, UnknownKeysParam, ZodTypeAny>;
502
+ export interface ZodDiscriminatedUnionDef<Discriminator extends string, Options extends ZodDiscriminatedUnionOption<string>[] = ZodDiscriminatedUnionOption<string>[]> extends ZodTypeDef {
499
503
  discriminator: Discriminator;
500
504
  options: Options;
501
505
  optionsMap: Map<Primitive, ZodDiscriminatedUnionOption<any>>;
@@ -651,6 +655,7 @@ export interface ZodEnumDef<T extends EnumValues = EnumValues> extends ZodTypeDe
651
655
  export declare type Writeable<T> = {
652
656
  -readonly [P in keyof T]: T[P];
653
657
  };
658
+ export declare type FilterEnum<Values, ToExclude> = Values extends [] ? [] : Values extends [infer Head, ...infer Rest] ? Head extends ToExclude ? FilterEnum<Rest, ToExclude> : [Head, ...FilterEnum<Rest, ToExclude>] : never;
654
659
  declare function createZodEnum<U extends string, T extends Readonly<[U, ...U[]]>>(values: T, params?: RawCreateParams): ZodEnum<Writeable<T>>;
655
660
  declare function createZodEnum<U extends string, T extends [U, ...U[]]>(values: T, params?: RawCreateParams): ZodEnum<T>;
656
661
  export declare class ZodEnum<T extends [string, ...string[]]> extends ZodType<T[number], ZodEnumDef<T>> {
@@ -659,6 +664,8 @@ export declare class ZodEnum<T extends [string, ...string[]]> extends ZodType<T[
659
664
  get enum(): Values<T>;
660
665
  get Values(): Values<T>;
661
666
  get Enum(): Values<T>;
667
+ extract<ToExtract extends readonly [T[number], ...T[number][]]>(values: ToExtract): ZodEnum<Writeable<ToExtract>>;
668
+ exclude<ToExclude extends readonly [T[number], ...T[number][]]>(values: ToExclude): ZodEnum<Writeable<FilterEnum<T, ToExclude[number]>>>;
662
669
  static create: typeof createZodEnum;
663
670
  }
664
671
  export interface ZodNativeEnumDef<T extends EnumLike = EnumLike> extends ZodTypeDef {
@@ -679,6 +686,7 @@ export interface ZodPromiseDef<T extends ZodTypeAny = ZodTypeAny> extends ZodTyp
679
686
  typeName: ZodFirstPartyTypeKind.ZodPromise;
680
687
  }
681
688
  export declare class ZodPromise<T extends ZodTypeAny> extends ZodType<Promise<T["_output"]>, ZodPromiseDef<T>, Promise<T["_input"]>> {
689
+ unwrap(): T;
682
690
  _parse(input: ParseInput): ParseReturnType<this["_output"]>;
683
691
  static create: <T_1 extends ZodTypeAny>(schema: T_1, params?: RawCreateParams) => ZodPromise<T_1>;
684
692
  }
@@ -747,21 +755,21 @@ export declare class ZodDefault<T extends ZodTypeAny> extends ZodType<util.noUnd
747
755
  default: T_1["_input"] | (() => util.noUndefined<T_1["_input"]>);
748
756
  }) => ZodDefault<T_1>;
749
757
  }
750
- export interface ZodCatchDef<T extends ZodTypeAny = ZodTypeAny> extends ZodTypeDef {
758
+ export interface ZodCatchDef<T extends ZodTypeAny = ZodTypeAny, C extends T["_input"] = T["_input"]> extends ZodTypeDef {
751
759
  innerType: T;
752
- defaultValue: () => T["_input"];
760
+ catchValue: () => C;
753
761
  typeName: ZodFirstPartyTypeKind.ZodCatch;
754
762
  }
755
- export declare class ZodCatch<T extends ZodTypeAny> extends ZodType<util.noUndefined<T["_output"]>, ZodCatchDef<T>, T["_input"] | undefined> {
763
+ export declare class ZodCatch<T extends ZodTypeAny> extends ZodType<T["_output"], ZodCatchDef<T>, T["_input"]> {
756
764
  _parse(input: ParseInput): ParseReturnType<this["_output"]>;
757
- removeDefault(): T;
765
+ removeCatch(): T;
758
766
  static create: <T_1 extends ZodTypeAny>(type: T_1, params: {
759
767
  errorMap?: ZodErrorMap | undefined;
760
768
  invalid_type_error?: string | undefined;
761
769
  required_error?: string | undefined;
762
770
  description?: string | undefined;
763
771
  } & {
764
- default: T_1["_input"] | (() => T_1["_input"]);
772
+ catch: T_1["_output"] | (() => T_1["_output"]);
765
773
  }) => ZodCatch<T_1>;
766
774
  }
767
775
  export interface ZodNaNDef extends ZodTypeDef {
@@ -836,7 +844,7 @@ export declare enum ZodFirstPartyTypeKind {
836
844
  ZodBranded = "ZodBranded",
837
845
  ZodPipeline = "ZodPipeline"
838
846
  }
839
- export declare type ZodFirstPartySchemaTypes = ZodString | ZodNumber | ZodNaN | ZodBigInt | ZodBoolean | ZodDate | ZodUndefined | ZodNull | ZodAny | ZodUnknown | ZodNever | ZodVoid | ZodArray<any, any> | ZodObject<any, any, 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>;
847
+ 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>;
840
848
  declare abstract class Class {
841
849
  constructor(..._: any[]);
842
850
  }