zod 3.17.0 → 3.17.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -22,7 +22,7 @@
22
22
  <span>&nbsp;&nbsp;•&nbsp;&nbsp;</span>
23
23
  <a href="https://discord.gg/RcG33DQJdf">Discord</a>
24
24
  <span>&nbsp;&nbsp;•&nbsp;&nbsp;</span>
25
- <a href="https://www.npmjs.com/package/zod">NPM</a>
25
+ <a href="https://www.npmjs.com/package/zod">npm</a>
26
26
  <span>&nbsp;&nbsp;•&nbsp;&nbsp;</span>
27
27
  <a href="https://github.com/colinhacks/zod/issues/new">Issues</a>
28
28
  <span>&nbsp;&nbsp;•&nbsp;&nbsp;</span>
@@ -47,7 +47,7 @@
47
47
  - [Sponsors](#sponsors)
48
48
  - [Ecosystem](#ecosystem)
49
49
  - [Installation](#installation)
50
- - [Node](#node)
50
+ - [Node/npm](#Node/npm)
51
51
  - [Deno](#deno)
52
52
  - [Basic usage](#basic-usage)
53
53
  - [Primitives](#primitives)
@@ -215,6 +215,26 @@ Sponsorship at any level is appreciated and encouraged. For individual developer
215
215
  <b>Trip</b>
216
216
  </td>
217
217
  </tr>
218
+ <tr>
219
+ <td align="center">
220
+ <a href="https://seasoned.cc">
221
+ <img src="https://avatars.githubusercontent.com/u/33913103?s=200&v=4" width="150px;" alt="" />
222
+ </a>
223
+ <br />
224
+ <b>Seasoned Software</b>
225
+ <br />
226
+ <a href="https://seasoned.cc">seasoned.cc</a>
227
+ </td>
228
+ <td align="center">
229
+ <a href="https://seasoned.cc">
230
+ <img src="https://avatars.githubusercontent.com/u/67802063?s=200&v=4" width="150px;" alt="" />
231
+ </a>
232
+ <br />
233
+ <b>Interval</b>
234
+ <br />
235
+ <a href="https://interval.com">interval.com</a>
236
+ </td>
237
+ </tr>
218
238
  </table>
219
239
 
220
240
  #### Bronze
@@ -252,6 +272,18 @@ Sponsorship at any level is appreciated and encouraged. For individual developer
252
272
  <a href="https://twitter.com/alexdotjs">@alexdotjs</a>
253
273
  </td>
254
274
  </tr>
275
+ <tr>
276
+ <td align="center">
277
+ <a href="https://adaptable.io/">
278
+ <img src="https://avatars.githubusercontent.com/u/60378268?s=200&v=4" width="100px;" alt=""/>
279
+ </a>
280
+ <br />
281
+ <b>Adaptable</b>
282
+ <br/>
283
+ <a href="https://adaptable.io/">adaptable.io</a>
284
+ <br />
285
+ </td>
286
+ </tr>
255
287
  </table>
256
288
 
257
289
  ### Ecosystem
@@ -281,6 +313,7 @@ There are a growing number of tools that are built atop or support Zod natively!
281
313
  - [`prisma-zod-generator`](https://github.com/omar-dulaimi/prisma-zod-generator): Emit Zod schemas from your Prisma schema.
282
314
  - [`prisma-trpc-generator`](https://github.com/omar-dulaimi/prisma-trpc-generator): Emit fully implemented tRPC routers and their validation schemas using Zod.
283
315
  - [`nestjs-graphql-zod`](https://github.com/incetarik/nestjs-graphql-zod): Generates NestJS GraphQL model classes from Zod schemas dynamically and provides GraphQL method decorators working with Zod schemas.
316
+ - [`remix-domains`](https://github.com/SeasonedSoftware/remix-domains/): Improves end-to-end type safety in [Remix](https://remix.run/) by leveraging Zod to parse the framework's inputs such as FormData, URLSearchParams, etc.
284
317
 
285
318
  #### Form integrations
286
319
 
@@ -306,7 +339,7 @@ There are a growing number of tools that are built atop or support Zod natively!
306
339
  }
307
340
  ```
308
341
 
309
- ### Node/NPM
342
+ ### Node/npm
310
343
 
311
344
  To install Zod v3:
312
345
 
@@ -318,7 +351,7 @@ pnpm add zod # pnpm
318
351
 
319
352
  ### Deno
320
353
 
321
- Unlike Node, Deno relies on direct URL imports instead of a package manager like NPM. Zod is available on [deno.land/x](deno.land/x). The latest version can be imported like so:
354
+ Unlike Node, Deno relies on direct URL imports instead of a package manager like npm. Zod is available on [deno.land/x](deno.land/x). The latest version can be imported like so:
322
355
 
323
356
  ```ts
324
357
  import { z } from "https://deno.land/x/zod/mod.ts";
@@ -330,7 +363,7 @@ You can also specify a particular version:
330
363
  import { z } from from "https://deno.land/x/zod@v3.16.1/mod.ts"
331
364
  ```
332
365
 
333
- > The rest of this README assumes you are using NPM and importing directly from the `"zod"` package.
366
+ > The rest of this README assumes you are using npm and importing directly from the `"zod"` package.
334
367
 
335
368
  ## Basic usage
336
369
 
@@ -433,7 +466,7 @@ z.string().nonempty({ message: "Can't be empty" });
433
466
 
434
467
  > Check out [validator.js](https://github.com/validatorjs/validator.js) for a bunch of other useful string validation functions.
435
468
 
436
- You can customize some common errors messages when creating a string schema.
469
+ You can customize some common error messages when creating a string schema.
437
470
 
438
471
  ```ts
439
472
  const name = z.string({
@@ -547,7 +580,7 @@ const VALUES = ["Salmon", "Tuna", "Trout"] as const;
547
580
  const FishEnum = z.enum(VALUES);
548
581
  ```
549
582
 
550
- This is not allowed, since Zod isn't able to infer the exact values of each elements.
583
+ This is not allowed, since Zod isn't able to infer the exact values of each element.
551
584
 
552
585
  ```ts
553
586
  const fish = ["Salmon", "Tuna", "Trout"];
@@ -728,7 +761,7 @@ Dog.shape.age; // => number schema
728
761
 
729
762
  ### `.extend`
730
763
 
731
- You can add additional fields an object schema with the `.extend` method.
764
+ You can add additional fields to an object schema with the `.extend` method.
732
765
 
733
766
  ```ts
734
767
  const DogWithBreed = Dog.extend({
@@ -848,7 +881,7 @@ const deepPartialUser = user.deepPartial();
848
881
 
849
882
  ### `.passthrough`
850
883
 
851
- By default Zod objects schemas strip out unrecognized keys during parsing.
884
+ By default Zod object schemas strip out unrecognized keys during parsing.
852
885
 
853
886
  ```ts
854
887
  const person = z.object({
@@ -875,7 +908,7 @@ person.passthrough().parse({
875
908
 
876
909
  ### `.strict`
877
910
 
878
- By default Zod objects schemas strip out unrecognized keys during parsing. You can _disallow_ unknown keys with `.strict()` . If there are any unknown keys in the input, Zod will throw an error.
911
+ By default Zod object schemas strip out unrecognized keys during parsing. You can _disallow_ unknown keys with `.strict()` . If there are any unknown keys in the input, Zod will throw an error.
879
912
 
880
913
  ```ts
881
914
  const person = z
@@ -1035,7 +1068,7 @@ const item = z
1035
1068
 
1036
1069
  Record schemas are used to validate types such as `{ [k: string]: number }`.
1037
1070
 
1038
- If you want to validate the _values_ of an object against some schema but don't care about the keys, use `Record`.
1071
+ If you want to validate the _values_ of an object against some schema but don't care about the keys, use `z.record(valueType)`:
1039
1072
 
1040
1073
  ```ts
1041
1074
  const NumberCache = z.record(z.number());
@@ -1058,9 +1091,22 @@ userStore["77d2586b-9e8e-4ecf-8b21-ea7e0530eadd"] = {
1058
1091
  }; // TypeError
1059
1092
  ```
1060
1093
 
1094
+ ### Record key type
1095
+
1096
+ If you want to validate both the keys and the values, use
1097
+ `z.record(keyType, valueType)`:
1098
+
1099
+ ```ts
1100
+ const NoEmptyKeysSchema = z.record(z.string().min(1), z.number());
1101
+ NoEmptyKeysSchema.parse({ count: 1 }); // => { 'count': 1 }
1102
+ NoEmptyKeysSchema.parse({ "": 1 }); // fails
1103
+ ```
1104
+
1105
+ _(Notice how when passing two arguments, `valueType` is the second argument)_
1106
+
1061
1107
  **A note on numerical keys**
1062
1108
 
1063
- You may have expected `z.record()` to accept two arguments, one for the keys and one for the values. After all, TypeScript's built-in Record type does: `Record<KeyType, ValueType>` . Otherwise, how do you represent the TypeScript type `Record<number, any>` in Zod?
1109
+ While `z.record(keyType, valueType)` is able to accept numerical key types and TypeScript's built-in Record type is `Record<KeyType, ValueType>`, it's hard to represent the TypeScript type `Record<number, any>` in Zod.
1064
1110
 
1065
1111
  As it turns out, TypeScript's behavior surrounding `[k: number]` is a little unintuitive:
1066
1112
 
@@ -1310,7 +1356,7 @@ type myFunction = z.infer<typeof myFunction>;
1310
1356
  // => (arg0: string)=>number
1311
1357
  ``` -->
1312
1358
 
1313
- Function schemas have an `.implement()` method which accepts a function and returns a new function that automatically validates it's inputs and outputs.
1359
+ Function schemas have an `.implement()` method which accepts a function and returns a new function that automatically validates its inputs and outputs.
1314
1360
 
1315
1361
  ```ts
1316
1362
  const trimmedLength = z
@@ -1528,7 +1574,7 @@ const userId = z.string().refine(async (id) => {
1528
1574
  });
1529
1575
  ```
1530
1576
 
1531
- > ⚠️If you use async refinements, you must use the `.parseAsync` method to parse data! Otherwise Zod will throw an error.
1577
+ > ⚠️ If you use async refinements, you must use the `.parseAsync` method to parse data! Otherwise Zod will throw an error.
1532
1578
 
1533
1579
  #### Relationship to transforms
1534
1580
 
@@ -1584,7 +1630,7 @@ const Strings = z.array(z.string()).superRefine((val, ctx) => {
1584
1630
  if (val.length !== new Set(val).size) {
1585
1631
  ctx.addIssue({
1586
1632
  code: z.ZodIssueCode.custom,
1587
- message: `No duplicated allowed.`,
1633
+ message: `No duplicates allowed.`,
1588
1634
  });
1589
1635
  }
1590
1636
  });
@@ -1977,13 +2023,13 @@ Branded -->
1977
2023
  * Missing support for parsing cyclical data (maybe)
1978
2024
  * Missing error customization -->
1979
2025
 
1980
- **Joi**
2026
+ ### Joi
1981
2027
 
1982
2028
  [https://github.com/hapijs/joi](https://github.com/hapijs/joi)
1983
2029
 
1984
2030
  Doesn't support static type inference 😕
1985
2031
 
1986
- **Yup**
2032
+ ### Yup
1987
2033
 
1988
2034
  [https://github.com/jquense/yup](https://github.com/jquense/yup)
1989
2035
 
@@ -1999,7 +2045,7 @@ Yup is a full-featured library that was implemented first in vanilla JS, and lat
1999
2045
 
2000
2046
  <!-- ¹Yup has a strange interpretation of the word `required`. Instead of meaning "not undefined", Yup uses it to mean "not empty". So `yup.string().required()` will not accept an empty string, and `yup.array(yup.string()).required()` will not accept an empty array. Instead, Yup us Zod arrays there is a dedicated `.nonempty()` method to indicate this, or you can implement it with a custom refinement. -->
2001
2047
 
2002
- **io-ts**
2048
+ ### io-ts
2003
2049
 
2004
2050
  [https://github.com/gcanti/io-ts](https://github.com/gcanti/io-ts)
2005
2051
 
@@ -2050,7 +2096,7 @@ This more declarative API makes schema definitions vastly more concise.
2050
2096
  - Missing promise schemas
2051
2097
  - Missing function schemas
2052
2098
 
2053
- **Runtypes**
2099
+ ### Runtypes
2054
2100
 
2055
2101
  [https://github.com/pelotom/runtypes](https://github.com/pelotom/runtypes)
2056
2102
 
@@ -2063,7 +2109,7 @@ Good type inference support, but limited options for object type masking (no `.p
2063
2109
  - Missing promise schemas
2064
2110
  - Missing error customization
2065
2111
 
2066
- **Ow**
2112
+ ### Ow
2067
2113
 
2068
2114
  [https://github.com/sindresorhus/ow](https://github.com/sindresorhus/ow)
2069
2115
 
package/lib/ZodError.d.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  import type { TypeOf, ZodType } from ".";
2
- import { ZodParsedType } from "./helpers/parseUtil";
3
2
  import { Primitive } from "./helpers/typeAliases";
4
- import { util } from "./helpers/util";
3
+ import { util, ZodParsedType } from "./helpers/util";
5
4
  declare type allKeys<T> = T extends any ? keyof T : never;
6
5
  export declare type inferFlattenedErrors<T extends ZodType<any, any, any>, U = string> = typeToFlattenedError<TypeOf<T>, U>;
7
6
  export declare type typeToFlattenedError<T, U = string> = {
package/lib/ZodError.js CHANGED
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.setErrorMap = exports.overrideErrorMap = exports.defaultErrorMap = exports.ZodError = exports.quotelessJson = exports.ZodIssueCode = void 0;
4
- const parseUtil_1 = require("./helpers/parseUtil");
5
4
  const util_1 = require("./helpers/util");
6
5
  exports.ZodIssueCode = util_1.util.arrayToEnum([
7
6
  "invalid_type",
@@ -134,7 +133,7 @@ const defaultErrorMap = (issue, _ctx) => {
134
133
  let message;
135
134
  switch (issue.code) {
136
135
  case exports.ZodIssueCode.invalid_type:
137
- if (issue.received === parseUtil_1.ZodParsedType.undefined) {
136
+ if (issue.received === util_1.ZodParsedType.undefined) {
138
137
  message = "Required";
139
138
  }
140
139
  else {
package/lib/external.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from "./helpers/parseUtil";
2
2
  export * from "./helpers/typeAliases";
3
+ export { getParsedType, ZodParsedType } from "./helpers/util";
3
4
  export * from "./types";
4
5
  export * from "./ZodError";
package/lib/external.js CHANGED
@@ -1,11 +1,7 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
9
5
  }) : (function(o, m, k, k2) {
10
6
  if (k2 === undefined) k2 = k;
11
7
  o[k2] = m[k];
@@ -14,7 +10,11 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
10
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
11
  };
16
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.ZodParsedType = exports.getParsedType = void 0;
17
14
  __exportStar(require("./helpers/parseUtil"), exports);
18
15
  __exportStar(require("./helpers/typeAliases"), exports);
16
+ var util_1 = require("./helpers/util");
17
+ Object.defineProperty(exports, "getParsedType", { enumerable: true, get: function () { return util_1.getParsedType; } });
18
+ Object.defineProperty(exports, "ZodParsedType", { enumerable: true, get: function () { return util_1.ZodParsedType; } });
19
19
  __exportStar(require("./types"), exports);
20
20
  __exportStar(require("./ZodError"), exports);
@@ -2,8 +2,12 @@ export declare namespace errorUtil {
2
2
  type ErrMessage = string | {
3
3
  message?: string;
4
4
  };
5
- const errToObj: (message?: ErrMessage | undefined) => {
5
+ const errToObj: (message?: string | {
6
+ message?: string | undefined;
7
+ } | undefined) => {
6
8
  message?: string | undefined;
7
9
  };
8
- const toString: (message?: ErrMessage | undefined) => string | undefined;
10
+ const toString: (message?: string | {
11
+ message?: string | undefined;
12
+ } | undefined) => string | undefined;
9
13
  }
@@ -1,28 +1,5 @@
1
- import { IssueData, ZodErrorMap, ZodIssue } from "../ZodError";
2
- export declare const ZodParsedType: {
3
- function: "function";
4
- number: "number";
5
- string: "string";
6
- nan: "nan";
7
- integer: "integer";
8
- float: "float";
9
- boolean: "boolean";
10
- date: "date";
11
- bigint: "bigint";
12
- symbol: "symbol";
13
- undefined: "undefined";
14
- null: "null";
15
- array: "array";
16
- object: "object";
17
- unknown: "unknown";
18
- promise: "promise";
19
- void: "void";
20
- never: "never";
21
- map: "map";
22
- set: "set";
23
- };
24
- export declare type ZodParsedType = keyof typeof ZodParsedType;
25
- export declare const getParsedType: (data: any) => ZodParsedType;
1
+ import type { IssueData, ZodErrorMap, ZodIssue } from "../ZodError";
2
+ import type { ZodParsedType } from "./util";
26
3
  export declare const makeIssue: (params: {
27
4
  data: any;
28
5
  path: (string | number)[];
@@ -1,73 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isAsync = exports.isValid = exports.isDirty = exports.isAborted = exports.OK = exports.DIRTY = exports.INVALID = exports.ParseStatus = exports.addIssueToContext = exports.EMPTY_PATH = exports.makeIssue = exports.getParsedType = exports.ZodParsedType = void 0;
3
+ exports.isAsync = exports.isValid = exports.isDirty = exports.isAborted = exports.OK = exports.DIRTY = exports.INVALID = exports.ParseStatus = exports.addIssueToContext = exports.EMPTY_PATH = exports.makeIssue = void 0;
4
4
  const ZodError_1 = require("../ZodError");
5
- const util_1 = require("./util");
6
- exports.ZodParsedType = util_1.util.arrayToEnum([
7
- "string",
8
- "nan",
9
- "number",
10
- "integer",
11
- "float",
12
- "boolean",
13
- "date",
14
- "bigint",
15
- "symbol",
16
- "function",
17
- "undefined",
18
- "null",
19
- "array",
20
- "object",
21
- "unknown",
22
- "promise",
23
- "void",
24
- "never",
25
- "map",
26
- "set",
27
- ]);
28
- const getParsedType = (data) => {
29
- const t = typeof data;
30
- switch (t) {
31
- case "undefined":
32
- return exports.ZodParsedType.undefined;
33
- case "string":
34
- return exports.ZodParsedType.string;
35
- case "number":
36
- return isNaN(data) ? exports.ZodParsedType.nan : exports.ZodParsedType.number;
37
- case "boolean":
38
- return exports.ZodParsedType.boolean;
39
- case "function":
40
- return exports.ZodParsedType.function;
41
- case "bigint":
42
- return exports.ZodParsedType.bigint;
43
- case "object":
44
- if (Array.isArray(data)) {
45
- return exports.ZodParsedType.array;
46
- }
47
- if (data === null) {
48
- return exports.ZodParsedType.null;
49
- }
50
- if (data.then &&
51
- typeof data.then === "function" &&
52
- data.catch &&
53
- typeof data.catch === "function") {
54
- return exports.ZodParsedType.promise;
55
- }
56
- if (typeof Map !== "undefined" && data instanceof Map) {
57
- return exports.ZodParsedType.map;
58
- }
59
- if (typeof Set !== "undefined" && data instanceof Set) {
60
- return exports.ZodParsedType.set;
61
- }
62
- if (typeof Date !== "undefined" && data instanceof Date) {
63
- return exports.ZodParsedType.date;
64
- }
65
- return exports.ZodParsedType.object;
66
- default:
67
- return exports.ZodParsedType.unknown;
68
- }
69
- };
70
- exports.getParsedType = getParsedType;
71
5
  const makeIssue = (params) => {
72
6
  const { data, path, errorMaps, issueData } = params;
73
7
  const fullPath = [...path, ...(issueData.path || [])];
@@ -92,7 +26,7 @@ const makeIssue = (params) => {
92
26
  exports.makeIssue = makeIssue;
93
27
  exports.EMPTY_PATH = [];
94
28
  function addIssueToContext(ctx, issueData) {
95
- const issue = (0, exports.makeIssue)({
29
+ const issue = exports.makeIssue({
96
30
  issueData: issueData,
97
31
  data: ctx.data,
98
32
  path: ctx.path,
@@ -100,7 +34,7 @@ function addIssueToContext(ctx, issueData) {
100
34
  ctx.common.contextualErrorMap,
101
35
  ctx.schemaErrorMap,
102
36
  ZodError_1.overrideErrorMap,
103
- ZodError_1.defaultErrorMap, // then global default map
37
+ ZodError_1.defaultErrorMap,
104
38
  ].filter((x) => !!x),
105
39
  });
106
40
  ctx.common.issues.push(issue);
@@ -17,3 +17,27 @@ export declare namespace util {
17
17
  const isInteger: NumberConstructor["isInteger"];
18
18
  function joinValues<T extends any[]>(array: T, separator?: string): string;
19
19
  }
20
+ export declare const ZodParsedType: {
21
+ function: "function";
22
+ number: "number";
23
+ string: "string";
24
+ nan: "nan";
25
+ integer: "integer";
26
+ float: "float";
27
+ boolean: "boolean";
28
+ date: "date";
29
+ bigint: "bigint";
30
+ symbol: "symbol";
31
+ undefined: "undefined";
32
+ null: "null";
33
+ array: "array";
34
+ object: "object";
35
+ unknown: "unknown";
36
+ promise: "promise";
37
+ void: "void";
38
+ never: "never";
39
+ map: "map";
40
+ set: "set";
41
+ };
42
+ export declare type ZodParsedType = keyof typeof ZodParsedType;
43
+ export declare const getParsedType: (data: any) => ZodParsedType;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.util = void 0;
3
+ exports.getParsedType = exports.ZodParsedType = exports.util = void 0;
4
4
  var util;
5
5
  (function (util) {
6
6
  function assertNever(_x) {
@@ -55,3 +55,68 @@ var util;
55
55
  }
56
56
  util.joinValues = joinValues;
57
57
  })(util = exports.util || (exports.util = {}));
58
+ exports.ZodParsedType = util.arrayToEnum([
59
+ "string",
60
+ "nan",
61
+ "number",
62
+ "integer",
63
+ "float",
64
+ "boolean",
65
+ "date",
66
+ "bigint",
67
+ "symbol",
68
+ "function",
69
+ "undefined",
70
+ "null",
71
+ "array",
72
+ "object",
73
+ "unknown",
74
+ "promise",
75
+ "void",
76
+ "never",
77
+ "map",
78
+ "set",
79
+ ]);
80
+ const getParsedType = (data) => {
81
+ const t = typeof data;
82
+ switch (t) {
83
+ case "undefined":
84
+ return exports.ZodParsedType.undefined;
85
+ case "string":
86
+ return exports.ZodParsedType.string;
87
+ case "number":
88
+ return isNaN(data) ? exports.ZodParsedType.nan : exports.ZodParsedType.number;
89
+ case "boolean":
90
+ return exports.ZodParsedType.boolean;
91
+ case "function":
92
+ return exports.ZodParsedType.function;
93
+ case "bigint":
94
+ return exports.ZodParsedType.bigint;
95
+ case "object":
96
+ if (Array.isArray(data)) {
97
+ return exports.ZodParsedType.array;
98
+ }
99
+ if (data === null) {
100
+ return exports.ZodParsedType.null;
101
+ }
102
+ if (data.then &&
103
+ typeof data.then === "function" &&
104
+ data.catch &&
105
+ typeof data.catch === "function") {
106
+ return exports.ZodParsedType.promise;
107
+ }
108
+ if (typeof Map !== "undefined" && data instanceof Map) {
109
+ return exports.ZodParsedType.map;
110
+ }
111
+ if (typeof Set !== "undefined" && data instanceof Set) {
112
+ return exports.ZodParsedType.set;
113
+ }
114
+ if (typeof Date !== "undefined" && data instanceof Date) {
115
+ return exports.ZodParsedType.date;
116
+ }
117
+ return exports.ZodParsedType.object;
118
+ default:
119
+ return exports.ZodParsedType.unknown;
120
+ }
121
+ };
122
+ exports.getParsedType = getParsedType;
package/lib/index.js CHANGED
@@ -1,11 +1,7 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
9
5
  }) : (function(o, m, k, k2) {
10
6
  if (k2 === undefined) k2 = k;
11
7
  o[k2] = m[k];