@exodus/zod 3.24.1-rc.2 → 3.24.1-rc.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.
@@ -10,13 +10,13 @@ export declare namespace util {
10
10
  export type Exactly<T, X> = T & Record<Exclude<keyof X, keyof T>, never>;
11
11
  export const arrayToEnum: <T extends string, U extends [T, ...T[]]>(items: U) => { [k in U[number]]: k; };
12
12
  export const getValidEnumValues: (obj: any) => any[];
13
- export const objectValues: (obj: any) => any[];
13
+ export const objectValues: ObjectConstructor["values"];
14
14
  export const objectKeys: ObjectConstructor["keys"];
15
15
  export const find: <T>(arr: T[], checker: (arg: T) => any) => T | undefined;
16
16
  export type identity<T> = objectUtil.identity<T>;
17
17
  export type flatten<T> = objectUtil.flatten<T>;
18
18
  export type noUndefined<T> = T extends undefined ? never : T;
19
- export const isInteger: NumberConstructor["isInteger"];
19
+ export const isInteger: (number: unknown) => boolean;
20
20
  export function joinValues<T extends any[]>(array: T, separator?: string): string;
21
21
  export const jsonStringifyReplacer: (_: string, value: any) => any;
22
22
  export {};
package/lib/index.mjs CHANGED
@@ -8,7 +8,7 @@ var util;
8
8
  }
9
9
  util.assertNever = assertNever;
10
10
  util.arrayToEnum = (items) => {
11
- const obj = {};
11
+ const obj = Object.create(null);
12
12
  for (const item of items) {
13
13
  obj[item] = item;
14
14
  }
@@ -16,28 +16,14 @@ var util;
16
16
  };
17
17
  util.getValidEnumValues = (obj) => {
18
18
  const validKeys = util.objectKeys(obj).filter((k) => typeof obj[obj[k]] !== "number");
19
- const filtered = {};
19
+ const filtered = Object.create(null);
20
20
  for (const k of validKeys) {
21
21
  filtered[k] = obj[k];
22
22
  }
23
23
  return util.objectValues(filtered);
24
24
  };
25
- util.objectValues = (obj) => {
26
- return util.objectKeys(obj).map(function (e) {
27
- return obj[e];
28
- });
29
- };
30
- util.objectKeys = typeof Object.keys === "function" // eslint-disable-line ban/ban
31
- ? (obj) => Object.keys(obj) // eslint-disable-line ban/ban
32
- : (object) => {
33
- const keys = [];
34
- for (const key in object) {
35
- if (Object.prototype.hasOwnProperty.call(object, key)) {
36
- keys.push(key);
37
- }
38
- }
39
- return keys;
40
- };
25
+ util.objectValues = Object.values;
26
+ util.objectKeys = Object.keys;
41
27
  util.find = (arr, checker) => {
42
28
  for (const item of arr) {
43
29
  if (checker(item))
@@ -45,9 +31,7 @@ var util;
45
31
  }
46
32
  return undefined;
47
33
  };
48
- util.isInteger = typeof Number.isInteger === "function"
49
- ? (val) => Number.isInteger(val) // eslint-disable-line ban/ban
50
- : (val) => typeof val === "number" && isFinite(val) && Math.floor(val) === val;
34
+ util.isInteger = Number.isInteger;
51
35
  function joinValues(array, separator = " | ") {
52
36
  return array
53
37
  .map((val) => (typeof val === "string" ? `'${val}'` : val))
@@ -160,18 +144,12 @@ const quotelessJson = (obj) => {
160
144
  return json.replace(/"([^"]+)":/g, "$1:");
161
145
  };
162
146
  class ZodError extends Error {
147
+ issues = [];
163
148
  get errors() {
164
149
  return this.issues;
165
150
  }
166
151
  constructor(issues) {
167
152
  super();
168
- this.issues = [];
169
- this.addIssue = (sub) => {
170
- this.issues = [...this.issues, sub];
171
- };
172
- this.addIssues = (subs = []) => {
173
- this.issues = [...this.issues, ...subs];
174
- };
175
153
  const actualProto = new.target.prototype;
176
154
  if (Object.setPrototypeOf) {
177
155
  // eslint-disable-next-line ban/ban
@@ -232,6 +210,10 @@ class ZodError extends Error {
232
210
  processError(this);
233
211
  return fieldErrors;
234
212
  }
213
+ static create = (issues) => {
214
+ const error = new ZodError(issues);
215
+ return error;
216
+ };
235
217
  static assert(value) {
236
218
  if (!(value instanceof ZodError)) {
237
219
  throw new Error(`Not a ZodError: ${value}`);
@@ -246,6 +228,12 @@ class ZodError extends Error {
246
228
  get isEmpty() {
247
229
  return this.issues.length === 0;
248
230
  }
231
+ addIssue = (sub) => {
232
+ this.issues = [...this.issues, sub];
233
+ };
234
+ addIssues = (subs = []) => {
235
+ this.issues = [...this.issues, ...subs];
236
+ };
249
237
  flatten(mapper = (issue) => issue.message) {
250
238
  const fieldErrors = {};
251
239
  const formErrors = [];
@@ -264,10 +252,6 @@ class ZodError extends Error {
264
252
  return this.flatten();
265
253
  }
266
254
  }
267
- ZodError.create = (issues) => {
268
- const error = new ZodError(issues);
269
- return error;
270
- };
271
255
 
272
256
  const errorMap = (issue, _ctx) => {
273
257
  let message;
@@ -447,9 +431,7 @@ function addIssueToContext(ctx, issueData) {
447
431
  ctx.common.issues.push(issue);
448
432
  }
449
433
  class ParseStatus {
450
- constructor() {
451
- this.value = "valid";
452
- }
434
+ value = "valid";
453
435
  dirty() {
454
436
  if (this.value === "valid")
455
437
  this.value = "dirty";
@@ -511,49 +493,19 @@ const isDirty = (x) => x.status === "dirty";
511
493
  const isValid = (x) => x.status === "valid";
512
494
  const isAsync = (x) => typeof Promise !== "undefined" && x instanceof Promise;
513
495
 
514
- /******************************************************************************
515
- Copyright (c) Microsoft Corporation.
516
-
517
- Permission to use, copy, modify, and/or distribute this software for any
518
- purpose with or without fee is hereby granted.
519
-
520
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
521
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
522
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
523
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
524
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
525
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
526
- PERFORMANCE OF THIS SOFTWARE.
527
- ***************************************************************************** */
528
-
529
- function __classPrivateFieldGet(receiver, state, kind, f) {
530
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
531
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
532
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
533
- }
534
-
535
- function __classPrivateFieldSet(receiver, state, value, kind, f) {
536
- if (kind === "m") throw new TypeError("Private method is not writable");
537
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
538
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
539
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
540
- }
541
-
542
- typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
543
- var e = new Error(message);
544
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
545
- };
546
-
547
496
  var errorUtil;
548
497
  (function (errorUtil) {
549
498
  errorUtil.errToObj = (message) => typeof message === "string" ? { message } : message || {};
550
- errorUtil.toString = (message) => typeof message === "string" ? message : message === null || message === void 0 ? void 0 : message.message;
499
+ errorUtil.toString = (message) => typeof message === "string" ? message : message?.message;
551
500
  })(errorUtil || (errorUtil = {}));
552
501
 
553
- var _ZodEnum_cache, _ZodNativeEnum_cache;
554
502
  class ParseInputLazyPath {
503
+ parent;
504
+ data;
505
+ _path;
506
+ _key;
507
+ _cachedPath = [];
555
508
  constructor(parent, value, path, key) {
556
- this._cachedPath = [];
557
509
  this.parent = parent;
558
510
  this.data = value;
559
511
  this._path = path;
@@ -601,24 +553,28 @@ function processCreateParams(params) {
601
553
  if (errorMap)
602
554
  return { errorMap: errorMap, description };
603
555
  const customMap = (iss, ctx) => {
604
- var _a, _b;
605
556
  const { message } = params;
606
557
  if (iss.code === "invalid_enum_value") {
607
- return { message: message !== null && message !== void 0 ? message : ctx.defaultError };
558
+ return { message: message ?? ctx.defaultError };
608
559
  }
609
560
  if (typeof ctx.data === "undefined") {
610
- return { message: (_a = message !== null && message !== void 0 ? message : required_error) !== null && _a !== void 0 ? _a : ctx.defaultError };
561
+ return { message: message ?? required_error ?? ctx.defaultError };
611
562
  }
612
563
  if (iss.code !== "invalid_type")
613
564
  return { message: ctx.defaultError };
614
- return { message: (_b = message !== null && message !== void 0 ? message : invalid_type_error) !== null && _b !== void 0 ? _b : ctx.defaultError };
565
+ return { message: message ?? invalid_type_error ?? ctx.defaultError };
615
566
  };
616
567
  return { errorMap: customMap, description };
617
568
  }
618
569
  class ZodType {
570
+ _type;
571
+ _output;
572
+ _input;
573
+ _def;
619
574
  get description() {
620
575
  return this._def.description;
621
576
  }
577
+ "~standard";
622
578
  _getType(input) {
623
579
  return getParsedType(input.data);
624
580
  }
@@ -663,14 +619,13 @@ class ZodType {
663
619
  throw result.error;
664
620
  }
665
621
  safeParse(data, params) {
666
- var _a;
667
622
  const ctx = {
668
623
  common: {
669
624
  issues: [],
670
- async: (_a = params === null || params === void 0 ? void 0 : params.async) !== null && _a !== void 0 ? _a : false,
671
- contextualErrorMap: params === null || params === void 0 ? void 0 : params.errorMap,
625
+ async: params?.async ?? false,
626
+ contextualErrorMap: params?.errorMap,
672
627
  },
673
- path: (params === null || params === void 0 ? void 0 : params.path) || [],
628
+ path: params?.path || [],
674
629
  schemaErrorMap: this._def.errorMap,
675
630
  parent: null,
676
631
  data,
@@ -680,7 +635,6 @@ class ZodType {
680
635
  return handleResult(ctx, result);
681
636
  }
682
637
  "~validate"(data) {
683
- var _a, _b;
684
638
  const ctx = {
685
639
  common: {
686
640
  issues: [],
@@ -704,7 +658,7 @@ class ZodType {
704
658
  };
705
659
  }
706
660
  catch (err) {
707
- if ((_b = (_a = err === null || err === void 0 ? void 0 : err.message) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === null || _b === void 0 ? void 0 : _b.includes("encountered")) {
661
+ if (err?.message?.toLowerCase()?.includes("encountered")) {
708
662
  this["~standard"].async = true;
709
663
  }
710
664
  ctx.common = {
@@ -731,10 +685,10 @@ class ZodType {
731
685
  const ctx = {
732
686
  common: {
733
687
  issues: [],
734
- contextualErrorMap: params === null || params === void 0 ? void 0 : params.errorMap,
688
+ contextualErrorMap: params?.errorMap,
735
689
  async: true,
736
690
  },
737
- path: (params === null || params === void 0 ? void 0 : params.path) || [],
691
+ path: params?.path || [],
738
692
  schemaErrorMap: this._def.errorMap,
739
693
  parent: null,
740
694
  data,
@@ -746,6 +700,8 @@ class ZodType {
746
700
  : Promise.resolve(maybeAsyncResult));
747
701
  return handleResult(ctx, result);
748
702
  }
703
+ /** Alias of safeParseAsync */
704
+ spa = this.safeParseAsync;
749
705
  refine(check, message) {
750
706
  const getIssueProperties = (val) => {
751
707
  if (typeof message === "string" || typeof message === "undefined") {
@@ -808,8 +764,6 @@ class ZodType {
808
764
  return this._refinement(refinement);
809
765
  }
810
766
  constructor(def) {
811
- /** Alias of safeParseAsync */
812
- this.spa = this.safeParseAsync;
813
767
  this._def = def;
814
768
  this.parse = this.parse.bind(this);
815
769
  this.safeParse = this.safeParse.bind(this);
@@ -1012,7 +966,7 @@ function isValidJWT(jwt, alg) {
1012
966
  return false;
1013
967
  return true;
1014
968
  }
1015
- catch (_a) {
969
+ catch {
1016
970
  return false;
1017
971
  }
1018
972
  }
@@ -1183,7 +1137,7 @@ class ZodString extends ZodType {
1183
1137
  try {
1184
1138
  new URL(input.data);
1185
1139
  }
1186
- catch (_a) {
1140
+ catch {
1187
1141
  ctx = this._getOrReturnCtx(input, ctx);
1188
1142
  addIssueToContext(ctx, {
1189
1143
  validation: "url",
@@ -1413,7 +1367,6 @@ class ZodString extends ZodType {
1413
1367
  return this._addCheck({ kind: "cidr", ...errorUtil.errToObj(options) });
1414
1368
  }
1415
1369
  datetime(options) {
1416
- var _a, _b;
1417
1370
  if (typeof options === "string") {
1418
1371
  return this._addCheck({
1419
1372
  kind: "datetime",
@@ -1425,10 +1378,10 @@ class ZodString extends ZodType {
1425
1378
  }
1426
1379
  return this._addCheck({
1427
1380
  kind: "datetime",
1428
- precision: typeof (options === null || options === void 0 ? void 0 : options.precision) === "undefined" ? null : options === null || options === void 0 ? void 0 : options.precision,
1429
- offset: (_a = options === null || options === void 0 ? void 0 : options.offset) !== null && _a !== void 0 ? _a : false,
1430
- local: (_b = options === null || options === void 0 ? void 0 : options.local) !== null && _b !== void 0 ? _b : false,
1431
- ...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message),
1381
+ precision: typeof options?.precision === "undefined" ? null : options?.precision,
1382
+ offset: options?.offset ?? false,
1383
+ local: options?.local ?? false,
1384
+ ...errorUtil.errToObj(options?.message),
1432
1385
  });
1433
1386
  }
1434
1387
  date(message) {
@@ -1444,8 +1397,8 @@ class ZodString extends ZodType {
1444
1397
  }
1445
1398
  return this._addCheck({
1446
1399
  kind: "time",
1447
- precision: typeof (options === null || options === void 0 ? void 0 : options.precision) === "undefined" ? null : options === null || options === void 0 ? void 0 : options.precision,
1448
- ...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message),
1400
+ precision: typeof options?.precision === "undefined" ? null : options?.precision,
1401
+ ...errorUtil.errToObj(options?.message),
1449
1402
  });
1450
1403
  }
1451
1404
  duration(message) {
@@ -1462,8 +1415,8 @@ class ZodString extends ZodType {
1462
1415
  return this._addCheck({
1463
1416
  kind: "includes",
1464
1417
  value: value,
1465
- position: options === null || options === void 0 ? void 0 : options.position,
1466
- ...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message),
1418
+ position: options?.position,
1419
+ ...errorUtil.errToObj(options?.message),
1467
1420
  });
1468
1421
  }
1469
1422
  startsWith(value, message) {
@@ -1594,16 +1547,15 @@ class ZodString extends ZodType {
1594
1547
  }
1595
1548
  return max;
1596
1549
  }
1550
+ static create = (params) => {
1551
+ return new ZodString({
1552
+ checks: [],
1553
+ typeName: ZodFirstPartyTypeKind.ZodString,
1554
+ coerce: params?.coerce ?? false,
1555
+ ...processCreateParams(params),
1556
+ });
1557
+ };
1597
1558
  }
1598
- ZodString.create = (params) => {
1599
- var _a;
1600
- return new ZodString({
1601
- checks: [],
1602
- typeName: ZodFirstPartyTypeKind.ZodString,
1603
- coerce: (_a = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a !== void 0 ? _a : false,
1604
- ...processCreateParams(params),
1605
- });
1606
- };
1607
1559
  // https://stackoverflow.com/questions/3966484/why-does-modulus-operator-return-fractional-number-in-javascript/31711034#31711034
1608
1560
  function floatSafeRemainder(val, step) {
1609
1561
  const valDecCount = (val.toString().split(".")[1] || "").length;
@@ -1614,12 +1566,6 @@ function floatSafeRemainder(val, step) {
1614
1566
  return (valInt % stepInt) / Math.pow(10, decCount);
1615
1567
  }
1616
1568
  class ZodNumber extends ZodType {
1617
- constructor() {
1618
- super(...arguments);
1619
- this.min = this.gte;
1620
- this.max = this.lte;
1621
- this.step = this.multipleOf;
1622
- }
1623
1569
  _parse(input) {
1624
1570
  if (this._def.coerce) {
1625
1571
  input.data = Number(input.data);
@@ -1710,15 +1656,25 @@ class ZodNumber extends ZodType {
1710
1656
  }
1711
1657
  return { status: status.value, value: input.data };
1712
1658
  }
1659
+ static create = (params) => {
1660
+ return new ZodNumber({
1661
+ checks: [],
1662
+ typeName: ZodFirstPartyTypeKind.ZodNumber,
1663
+ coerce: params?.coerce || false,
1664
+ ...processCreateParams(params),
1665
+ });
1666
+ };
1713
1667
  gte(value, message) {
1714
1668
  return this.setLimit("min", value, true, errorUtil.toString(message));
1715
1669
  }
1670
+ min = this.gte;
1716
1671
  gt(value, message) {
1717
1672
  return this.setLimit("min", value, false, errorUtil.toString(message));
1718
1673
  }
1719
1674
  lte(value, message) {
1720
1675
  return this.setLimit("max", value, true, errorUtil.toString(message));
1721
1676
  }
1677
+ max = this.lte;
1722
1678
  lt(value, message) {
1723
1679
  return this.setLimit("max", value, false, errorUtil.toString(message));
1724
1680
  }
@@ -1787,6 +1743,7 @@ class ZodNumber extends ZodType {
1787
1743
  message: errorUtil.toString(message),
1788
1744
  });
1789
1745
  }
1746
+ step = this.multipleOf;
1790
1747
  finite(message) {
1791
1748
  return this._addCheck({
1792
1749
  kind: "finite",
@@ -1850,26 +1807,13 @@ class ZodNumber extends ZodType {
1850
1807
  return Number.isFinite(min) && Number.isFinite(max);
1851
1808
  }
1852
1809
  }
1853
- ZodNumber.create = (params) => {
1854
- return new ZodNumber({
1855
- checks: [],
1856
- typeName: ZodFirstPartyTypeKind.ZodNumber,
1857
- coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false,
1858
- ...processCreateParams(params),
1859
- });
1860
- };
1861
1810
  class ZodBigInt extends ZodType {
1862
- constructor() {
1863
- super(...arguments);
1864
- this.min = this.gte;
1865
- this.max = this.lte;
1866
- }
1867
1811
  _parse(input) {
1868
1812
  if (this._def.coerce) {
1869
1813
  try {
1870
1814
  input.data = BigInt(input.data);
1871
1815
  }
1872
- catch (_a) {
1816
+ catch {
1873
1817
  return this._getInvalidInput(input);
1874
1818
  }
1875
1819
  }
@@ -1938,15 +1882,25 @@ class ZodBigInt extends ZodType {
1938
1882
  });
1939
1883
  return INVALID;
1940
1884
  }
1885
+ static create = (params) => {
1886
+ return new ZodBigInt({
1887
+ checks: [],
1888
+ typeName: ZodFirstPartyTypeKind.ZodBigInt,
1889
+ coerce: params?.coerce ?? false,
1890
+ ...processCreateParams(params),
1891
+ });
1892
+ };
1941
1893
  gte(value, message) {
1942
1894
  return this.setLimit("min", value, true, errorUtil.toString(message));
1943
1895
  }
1896
+ min = this.gte;
1944
1897
  gt(value, message) {
1945
1898
  return this.setLimit("min", value, false, errorUtil.toString(message));
1946
1899
  }
1947
1900
  lte(value, message) {
1948
1901
  return this.setLimit("max", value, true, errorUtil.toString(message));
1949
1902
  }
1903
+ max = this.lte;
1950
1904
  lt(value, message) {
1951
1905
  return this.setLimit("max", value, false, errorUtil.toString(message));
1952
1906
  }
@@ -2030,15 +1984,6 @@ class ZodBigInt extends ZodType {
2030
1984
  return max;
2031
1985
  }
2032
1986
  }
2033
- ZodBigInt.create = (params) => {
2034
- var _a;
2035
- return new ZodBigInt({
2036
- checks: [],
2037
- typeName: ZodFirstPartyTypeKind.ZodBigInt,
2038
- coerce: (_a = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a !== void 0 ? _a : false,
2039
- ...processCreateParams(params),
2040
- });
2041
- };
2042
1987
  class ZodBoolean extends ZodType {
2043
1988
  _parse(input) {
2044
1989
  if (this._def.coerce) {
@@ -2056,14 +2001,14 @@ class ZodBoolean extends ZodType {
2056
2001
  }
2057
2002
  return OK(input.data);
2058
2003
  }
2004
+ static create = (params) => {
2005
+ return new ZodBoolean({
2006
+ typeName: ZodFirstPartyTypeKind.ZodBoolean,
2007
+ coerce: params?.coerce || false,
2008
+ ...processCreateParams(params),
2009
+ });
2010
+ };
2059
2011
  }
2060
- ZodBoolean.create = (params) => {
2061
- return new ZodBoolean({
2062
- typeName: ZodFirstPartyTypeKind.ZodBoolean,
2063
- coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false,
2064
- ...processCreateParams(params),
2065
- });
2066
- };
2067
2012
  class ZodDate extends ZodType {
2068
2013
  _parse(input) {
2069
2014
  if (this._def.coerce) {
@@ -2166,15 +2111,15 @@ class ZodDate extends ZodType {
2166
2111
  }
2167
2112
  return max != null ? new Date(max) : null;
2168
2113
  }
2114
+ static create = (params) => {
2115
+ return new ZodDate({
2116
+ checks: [],
2117
+ coerce: params?.coerce || false,
2118
+ typeName: ZodFirstPartyTypeKind.ZodDate,
2119
+ ...processCreateParams(params),
2120
+ });
2121
+ };
2169
2122
  }
2170
- ZodDate.create = (params) => {
2171
- return new ZodDate({
2172
- checks: [],
2173
- coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false,
2174
- typeName: ZodFirstPartyTypeKind.ZodDate,
2175
- ...processCreateParams(params),
2176
- });
2177
- };
2178
2123
  class ZodSymbol extends ZodType {
2179
2124
  _parse(input) {
2180
2125
  const parsedType = this._getType(input);
@@ -2189,13 +2134,13 @@ class ZodSymbol extends ZodType {
2189
2134
  }
2190
2135
  return OK(input.data);
2191
2136
  }
2137
+ static create = (params) => {
2138
+ return new ZodSymbol({
2139
+ typeName: ZodFirstPartyTypeKind.ZodSymbol,
2140
+ ...processCreateParams(params),
2141
+ });
2142
+ };
2192
2143
  }
2193
- ZodSymbol.create = (params) => {
2194
- return new ZodSymbol({
2195
- typeName: ZodFirstPartyTypeKind.ZodSymbol,
2196
- ...processCreateParams(params),
2197
- });
2198
- };
2199
2144
  class ZodUndefined extends ZodType {
2200
2145
  _parse(input) {
2201
2146
  const parsedType = this._getType(input);
@@ -2210,13 +2155,14 @@ class ZodUndefined extends ZodType {
2210
2155
  }
2211
2156
  return OK(input.data);
2212
2157
  }
2158
+ params;
2159
+ static create = (params) => {
2160
+ return new ZodUndefined({
2161
+ typeName: ZodFirstPartyTypeKind.ZodUndefined,
2162
+ ...processCreateParams(params),
2163
+ });
2164
+ };
2213
2165
  }
2214
- ZodUndefined.create = (params) => {
2215
- return new ZodUndefined({
2216
- typeName: ZodFirstPartyTypeKind.ZodUndefined,
2217
- ...processCreateParams(params),
2218
- });
2219
- };
2220
2166
  class ZodNull extends ZodType {
2221
2167
  _parse(input) {
2222
2168
  const parsedType = this._getType(input);
@@ -2231,45 +2177,39 @@ class ZodNull extends ZodType {
2231
2177
  }
2232
2178
  return OK(input.data);
2233
2179
  }
2180
+ static create = (params) => {
2181
+ return new ZodNull({
2182
+ typeName: ZodFirstPartyTypeKind.ZodNull,
2183
+ ...processCreateParams(params),
2184
+ });
2185
+ };
2234
2186
  }
2235
- ZodNull.create = (params) => {
2236
- return new ZodNull({
2237
- typeName: ZodFirstPartyTypeKind.ZodNull,
2238
- ...processCreateParams(params),
2239
- });
2240
- };
2241
2187
  class ZodAny extends ZodType {
2242
- constructor() {
2243
- super(...arguments);
2244
- // to prevent instances of other classes from extending ZodAny. this causes issues with catchall in ZodObject.
2245
- this._any = true;
2246
- }
2188
+ // to prevent instances of other classes from extending ZodAny. this causes issues with catchall in ZodObject.
2189
+ _any = true;
2247
2190
  _parse(input) {
2248
2191
  return OK(input.data);
2249
2192
  }
2193
+ static create = (params) => {
2194
+ return new ZodAny({
2195
+ typeName: ZodFirstPartyTypeKind.ZodAny,
2196
+ ...processCreateParams(params),
2197
+ });
2198
+ };
2250
2199
  }
2251
- ZodAny.create = (params) => {
2252
- return new ZodAny({
2253
- typeName: ZodFirstPartyTypeKind.ZodAny,
2254
- ...processCreateParams(params),
2255
- });
2256
- };
2257
2200
  class ZodUnknown extends ZodType {
2258
- constructor() {
2259
- super(...arguments);
2260
- // required
2261
- this._unknown = true;
2262
- }
2201
+ // required
2202
+ _unknown = true;
2263
2203
  _parse(input) {
2264
2204
  return OK(input.data);
2265
2205
  }
2206
+ static create = (params) => {
2207
+ return new ZodUnknown({
2208
+ typeName: ZodFirstPartyTypeKind.ZodUnknown,
2209
+ ...processCreateParams(params),
2210
+ });
2211
+ };
2266
2212
  }
2267
- ZodUnknown.create = (params) => {
2268
- return new ZodUnknown({
2269
- typeName: ZodFirstPartyTypeKind.ZodUnknown,
2270
- ...processCreateParams(params),
2271
- });
2272
- };
2273
2213
  class ZodNever extends ZodType {
2274
2214
  _parse(input) {
2275
2215
  const ctx = this._getOrReturnCtx(input);
@@ -2280,13 +2220,13 @@ class ZodNever extends ZodType {
2280
2220
  });
2281
2221
  return INVALID;
2282
2222
  }
2223
+ static create = (params) => {
2224
+ return new ZodNever({
2225
+ typeName: ZodFirstPartyTypeKind.ZodNever,
2226
+ ...processCreateParams(params),
2227
+ });
2228
+ };
2283
2229
  }
2284
- ZodNever.create = (params) => {
2285
- return new ZodNever({
2286
- typeName: ZodFirstPartyTypeKind.ZodNever,
2287
- ...processCreateParams(params),
2288
- });
2289
- };
2290
2230
  class ZodVoid extends ZodType {
2291
2231
  _parse(input) {
2292
2232
  const parsedType = this._getType(input);
@@ -2301,13 +2241,13 @@ class ZodVoid extends ZodType {
2301
2241
  }
2302
2242
  return OK(input.data);
2303
2243
  }
2244
+ static create = (params) => {
2245
+ return new ZodVoid({
2246
+ typeName: ZodFirstPartyTypeKind.ZodVoid,
2247
+ ...processCreateParams(params),
2248
+ });
2249
+ };
2304
2250
  }
2305
- ZodVoid.create = (params) => {
2306
- return new ZodVoid({
2307
- typeName: ZodFirstPartyTypeKind.ZodVoid,
2308
- ...processCreateParams(params),
2309
- });
2310
- };
2311
2251
  class ZodArray extends ZodType {
2312
2252
  _parse(input) {
2313
2253
  const { ctx, status } = this._processInputParams(input);
@@ -2398,17 +2338,17 @@ class ZodArray extends ZodType {
2398
2338
  nonempty(message) {
2399
2339
  return this.min(1, message);
2400
2340
  }
2341
+ static create = (schema, params) => {
2342
+ return new ZodArray({
2343
+ type: schema,
2344
+ minLength: null,
2345
+ maxLength: null,
2346
+ exactLength: null,
2347
+ typeName: ZodFirstPartyTypeKind.ZodArray,
2348
+ ...processCreateParams(params),
2349
+ });
2350
+ };
2401
2351
  }
2402
- ZodArray.create = (schema, params) => {
2403
- return new ZodArray({
2404
- type: schema,
2405
- minLength: null,
2406
- maxLength: null,
2407
- exactLength: null,
2408
- typeName: ZodFirstPartyTypeKind.ZodArray,
2409
- ...processCreateParams(params),
2410
- });
2411
- };
2412
2352
  function deepPartialify(schema) {
2413
2353
  if (schema instanceof ZodObject) {
2414
2354
  const newShape = {};
@@ -2441,52 +2381,7 @@ function deepPartialify(schema) {
2441
2381
  }
2442
2382
  }
2443
2383
  class ZodObject extends ZodType {
2444
- constructor() {
2445
- super(...arguments);
2446
- this._cached = null;
2447
- /**
2448
- * @deprecated In most cases, this is no longer needed - unknown properties are now silently stripped.
2449
- * If you want to pass through unknown properties, use `.passthrough()` instead.
2450
- */
2451
- this.nonstrict = this.passthrough;
2452
- // extend<
2453
- // Augmentation extends ZodRawShape,
2454
- // NewOutput extends util.flatten<{
2455
- // [k in keyof Augmentation | keyof Output]: k extends keyof Augmentation
2456
- // ? Augmentation[k]["_output"]
2457
- // : k extends keyof Output
2458
- // ? Output[k]
2459
- // : never;
2460
- // }>,
2461
- // NewInput extends util.flatten<{
2462
- // [k in keyof Augmentation | keyof Input]: k extends keyof Augmentation
2463
- // ? Augmentation[k]["_input"]
2464
- // : k extends keyof Input
2465
- // ? Input[k]
2466
- // : never;
2467
- // }>
2468
- // >(
2469
- // augmentation: Augmentation
2470
- // ): ZodObject<
2471
- // extendShape<T, Augmentation>,
2472
- // UnknownKeys,
2473
- // Catchall,
2474
- // NewOutput,
2475
- // NewInput
2476
- // > {
2477
- // return new ZodObject({
2478
- // ...this._def,
2479
- // shape: () => ({
2480
- // ...this._def.shape(),
2481
- // ...augmentation,
2482
- // }),
2483
- // }) as any;
2484
- // }
2485
- /**
2486
- * @deprecated Use `.extend` instead
2487
- * */
2488
- this.augment = this.extend;
2489
- }
2384
+ _cached = null;
2490
2385
  _getCached() {
2491
2386
  if (this._cached !== null)
2492
2387
  return this._cached;
@@ -2597,11 +2492,10 @@ class ZodObject extends ZodType {
2597
2492
  ...(message !== undefined
2598
2493
  ? {
2599
2494
  errorMap: (issue, ctx) => {
2600
- var _a, _b, _c, _d;
2601
- const defaultError = (_c = (_b = (_a = this._def).errorMap) === null || _b === void 0 ? void 0 : _b.call(_a, issue, ctx).message) !== null && _c !== void 0 ? _c : ctx.defaultError;
2495
+ const defaultError = this._def.errorMap?.(issue, ctx).message ?? ctx.defaultError;
2602
2496
  if (issue.code === "unrecognized_keys")
2603
2497
  return {
2604
- message: (_d = errorUtil.errToObj(message).message) !== null && _d !== void 0 ? _d : defaultError,
2498
+ message: errorUtil.errToObj(message).message ?? defaultError,
2605
2499
  };
2606
2500
  return {
2607
2501
  message: defaultError,
@@ -2623,6 +2517,11 @@ class ZodObject extends ZodType {
2623
2517
  unknownKeys: "passthrough",
2624
2518
  });
2625
2519
  }
2520
+ /**
2521
+ * @deprecated In most cases, this is no longer needed - unknown properties are now silently stripped.
2522
+ * If you want to pass through unknown properties, use `.passthrough()` instead.
2523
+ */
2524
+ nonstrict = this.passthrough;
2626
2525
  // const AugmentFactory =
2627
2526
  // <Def extends ZodObjectDef>(def: Def) =>
2628
2527
  // <Augmentation extends ZodRawShape>(
@@ -2649,6 +2548,43 @@ class ZodObject extends ZodType {
2649
2548
  }),
2650
2549
  });
2651
2550
  }
2551
+ // extend<
2552
+ // Augmentation extends ZodRawShape,
2553
+ // NewOutput extends util.flatten<{
2554
+ // [k in keyof Augmentation | keyof Output]: k extends keyof Augmentation
2555
+ // ? Augmentation[k]["_output"]
2556
+ // : k extends keyof Output
2557
+ // ? Output[k]
2558
+ // : never;
2559
+ // }>,
2560
+ // NewInput extends util.flatten<{
2561
+ // [k in keyof Augmentation | keyof Input]: k extends keyof Augmentation
2562
+ // ? Augmentation[k]["_input"]
2563
+ // : k extends keyof Input
2564
+ // ? Input[k]
2565
+ // : never;
2566
+ // }>
2567
+ // >(
2568
+ // augmentation: Augmentation
2569
+ // ): ZodObject<
2570
+ // extendShape<T, Augmentation>,
2571
+ // UnknownKeys,
2572
+ // Catchall,
2573
+ // NewOutput,
2574
+ // NewInput
2575
+ // > {
2576
+ // return new ZodObject({
2577
+ // ...this._def,
2578
+ // shape: () => ({
2579
+ // ...this._def.shape(),
2580
+ // ...augmentation,
2581
+ // }),
2582
+ // }) as any;
2583
+ // }
2584
+ /**
2585
+ * @deprecated Use `.extend` instead
2586
+ * */
2587
+ augment = this.extend;
2652
2588
  /**
2653
2589
  * Prior to zod@1.0.12 there was a bug in the
2654
2590
  * inferred type of merged objects. Please
@@ -2800,34 +2736,34 @@ class ZodObject extends ZodType {
2800
2736
  keyof() {
2801
2737
  return createZodEnum(util.objectKeys(this.shape));
2802
2738
  }
2739
+ static create = (shape, params) => {
2740
+ return new ZodObject({
2741
+ shape: () => shape,
2742
+ unknownKeys: "strip",
2743
+ catchall: ZodNever.create(),
2744
+ typeName: ZodFirstPartyTypeKind.ZodObject,
2745
+ ...processCreateParams(params),
2746
+ });
2747
+ };
2748
+ static strictCreate = (shape, params) => {
2749
+ return new ZodObject({
2750
+ shape: () => shape,
2751
+ unknownKeys: "strict",
2752
+ catchall: ZodNever.create(),
2753
+ typeName: ZodFirstPartyTypeKind.ZodObject,
2754
+ ...processCreateParams(params),
2755
+ });
2756
+ };
2757
+ static lazycreate = (shape, params) => {
2758
+ return new ZodObject({
2759
+ shape,
2760
+ unknownKeys: "strip",
2761
+ catchall: ZodNever.create(),
2762
+ typeName: ZodFirstPartyTypeKind.ZodObject,
2763
+ ...processCreateParams(params),
2764
+ });
2765
+ };
2803
2766
  }
2804
- ZodObject.create = (shape, params) => {
2805
- return new ZodObject({
2806
- shape: () => shape,
2807
- unknownKeys: "strip",
2808
- catchall: ZodNever.create(),
2809
- typeName: ZodFirstPartyTypeKind.ZodObject,
2810
- ...processCreateParams(params),
2811
- });
2812
- };
2813
- ZodObject.strictCreate = (shape, params) => {
2814
- return new ZodObject({
2815
- shape: () => shape,
2816
- unknownKeys: "strict",
2817
- catchall: ZodNever.create(),
2818
- typeName: ZodFirstPartyTypeKind.ZodObject,
2819
- ...processCreateParams(params),
2820
- });
2821
- };
2822
- ZodObject.lazycreate = (shape, params) => {
2823
- return new ZodObject({
2824
- shape,
2825
- unknownKeys: "strip",
2826
- catchall: ZodNever.create(),
2827
- typeName: ZodFirstPartyTypeKind.ZodObject,
2828
- ...processCreateParams(params),
2829
- });
2830
- };
2831
2767
  class ZodUnion extends ZodType {
2832
2768
  _parse(input) {
2833
2769
  const { ctx } = this._processInputParams(input);
@@ -2916,14 +2852,14 @@ class ZodUnion extends ZodType {
2916
2852
  get options() {
2917
2853
  return this._def.options;
2918
2854
  }
2855
+ static create = (types, params) => {
2856
+ return new ZodUnion({
2857
+ options: types,
2858
+ typeName: ZodFirstPartyTypeKind.ZodUnion,
2859
+ ...processCreateParams(params),
2860
+ });
2861
+ };
2919
2862
  }
2920
- ZodUnion.create = (types, params) => {
2921
- return new ZodUnion({
2922
- options: types,
2923
- typeName: ZodFirstPartyTypeKind.ZodUnion,
2924
- ...processCreateParams(params),
2925
- });
2926
- };
2927
2863
  /////////////////////////////////////////////////////
2928
2864
  /////////////////////////////////////////////////////
2929
2865
  ////////// //////////
@@ -3146,15 +3082,15 @@ class ZodIntersection extends ZodType {
3146
3082
  }));
3147
3083
  }
3148
3084
  }
3085
+ static create = (left, right, params) => {
3086
+ return new ZodIntersection({
3087
+ left: left,
3088
+ right: right,
3089
+ typeName: ZodFirstPartyTypeKind.ZodIntersection,
3090
+ ...processCreateParams(params),
3091
+ });
3092
+ };
3149
3093
  }
3150
- ZodIntersection.create = (left, right, params) => {
3151
- return new ZodIntersection({
3152
- left: left,
3153
- right: right,
3154
- typeName: ZodFirstPartyTypeKind.ZodIntersection,
3155
- ...processCreateParams(params),
3156
- });
3157
- };
3158
3094
  class ZodTuple extends ZodType {
3159
3095
  _parse(input) {
3160
3096
  const { status, ctx } = this._processInputParams(input);
@@ -3213,18 +3149,18 @@ class ZodTuple extends ZodType {
3213
3149
  rest,
3214
3150
  });
3215
3151
  }
3152
+ static create = (schemas, params) => {
3153
+ if (!Array.isArray(schemas)) {
3154
+ throw new Error("You must pass an array of schemas to z.tuple([ ... ])");
3155
+ }
3156
+ return new ZodTuple({
3157
+ items: schemas,
3158
+ typeName: ZodFirstPartyTypeKind.ZodTuple,
3159
+ rest: null,
3160
+ ...processCreateParams(params),
3161
+ });
3162
+ };
3216
3163
  }
3217
- ZodTuple.create = (schemas, params) => {
3218
- if (!Array.isArray(schemas)) {
3219
- throw new Error("You must pass an array of schemas to z.tuple([ ... ])");
3220
- }
3221
- return new ZodTuple({
3222
- items: schemas,
3223
- typeName: ZodFirstPartyTypeKind.ZodTuple,
3224
- rest: null,
3225
- ...processCreateParams(params),
3226
- });
3227
- };
3228
3164
  class ZodRecord extends ZodType {
3229
3165
  get keySchema() {
3230
3166
  return this._def.keyType;
@@ -3337,15 +3273,15 @@ class ZodMap extends ZodType {
3337
3273
  return { status: status.value, value: finalMap };
3338
3274
  }
3339
3275
  }
3276
+ static create = (keyType, valueType, params) => {
3277
+ return new ZodMap({
3278
+ valueType,
3279
+ keyType,
3280
+ typeName: ZodFirstPartyTypeKind.ZodMap,
3281
+ ...processCreateParams(params),
3282
+ });
3283
+ };
3340
3284
  }
3341
- ZodMap.create = (keyType, valueType, params) => {
3342
- return new ZodMap({
3343
- valueType,
3344
- keyType,
3345
- typeName: ZodFirstPartyTypeKind.ZodMap,
3346
- ...processCreateParams(params),
3347
- });
3348
- };
3349
3285
  class ZodSet extends ZodType {
3350
3286
  _parse(input) {
3351
3287
  const { status, ctx } = this._processInputParams(input);
@@ -3422,21 +3358,17 @@ class ZodSet extends ZodType {
3422
3358
  nonempty(message) {
3423
3359
  return this.min(1, message);
3424
3360
  }
3361
+ static create = (valueType, params) => {
3362
+ return new ZodSet({
3363
+ valueType,
3364
+ minSize: null,
3365
+ maxSize: null,
3366
+ typeName: ZodFirstPartyTypeKind.ZodSet,
3367
+ ...processCreateParams(params),
3368
+ });
3369
+ };
3425
3370
  }
3426
- ZodSet.create = (valueType, params) => {
3427
- return new ZodSet({
3428
- valueType,
3429
- minSize: null,
3430
- maxSize: null,
3431
- typeName: ZodFirstPartyTypeKind.ZodSet,
3432
- ...processCreateParams(params),
3433
- });
3434
- };
3435
3371
  class ZodFunction extends ZodType {
3436
- constructor() {
3437
- super(...arguments);
3438
- this.validate = this.implement;
3439
- }
3440
3372
  _parse(input) {
3441
3373
  const { ctx } = this._processInputParams(input);
3442
3374
  if (ctx.parsedType !== ZodParsedType.function) {
@@ -3549,6 +3481,7 @@ class ZodFunction extends ZodType {
3549
3481
  const validatedFunc = this.parse(func);
3550
3482
  return validatedFunc;
3551
3483
  }
3484
+ validate = this.implement;
3552
3485
  static create(args, returns, params) {
3553
3486
  return new ZodFunction({
3554
3487
  args: (args
@@ -3569,14 +3502,14 @@ class ZodLazy extends ZodType {
3569
3502
  const lazySchema = this._def.getter();
3570
3503
  return lazySchema._parse({ data: ctx.data, path: ctx.path, parent: ctx });
3571
3504
  }
3505
+ static create = (getter, params) => {
3506
+ return new ZodLazy({
3507
+ getter: getter,
3508
+ typeName: ZodFirstPartyTypeKind.ZodLazy,
3509
+ ...processCreateParams(params),
3510
+ });
3511
+ };
3572
3512
  }
3573
- ZodLazy.create = (getter, params) => {
3574
- return new ZodLazy({
3575
- getter: getter,
3576
- typeName: ZodFirstPartyTypeKind.ZodLazy,
3577
- ...processCreateParams(params),
3578
- });
3579
- };
3580
3513
  class ZodLiteral extends ZodType {
3581
3514
  _parse(input) {
3582
3515
  if (input.data !== this._def.value) {
@@ -3593,14 +3526,14 @@ class ZodLiteral extends ZodType {
3593
3526
  get value() {
3594
3527
  return this._def.value;
3595
3528
  }
3529
+ static create = (value, params) => {
3530
+ return new ZodLiteral({
3531
+ value: value,
3532
+ typeName: ZodFirstPartyTypeKind.ZodLiteral,
3533
+ ...processCreateParams(params),
3534
+ });
3535
+ };
3596
3536
  }
3597
- ZodLiteral.create = (value, params) => {
3598
- return new ZodLiteral({
3599
- value: value,
3600
- typeName: ZodFirstPartyTypeKind.ZodLiteral,
3601
- ...processCreateParams(params),
3602
- });
3603
- };
3604
3537
  function createZodEnum(values, params) {
3605
3538
  return new ZodEnum({
3606
3539
  values,
@@ -3609,10 +3542,7 @@ function createZodEnum(values, params) {
3609
3542
  });
3610
3543
  }
3611
3544
  class ZodEnum extends ZodType {
3612
- constructor() {
3613
- super(...arguments);
3614
- _ZodEnum_cache.set(this, void 0);
3615
- }
3545
+ #cache;
3616
3546
  _parse(input) {
3617
3547
  if (typeof input.data !== "string") {
3618
3548
  const ctx = this._getOrReturnCtx(input);
@@ -3624,10 +3554,10 @@ class ZodEnum extends ZodType {
3624
3554
  });
3625
3555
  return INVALID;
3626
3556
  }
3627
- if (!__classPrivateFieldGet(this, _ZodEnum_cache, "f")) {
3628
- __classPrivateFieldSet(this, _ZodEnum_cache, new Set(this._def.values), "f");
3557
+ if (!this.#cache) {
3558
+ this.#cache = new Set(this._def.values);
3629
3559
  }
3630
- if (!__classPrivateFieldGet(this, _ZodEnum_cache, "f").has(input.data)) {
3560
+ if (!this.#cache.has(input.data)) {
3631
3561
  const ctx = this._getOrReturnCtx(input);
3632
3562
  const expectedValues = this._def.values;
3633
3563
  addIssueToContext(ctx, {
@@ -3675,14 +3605,10 @@ class ZodEnum extends ZodType {
3675
3605
  ...newDef,
3676
3606
  });
3677
3607
  }
3608
+ static create = createZodEnum;
3678
3609
  }
3679
- _ZodEnum_cache = new WeakMap();
3680
- ZodEnum.create = createZodEnum;
3681
3610
  class ZodNativeEnum extends ZodType {
3682
- constructor() {
3683
- super(...arguments);
3684
- _ZodNativeEnum_cache.set(this, void 0);
3685
- }
3611
+ #cache;
3686
3612
  _parse(input) {
3687
3613
  const nativeEnumValues = util.getValidEnumValues(this._def.values);
3688
3614
  const ctx = this._getOrReturnCtx(input);
@@ -3696,10 +3622,10 @@ class ZodNativeEnum extends ZodType {
3696
3622
  });
3697
3623
  return INVALID;
3698
3624
  }
3699
- if (!__classPrivateFieldGet(this, _ZodNativeEnum_cache, "f")) {
3700
- __classPrivateFieldSet(this, _ZodNativeEnum_cache, new Set(util.getValidEnumValues(this._def.values)), "f");
3625
+ if (!this.#cache) {
3626
+ this.#cache = new Set(util.getValidEnumValues(this._def.values));
3701
3627
  }
3702
- if (!__classPrivateFieldGet(this, _ZodNativeEnum_cache, "f").has(input.data)) {
3628
+ if (!this.#cache.has(input.data)) {
3703
3629
  const expectedValues = util.objectValues(nativeEnumValues);
3704
3630
  addIssueToContext(ctx, {
3705
3631
  received: ctx.data,
@@ -3713,15 +3639,14 @@ class ZodNativeEnum extends ZodType {
3713
3639
  get enum() {
3714
3640
  return this._def.values;
3715
3641
  }
3642
+ static create = (values, params) => {
3643
+ return new ZodNativeEnum({
3644
+ values: values,
3645
+ typeName: ZodFirstPartyTypeKind.ZodNativeEnum,
3646
+ ...processCreateParams(params),
3647
+ });
3648
+ };
3716
3649
  }
3717
- _ZodNativeEnum_cache = new WeakMap();
3718
- ZodNativeEnum.create = (values, params) => {
3719
- return new ZodNativeEnum({
3720
- values: values,
3721
- typeName: ZodFirstPartyTypeKind.ZodNativeEnum,
3722
- ...processCreateParams(params),
3723
- });
3724
- };
3725
3650
  class ZodPromise extends ZodType {
3726
3651
  unwrap() {
3727
3652
  return this._def.type;
@@ -3747,14 +3672,14 @@ class ZodPromise extends ZodType {
3747
3672
  });
3748
3673
  }));
3749
3674
  }
3675
+ static create = (schema, params) => {
3676
+ return new ZodPromise({
3677
+ type: schema,
3678
+ typeName: ZodFirstPartyTypeKind.ZodPromise,
3679
+ ...processCreateParams(params),
3680
+ });
3681
+ };
3750
3682
  }
3751
- ZodPromise.create = (schema, params) => {
3752
- return new ZodPromise({
3753
- type: schema,
3754
- typeName: ZodFirstPartyTypeKind.ZodPromise,
3755
- ...processCreateParams(params),
3756
- });
3757
- };
3758
3683
  class ZodEffects extends ZodType {
3759
3684
  innerType() {
3760
3685
  return this._def.schema;
@@ -3885,23 +3810,23 @@ class ZodEffects extends ZodType {
3885
3810
  }
3886
3811
  util.assertNever(effect);
3887
3812
  }
3813
+ static create = (schema, effect, params) => {
3814
+ return new ZodEffects({
3815
+ schema,
3816
+ typeName: ZodFirstPartyTypeKind.ZodEffects,
3817
+ effect,
3818
+ ...processCreateParams(params),
3819
+ });
3820
+ };
3821
+ static createWithPreprocess = (preprocess, schema, params) => {
3822
+ return new ZodEffects({
3823
+ schema,
3824
+ effect: { type: "preprocess", transform: preprocess },
3825
+ typeName: ZodFirstPartyTypeKind.ZodEffects,
3826
+ ...processCreateParams(params),
3827
+ });
3828
+ };
3888
3829
  }
3889
- ZodEffects.create = (schema, effect, params) => {
3890
- return new ZodEffects({
3891
- schema,
3892
- typeName: ZodFirstPartyTypeKind.ZodEffects,
3893
- effect,
3894
- ...processCreateParams(params),
3895
- });
3896
- };
3897
- ZodEffects.createWithPreprocess = (preprocess, schema, params) => {
3898
- return new ZodEffects({
3899
- schema,
3900
- effect: { type: "preprocess", transform: preprocess },
3901
- typeName: ZodFirstPartyTypeKind.ZodEffects,
3902
- ...processCreateParams(params),
3903
- });
3904
- };
3905
3830
  class ZodOptional extends ZodType {
3906
3831
  _parse(input) {
3907
3832
  const parsedType = this._getType(input);
@@ -3913,14 +3838,14 @@ class ZodOptional extends ZodType {
3913
3838
  unwrap() {
3914
3839
  return this._def.innerType;
3915
3840
  }
3841
+ static create = (type, params) => {
3842
+ return new ZodOptional({
3843
+ innerType: type,
3844
+ typeName: ZodFirstPartyTypeKind.ZodOptional,
3845
+ ...processCreateParams(params),
3846
+ });
3847
+ };
3916
3848
  }
3917
- ZodOptional.create = (type, params) => {
3918
- return new ZodOptional({
3919
- innerType: type,
3920
- typeName: ZodFirstPartyTypeKind.ZodOptional,
3921
- ...processCreateParams(params),
3922
- });
3923
- };
3924
3849
  class ZodNullable extends ZodType {
3925
3850
  _parse(input) {
3926
3851
  const parsedType = this._getType(input);
@@ -3932,14 +3857,14 @@ class ZodNullable extends ZodType {
3932
3857
  unwrap() {
3933
3858
  return this._def.innerType;
3934
3859
  }
3860
+ static create = (type, params) => {
3861
+ return new ZodNullable({
3862
+ innerType: type,
3863
+ typeName: ZodFirstPartyTypeKind.ZodNullable,
3864
+ ...processCreateParams(params),
3865
+ });
3866
+ };
3935
3867
  }
3936
- ZodNullable.create = (type, params) => {
3937
- return new ZodNullable({
3938
- innerType: type,
3939
- typeName: ZodFirstPartyTypeKind.ZodNullable,
3940
- ...processCreateParams(params),
3941
- });
3942
- };
3943
3868
  class ZodDefault extends ZodType {
3944
3869
  _parse(input) {
3945
3870
  const { ctx } = this._processInputParams(input);
@@ -3956,17 +3881,17 @@ class ZodDefault extends ZodType {
3956
3881
  removeDefault() {
3957
3882
  return this._def.innerType;
3958
3883
  }
3884
+ static create = (type, params) => {
3885
+ return new ZodDefault({
3886
+ innerType: type,
3887
+ typeName: ZodFirstPartyTypeKind.ZodDefault,
3888
+ defaultValue: typeof params.default === "function"
3889
+ ? params.default
3890
+ : () => params.default,
3891
+ ...processCreateParams(params),
3892
+ });
3893
+ };
3959
3894
  }
3960
- ZodDefault.create = (type, params) => {
3961
- return new ZodDefault({
3962
- innerType: type,
3963
- typeName: ZodFirstPartyTypeKind.ZodDefault,
3964
- defaultValue: typeof params.default === "function"
3965
- ? params.default
3966
- : () => params.default,
3967
- ...processCreateParams(params),
3968
- });
3969
- };
3970
3895
  class ZodCatch extends ZodType {
3971
3896
  _parse(input) {
3972
3897
  const { ctx } = this._processInputParams(input);
@@ -4017,15 +3942,15 @@ class ZodCatch extends ZodType {
4017
3942
  removeCatch() {
4018
3943
  return this._def.innerType;
4019
3944
  }
3945
+ static create = (type, params) => {
3946
+ return new ZodCatch({
3947
+ innerType: type,
3948
+ typeName: ZodFirstPartyTypeKind.ZodCatch,
3949
+ catchValue: typeof params.catch === "function" ? params.catch : () => params.catch,
3950
+ ...processCreateParams(params),
3951
+ });
3952
+ };
4020
3953
  }
4021
- ZodCatch.create = (type, params) => {
4022
- return new ZodCatch({
4023
- innerType: type,
4024
- typeName: ZodFirstPartyTypeKind.ZodCatch,
4025
- catchValue: typeof params.catch === "function" ? params.catch : () => params.catch,
4026
- ...processCreateParams(params),
4027
- });
4028
- };
4029
3954
  class ZodNaN extends ZodType {
4030
3955
  _parse(input) {
4031
3956
  const parsedType = this._getType(input);
@@ -4040,13 +3965,13 @@ class ZodNaN extends ZodType {
4040
3965
  }
4041
3966
  return { status: "valid", value: input.data };
4042
3967
  }
3968
+ static create = (params) => {
3969
+ return new ZodNaN({
3970
+ typeName: ZodFirstPartyTypeKind.ZodNaN,
3971
+ ...processCreateParams(params),
3972
+ });
3973
+ };
4043
3974
  }
4044
- ZodNaN.create = (params) => {
4045
- return new ZodNaN({
4046
- typeName: ZodFirstPartyTypeKind.ZodNaN,
4047
- ...processCreateParams(params),
4048
- });
4049
- };
4050
3975
  const BRAND = Symbol("zod_brand");
4051
3976
  class ZodBranded extends ZodType {
4052
3977
  _parse(input) {
@@ -4133,17 +4058,17 @@ class ZodReadonly extends ZodType {
4133
4058
  ? result.then((data) => freeze(data))
4134
4059
  : freeze(result);
4135
4060
  }
4061
+ static create = (type, params) => {
4062
+ return new ZodReadonly({
4063
+ innerType: type,
4064
+ typeName: ZodFirstPartyTypeKind.ZodReadonly,
4065
+ ...processCreateParams(params),
4066
+ });
4067
+ };
4136
4068
  unwrap() {
4137
4069
  return this._def.innerType;
4138
4070
  }
4139
4071
  }
4140
- ZodReadonly.create = (type, params) => {
4141
- return new ZodReadonly({
4142
- innerType: type,
4143
- typeName: ZodFirstPartyTypeKind.ZodReadonly,
4144
- ...processCreateParams(params),
4145
- });
4146
- };
4147
4072
  function custom(check, params = {},
4148
4073
  /**
4149
4074
  * @deprecated
@@ -4158,14 +4083,13 @@ function custom(check, params = {},
4158
4083
  fatal) {
4159
4084
  if (check)
4160
4085
  return ZodAny.create().superRefine((data, ctx) => {
4161
- var _a, _b;
4162
4086
  if (!check(data)) {
4163
4087
  const p = typeof params === "function"
4164
4088
  ? params(data)
4165
4089
  : typeof params === "string"
4166
4090
  ? { message: params }
4167
4091
  : params;
4168
- const _fatal = (_b = (_a = p.fatal) !== null && _a !== void 0 ? _a : fatal) !== null && _b !== void 0 ? _b : true;
4092
+ const _fatal = p.fatal ?? fatal ?? true;
4169
4093
  const p2 = typeof p === "string" ? { message: p } : p;
4170
4094
  ctx.addIssue({ code: "custom", ...p2, fatal: _fatal });
4171
4095
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exodus/zod",
3
- "version": "3.24.1-rc.2",
3
+ "version": "3.24.1-rc.3",
4
4
  "author": "Colin McDonnell <colin@colinhacks.com>",
5
5
  "repository": {
6
6
  "type": "git",