zod 3.20.2 → 3.20.6

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);
@@ -1765,15 +1808,6 @@
1765
1808
  };
1766
1809
  };
1767
1810
  })(exports.objectUtil || (exports.objectUtil = {}));
1768
- const AugmentFactory = (def) => (augmentation) => {
1769
- return new ZodObject({
1770
- ...def,
1771
- shape: () => ({
1772
- ...def.shape(),
1773
- ...augmentation,
1774
- }),
1775
- });
1776
- };
1777
1811
  function deepPartialify(schema) {
1778
1812
  if (schema instanceof ZodObject) {
1779
1813
  const newShape = {};
@@ -1811,8 +1845,43 @@
1811
1845
  * If you want to pass through unknown properties, use `.passthrough()` instead.
1812
1846
  */
1813
1847
  this.nonstrict = this.passthrough;
1814
- this.augment = AugmentFactory(this._def);
1815
- this.extend = AugmentFactory(this._def);
1848
+ // extend<
1849
+ // Augmentation extends ZodRawShape,
1850
+ // NewOutput extends util.flatten<{
1851
+ // [k in keyof Augmentation | keyof Output]: k extends keyof Augmentation
1852
+ // ? Augmentation[k]["_output"]
1853
+ // : k extends keyof Output
1854
+ // ? Output[k]
1855
+ // : never;
1856
+ // }>,
1857
+ // NewInput extends util.flatten<{
1858
+ // [k in keyof Augmentation | keyof Input]: k extends keyof Augmentation
1859
+ // ? Augmentation[k]["_input"]
1860
+ // : k extends keyof Input
1861
+ // ? Input[k]
1862
+ // : never;
1863
+ // }>
1864
+ // >(
1865
+ // augmentation: Augmentation
1866
+ // ): ZodObject<
1867
+ // extendShape<T, Augmentation>,
1868
+ // UnknownKeys,
1869
+ // Catchall,
1870
+ // NewOutput,
1871
+ // NewInput
1872
+ // > {
1873
+ // return new ZodObject({
1874
+ // ...this._def,
1875
+ // shape: () => ({
1876
+ // ...this._def.shape(),
1877
+ // ...augmentation,
1878
+ // }),
1879
+ // }) as any;
1880
+ // }
1881
+ /**
1882
+ * @deprecated Use `.extend` instead
1883
+ * */
1884
+ this.augment = this.extend;
1816
1885
  }
1817
1886
  _getCached() {
1818
1887
  if (this._cached !== null)
@@ -1949,8 +2018,31 @@
1949
2018
  unknownKeys: "passthrough",
1950
2019
  });
1951
2020
  }
1952
- setKey(key, schema) {
1953
- return this.augment({ [key]: schema });
2021
+ // const AugmentFactory =
2022
+ // <Def extends ZodObjectDef>(def: Def) =>
2023
+ // <Augmentation extends ZodRawShape>(
2024
+ // augmentation: Augmentation
2025
+ // ): ZodObject<
2026
+ // extendShape<ReturnType<Def["shape"]>, Augmentation>,
2027
+ // Def["unknownKeys"],
2028
+ // Def["catchall"]
2029
+ // > => {
2030
+ // return new ZodObject({
2031
+ // ...def,
2032
+ // shape: () => ({
2033
+ // ...def.shape(),
2034
+ // ...augmentation,
2035
+ // }),
2036
+ // }) as any;
2037
+ // };
2038
+ extend(augmentation) {
2039
+ return new ZodObject({
2040
+ ...this._def,
2041
+ shape: () => ({
2042
+ ...this._def.shape(),
2043
+ ...augmentation,
2044
+ }),
2045
+ });
1954
2046
  }
1955
2047
  /**
1956
2048
  * Prior to zod@1.0.12 there was a bug in the
@@ -1958,10 +2050,6 @@
1958
2050
  * upgrade if you are experiencing issues.
1959
2051
  */
1960
2052
  merge(merging) {
1961
- // const mergedShape = objectUtil.mergeShapes(
1962
- // this._def.shape(),
1963
- // merging._def.shape()
1964
- // );
1965
2053
  const merged = new ZodObject({
1966
2054
  unknownKeys: merging._def.unknownKeys,
1967
2055
  catchall: merging._def.catchall,
@@ -1970,6 +2058,65 @@
1970
2058
  });
1971
2059
  return merged;
1972
2060
  }
2061
+ // merge<
2062
+ // Incoming extends AnyZodObject,
2063
+ // Augmentation extends Incoming["shape"],
2064
+ // NewOutput extends {
2065
+ // [k in keyof Augmentation | keyof Output]: k extends keyof Augmentation
2066
+ // ? Augmentation[k]["_output"]
2067
+ // : k extends keyof Output
2068
+ // ? Output[k]
2069
+ // : never;
2070
+ // },
2071
+ // NewInput extends {
2072
+ // [k in keyof Augmentation | keyof Input]: k extends keyof Augmentation
2073
+ // ? Augmentation[k]["_input"]
2074
+ // : k extends keyof Input
2075
+ // ? Input[k]
2076
+ // : never;
2077
+ // }
2078
+ // >(
2079
+ // merging: Incoming
2080
+ // ): ZodObject<
2081
+ // extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
2082
+ // Incoming["_def"]["unknownKeys"],
2083
+ // Incoming["_def"]["catchall"],
2084
+ // NewOutput,
2085
+ // NewInput
2086
+ // > {
2087
+ // const merged: any = new ZodObject({
2088
+ // unknownKeys: merging._def.unknownKeys,
2089
+ // catchall: merging._def.catchall,
2090
+ // shape: () =>
2091
+ // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
2092
+ // typeName: ZodFirstPartyTypeKind.ZodObject,
2093
+ // }) as any;
2094
+ // return merged;
2095
+ // }
2096
+ setKey(key, schema) {
2097
+ return this.augment({ [key]: schema });
2098
+ }
2099
+ // merge<Incoming extends AnyZodObject>(
2100
+ // merging: Incoming
2101
+ // ): //ZodObject<T & Incoming["_shape"], UnknownKeys, Catchall> = (merging) => {
2102
+ // ZodObject<
2103
+ // extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
2104
+ // Incoming["_def"]["unknownKeys"],
2105
+ // Incoming["_def"]["catchall"]
2106
+ // > {
2107
+ // // const mergedShape = objectUtil.mergeShapes(
2108
+ // // this._def.shape(),
2109
+ // // merging._def.shape()
2110
+ // // );
2111
+ // const merged: any = new ZodObject({
2112
+ // unknownKeys: merging._def.unknownKeys,
2113
+ // catchall: merging._def.catchall,
2114
+ // shape: () =>
2115
+ // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
2116
+ // typeName: ZodFirstPartyTypeKind.ZodObject,
2117
+ // }) as any;
2118
+ // return merged;
2119
+ // }
1973
2120
  catchall(index) {
1974
2121
  return new ZodObject({
1975
2122
  ...this._def,
@@ -1978,10 +2125,10 @@
1978
2125
  }
1979
2126
  pick(mask) {
1980
2127
  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])
2128
+ exports.util.objectKeys(mask).forEach((key) => {
2129
+ if (mask[key] && this.shape[key]) {
1984
2130
  shape[key] = this.shape[key];
2131
+ }
1985
2132
  });
1986
2133
  return new ZodObject({
1987
2134
  ...this._def,
@@ -1990,8 +2137,8 @@
1990
2137
  }
1991
2138
  omit(mask) {
1992
2139
  const shape = {};
1993
- exports.util.objectKeys(this.shape).map((key) => {
1994
- if (exports.util.objectKeys(mask).indexOf(key) === -1) {
2140
+ exports.util.objectKeys(this.shape).forEach((key) => {
2141
+ if (!mask[key]) {
1995
2142
  shape[key] = this.shape[key];
1996
2143
  }
1997
2144
  });
@@ -2005,26 +2152,15 @@
2005
2152
  }
2006
2153
  partial(mask) {
2007
2154
  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];
2155
+ exports.util.objectKeys(this.shape).forEach((key) => {
2156
+ const fieldSchema = this.shape[key];
2157
+ if (mask && !mask[key]) {
2158
+ newShape[key] = fieldSchema;
2159
+ }
2160
+ else {
2025
2161
  newShape[key] = fieldSchema.optional();
2026
2162
  }
2027
- }
2163
+ });
2028
2164
  return new ZodObject({
2029
2165
  ...this._def,
2030
2166
  shape: () => newShape,
@@ -2032,23 +2168,11 @@
2032
2168
  }
2033
2169
  required(mask) {
2034
2170
  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) {
2171
+ exports.util.objectKeys(this.shape).forEach((key) => {
2172
+ if (mask && !mask[key]) {
2173
+ newShape[key] = this.shape[key];
2174
+ }
2175
+ else {
2052
2176
  const fieldSchema = this.shape[key];
2053
2177
  let newField = fieldSchema;
2054
2178
  while (newField instanceof ZodOptional) {
@@ -2056,7 +2180,7 @@
2056
2180
  }
2057
2181
  newShape[key] = newField;
2058
2182
  }
2059
- }
2183
+ });
2060
2184
  return new ZodObject({
2061
2185
  ...this._def,
2062
2186
  shape: () => newShape,
@@ -2437,7 +2561,7 @@
2437
2561
  });
2438
2562
  status.dirty();
2439
2563
  }
2440
- const items = ctx.data
2564
+ const items = [...ctx.data]
2441
2565
  .map((item, itemIndex) => {
2442
2566
  const schema = this._def.items[itemIndex] || this._def.rest;
2443
2567
  if (!schema)
@@ -2817,6 +2941,7 @@
2817
2941
  if (input.data !== this._def.value) {
2818
2942
  const ctx = this._getOrReturnCtx(input);
2819
2943
  addIssueToContext(ctx, {
2944
+ received: ctx.data,
2820
2945
  code: ZodIssueCode.invalid_literal,
2821
2946
  expected: this._def.value,
2822
2947
  });
@@ -2890,6 +3015,12 @@
2890
3015
  }
2891
3016
  return enumValues;
2892
3017
  }
3018
+ extract(values) {
3019
+ return ZodEnum.create(values);
3020
+ }
3021
+ exclude(values) {
3022
+ return ZodEnum.create(this.options.filter((opt) => !values.includes(opt)));
3023
+ }
2893
3024
  }
2894
3025
  ZodEnum.create = createZodEnum;
2895
3026
  class ZodNativeEnum extends ZodType {
@@ -2929,6 +3060,9 @@
2929
3060
  });
2930
3061
  };
2931
3062
  class ZodPromise extends ZodType {
3063
+ unwrap() {
3064
+ return this._def.type;
3065
+ }
2932
3066
  _parse(input) {
2933
3067
  const { ctx } = this._processInputParams(input);
2934
3068
  if (ctx.parsedType !== ZodParsedType.promise &&
@@ -3168,24 +3302,30 @@
3168
3302
  const result = this._def.innerType._parse({
3169
3303
  data: ctx.data,
3170
3304
  path: ctx.path,
3171
- parent: ctx,
3305
+ parent: {
3306
+ ...ctx,
3307
+ common: {
3308
+ ...ctx.common,
3309
+ issues: [], // don't collect issues from inner type
3310
+ },
3311
+ },
3172
3312
  });
3173
3313
  if (isAsync(result)) {
3174
3314
  return result.then((result) => {
3175
3315
  return {
3176
3316
  status: "valid",
3177
- value: result.status === "valid" ? result.value : this._def.defaultValue(),
3317
+ value: result.status === "valid" ? result.value : this._def.catchValue(),
3178
3318
  };
3179
3319
  });
3180
3320
  }
3181
3321
  else {
3182
3322
  return {
3183
3323
  status: "valid",
3184
- value: result.status === "valid" ? result.value : this._def.defaultValue(),
3324
+ value: result.status === "valid" ? result.value : this._def.catchValue(),
3185
3325
  };
3186
3326
  }
3187
3327
  }
3188
- removeDefault() {
3328
+ removeCatch() {
3189
3329
  return this._def.innerType;
3190
3330
  }
3191
3331
  }
@@ -3193,9 +3333,7 @@
3193
3333
  return new ZodCatch({
3194
3334
  innerType: type,
3195
3335
  typeName: exports.ZodFirstPartyTypeKind.ZodCatch,
3196
- defaultValue: typeof params.default === "function"
3197
- ? params.default
3198
- : () => params.default,
3336
+ catchValue: typeof params.catch === "function" ? params.catch : () => params.catch,
3199
3337
  ...processCreateParams(params),
3200
3338
  });
3201
3339
  };
@@ -3390,7 +3528,10 @@
3390
3528
  const coerce = {
3391
3529
  string: ((arg) => ZodString.create({ ...arg, coerce: true })),
3392
3530
  number: ((arg) => ZodNumber.create({ ...arg, coerce: true })),
3393
- boolean: ((arg) => ZodBoolean.create({ ...arg, coerce: true })),
3531
+ boolean: ((arg) => ZodBoolean.create({
3532
+ ...arg,
3533
+ coerce: true,
3534
+ })),
3394
3535
  bigint: ((arg) => ZodBigInt.create({ ...arg, coerce: true })),
3395
3536
  date: ((arg) => ZodDate.create({ ...arg, coerce: true })),
3396
3537
  };