zod 3.25.0-canary.20250211T214501 → 4.0.0-beta.0

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.
Files changed (97) hide show
  1. package/dist/commonjs/checks.d.ts +1 -0
  2. package/dist/commonjs/checks.js +32 -0
  3. package/dist/commonjs/coerce.d.ts +17 -0
  4. package/dist/commonjs/coerce.js +57 -0
  5. package/dist/commonjs/compat.d.ts +47 -0
  6. package/dist/commonjs/compat.js +73 -0
  7. package/dist/commonjs/errors.d.ts +23 -0
  8. package/dist/commonjs/errors.js +57 -0
  9. package/dist/commonjs/external.d.ts +8 -0
  10. package/dist/commonjs/external.js +67 -0
  11. package/dist/commonjs/index.d.ts +4 -0
  12. package/{lib → dist/commonjs}/index.js +19 -9
  13. package/dist/commonjs/iso.d.ts +22 -0
  14. package/dist/commonjs/iso.js +70 -0
  15. package/dist/commonjs/package.json +3 -0
  16. package/dist/commonjs/parse.d.ts +17 -0
  17. package/dist/commonjs/parse.js +44 -0
  18. package/dist/commonjs/schemas.d.ts +738 -0
  19. package/dist/commonjs/schemas.js +1171 -0
  20. package/dist/esm/checks.d.ts +1 -0
  21. package/dist/esm/checks.js +1 -0
  22. package/dist/esm/coerce.d.ts +17 -0
  23. package/dist/esm/coerce.js +17 -0
  24. package/dist/esm/compat.d.ts +47 -0
  25. package/dist/esm/compat.js +33 -0
  26. package/dist/esm/errors.d.ts +23 -0
  27. package/dist/esm/errors.js +20 -0
  28. package/dist/esm/external.d.ts +8 -0
  29. package/dist/esm/external.js +11 -0
  30. package/dist/esm/index.d.ts +4 -0
  31. package/dist/esm/index.js +4 -0
  32. package/dist/esm/iso.d.ts +22 -0
  33. package/dist/esm/iso.js +30 -0
  34. package/dist/esm/package.json +3 -0
  35. package/dist/esm/parse.d.ts +17 -0
  36. package/dist/esm/parse.js +8 -0
  37. package/dist/esm/schemas.d.ts +738 -0
  38. package/dist/esm/schemas.js +1057 -0
  39. package/package.json +59 -99
  40. package/src/checks.ts +30 -0
  41. package/src/coerce.ts +27 -0
  42. package/src/compat.ts +74 -0
  43. package/src/errors.ts +47 -0
  44. package/src/external.ts +29 -0
  45. package/src/index.ts +5 -0
  46. package/src/iso.ts +90 -0
  47. package/src/parse.ts +32 -0
  48. package/src/schemas.ts +2324 -0
  49. package/README.md +0 -3074
  50. package/index.d.ts +0 -2
  51. package/lib/ZodError.d.ts +0 -164
  52. package/lib/ZodError.js +0 -137
  53. package/lib/__tests__/Mocker.d.ts +0 -17
  54. package/lib/__tests__/Mocker.js +0 -57
  55. package/lib/benchmarks/datetime.d.ts +0 -5
  56. package/lib/benchmarks/datetime.js +0 -54
  57. package/lib/benchmarks/discriminatedUnion.d.ts +0 -5
  58. package/lib/benchmarks/discriminatedUnion.js +0 -79
  59. package/lib/benchmarks/index.d.ts +0 -1
  60. package/lib/benchmarks/index.js +0 -59
  61. package/lib/benchmarks/ipv4.d.ts +0 -5
  62. package/lib/benchmarks/ipv4.js +0 -54
  63. package/lib/benchmarks/object.d.ts +0 -5
  64. package/lib/benchmarks/object.js +0 -70
  65. package/lib/benchmarks/primitives.d.ts +0 -5
  66. package/lib/benchmarks/primitives.js +0 -170
  67. package/lib/benchmarks/realworld.d.ts +0 -5
  68. package/lib/benchmarks/realworld.js +0 -56
  69. package/lib/benchmarks/string.d.ts +0 -5
  70. package/lib/benchmarks/string.js +0 -55
  71. package/lib/benchmarks/union.d.ts +0 -5
  72. package/lib/benchmarks/union.js +0 -79
  73. package/lib/errors.d.ts +0 -5
  74. package/lib/errors.js +0 -17
  75. package/lib/external.d.ts +0 -6
  76. package/lib/external.js +0 -22
  77. package/lib/helpers/enumUtil.d.ts +0 -8
  78. package/lib/helpers/enumUtil.js +0 -2
  79. package/lib/helpers/errorUtil.d.ts +0 -9
  80. package/lib/helpers/errorUtil.js +0 -8
  81. package/lib/helpers/parseUtil.d.ts +0 -78
  82. package/lib/helpers/parseUtil.js +0 -125
  83. package/lib/helpers/partialUtil.d.ts +0 -8
  84. package/lib/helpers/partialUtil.js +0 -2
  85. package/lib/helpers/typeAliases.d.ts +0 -2
  86. package/lib/helpers/typeAliases.js +0 -2
  87. package/lib/helpers/util.d.ts +0 -82
  88. package/lib/helpers/util.js +0 -142
  89. package/lib/index.d.ts +0 -4
  90. package/lib/index.mjs +0 -4405
  91. package/lib/index.umd.js +0 -4520
  92. package/lib/locales/en.d.ts +0 -3
  93. package/lib/locales/en.js +0 -129
  94. package/lib/standard-schema.d.ts +0 -102
  95. package/lib/standard-schema.js +0 -2
  96. package/lib/types.d.ts +0 -1062
  97. package/lib/types.js +0 -3846
@@ -1,70 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const benchmark_1 = __importDefault(require("benchmark"));
7
- const index_1 = require("../index");
8
- const emptySuite = new benchmark_1.default.Suite("z.object: empty");
9
- const shortSuite = new benchmark_1.default.Suite("z.object: short");
10
- const longSuite = new benchmark_1.default.Suite("z.object: long");
11
- const empty = index_1.z.object({});
12
- const short = index_1.z.object({
13
- string: index_1.z.string(),
14
- });
15
- const long = index_1.z.object({
16
- string: index_1.z.string(),
17
- number: index_1.z.number(),
18
- boolean: index_1.z.boolean(),
19
- });
20
- emptySuite
21
- .add("valid", () => {
22
- empty.parse({});
23
- })
24
- .add("valid: extra keys", () => {
25
- empty.parse({ string: "string" });
26
- })
27
- .add("invalid: null", () => {
28
- try {
29
- empty.parse(null);
30
- }
31
- catch (err) { }
32
- })
33
- .on("cycle", (e) => {
34
- console.log(`${emptySuite.name}: ${e.target}`);
35
- });
36
- shortSuite
37
- .add("valid", () => {
38
- short.parse({ string: "string" });
39
- })
40
- .add("valid: extra keys", () => {
41
- short.parse({ string: "string", number: 42 });
42
- })
43
- .add("invalid: null", () => {
44
- try {
45
- short.parse(null);
46
- }
47
- catch (err) { }
48
- })
49
- .on("cycle", (e) => {
50
- console.log(`${shortSuite.name}: ${e.target}`);
51
- });
52
- longSuite
53
- .add("valid", () => {
54
- long.parse({ string: "string", number: 42, boolean: true });
55
- })
56
- .add("valid: extra keys", () => {
57
- long.parse({ string: "string", number: 42, boolean: true, list: [] });
58
- })
59
- .add("invalid: null", () => {
60
- try {
61
- long.parse(null);
62
- }
63
- catch (err) { }
64
- })
65
- .on("cycle", (e) => {
66
- console.log(`${longSuite.name}: ${e.target}`);
67
- });
68
- exports.default = {
69
- suites: [emptySuite, shortSuite, longSuite],
70
- };
@@ -1,5 +0,0 @@
1
- import Benchmark from "benchmark";
2
- declare const _default: {
3
- suites: Benchmark.Suite[];
4
- };
5
- export default _default;
@@ -1,170 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const benchmark_1 = __importDefault(require("benchmark"));
7
- const Mocker_1 = require("../__tests__/Mocker");
8
- const index_1 = require("../index");
9
- const val = new Mocker_1.Mocker();
10
- const enumSuite = new benchmark_1.default.Suite("z.enum");
11
- const enumSchema = index_1.z.enum(["a", "b", "c"]);
12
- enumSuite
13
- .add("valid", () => {
14
- enumSchema.parse("a");
15
- })
16
- .add("invalid", () => {
17
- try {
18
- enumSchema.parse("x");
19
- }
20
- catch (e) { }
21
- })
22
- .on("cycle", (e) => {
23
- console.log(`z.enum: ${e.target}`);
24
- });
25
- const longEnumSuite = new benchmark_1.default.Suite("long z.enum");
26
- const longEnumSchema = index_1.z.enum([
27
- "one",
28
- "two",
29
- "three",
30
- "four",
31
- "five",
32
- "six",
33
- "seven",
34
- "eight",
35
- "nine",
36
- "ten",
37
- "eleven",
38
- "twelve",
39
- "thirteen",
40
- "fourteen",
41
- "fifteen",
42
- "sixteen",
43
- "seventeen",
44
- ]);
45
- longEnumSuite
46
- .add("valid", () => {
47
- longEnumSchema.parse("five");
48
- })
49
- .add("invalid", () => {
50
- try {
51
- longEnumSchema.parse("invalid");
52
- }
53
- catch (e) { }
54
- })
55
- .on("cycle", (e) => {
56
- console.log(`long z.enum: ${e.target}`);
57
- });
58
- const undefinedSuite = new benchmark_1.default.Suite("z.undefined");
59
- const undefinedSchema = index_1.z.undefined();
60
- undefinedSuite
61
- .add("valid", () => {
62
- undefinedSchema.parse(undefined);
63
- })
64
- .add("invalid", () => {
65
- try {
66
- undefinedSchema.parse(1);
67
- }
68
- catch (e) { }
69
- })
70
- .on("cycle", (e) => {
71
- console.log(`z.undefined: ${e.target}`);
72
- });
73
- const literalSuite = new benchmark_1.default.Suite("z.literal");
74
- const short = "short";
75
- const bad = "bad";
76
- const literalSchema = index_1.z.literal("short");
77
- literalSuite
78
- .add("valid", () => {
79
- literalSchema.parse(short);
80
- })
81
- .add("invalid", () => {
82
- try {
83
- literalSchema.parse(bad);
84
- }
85
- catch (e) { }
86
- })
87
- .on("cycle", (e) => {
88
- console.log(`z.literal: ${e.target}`);
89
- });
90
- const numberSuite = new benchmark_1.default.Suite("z.number");
91
- const numberSchema = index_1.z.number().int();
92
- numberSuite
93
- .add("valid", () => {
94
- numberSchema.parse(1);
95
- })
96
- .add("invalid type", () => {
97
- try {
98
- numberSchema.parse("bad");
99
- }
100
- catch (e) { }
101
- })
102
- .add("invalid number", () => {
103
- try {
104
- numberSchema.parse(0.5);
105
- }
106
- catch (e) { }
107
- })
108
- .on("cycle", (e) => {
109
- console.log(`z.number: ${e.target}`);
110
- });
111
- const dateSuite = new benchmark_1.default.Suite("z.date");
112
- const plainDate = index_1.z.date();
113
- const minMaxDate = index_1.z
114
- .date()
115
- .min(new Date("2021-01-01"))
116
- .max(new Date("2030-01-01"));
117
- dateSuite
118
- .add("valid", () => {
119
- plainDate.parse(new Date());
120
- })
121
- .add("invalid", () => {
122
- try {
123
- plainDate.parse(1);
124
- }
125
- catch (e) { }
126
- })
127
- .add("valid min and max", () => {
128
- minMaxDate.parse(new Date("2023-01-01"));
129
- })
130
- .add("invalid min", () => {
131
- try {
132
- minMaxDate.parse(new Date("2019-01-01"));
133
- }
134
- catch (e) { }
135
- })
136
- .add("invalid max", () => {
137
- try {
138
- minMaxDate.parse(new Date("2031-01-01"));
139
- }
140
- catch (e) { }
141
- })
142
- .on("cycle", (e) => {
143
- console.log(`z.date: ${e.target}`);
144
- });
145
- const symbolSuite = new benchmark_1.default.Suite("z.symbol");
146
- const symbolSchema = index_1.z.symbol();
147
- symbolSuite
148
- .add("valid", () => {
149
- symbolSchema.parse(val.symbol);
150
- })
151
- .add("invalid", () => {
152
- try {
153
- symbolSchema.parse(1);
154
- }
155
- catch (e) { }
156
- })
157
- .on("cycle", (e) => {
158
- console.log(`z.symbol: ${e.target}`);
159
- });
160
- exports.default = {
161
- suites: [
162
- enumSuite,
163
- longEnumSuite,
164
- undefinedSuite,
165
- literalSuite,
166
- numberSuite,
167
- dateSuite,
168
- symbolSuite,
169
- ],
170
- };
@@ -1,5 +0,0 @@
1
- import Benchmark from "benchmark";
2
- declare const _default: {
3
- suites: Benchmark.Suite[];
4
- };
5
- export default _default;
@@ -1,56 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const benchmark_1 = __importDefault(require("benchmark"));
7
- const index_1 = require("../index");
8
- const shortSuite = new benchmark_1.default.Suite("realworld");
9
- const People = index_1.z.array(index_1.z.object({
10
- type: index_1.z.literal("person"),
11
- hair: index_1.z.enum(["blue", "brown"]),
12
- active: index_1.z.boolean(),
13
- name: index_1.z.string(),
14
- age: index_1.z.number().int(),
15
- hobbies: index_1.z.array(index_1.z.string()),
16
- address: index_1.z.object({
17
- street: index_1.z.string(),
18
- zip: index_1.z.string(),
19
- country: index_1.z.string(),
20
- }),
21
- }));
22
- let i = 0;
23
- function num() {
24
- return ++i;
25
- }
26
- function str() {
27
- return (++i % 100).toString(16);
28
- }
29
- function array(fn) {
30
- return Array.from({ length: ++i % 10 }, () => fn());
31
- }
32
- const people = Array.from({ length: 100 }, () => {
33
- return {
34
- type: "person",
35
- hair: i % 2 ? "blue" : "brown",
36
- active: !!(i % 2),
37
- name: str(),
38
- age: num(),
39
- hobbies: array(str),
40
- address: {
41
- street: str(),
42
- zip: str(),
43
- country: str(),
44
- },
45
- };
46
- });
47
- shortSuite
48
- .add("valid", () => {
49
- People.parse(people);
50
- })
51
- .on("cycle", (e) => {
52
- console.log(`${shortSuite.name}: ${e.target}`);
53
- });
54
- exports.default = {
55
- suites: [shortSuite],
56
- };
@@ -1,5 +0,0 @@
1
- import Benchmark from "benchmark";
2
- declare const _default: {
3
- suites: Benchmark.Suite[];
4
- };
5
- export default _default;
@@ -1,55 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const benchmark_1 = __importDefault(require("benchmark"));
7
- const index_1 = require("../index");
8
- const SUITE_NAME = "z.string";
9
- const suite = new benchmark_1.default.Suite(SUITE_NAME);
10
- const empty = "";
11
- const short = "short";
12
- const long = "long".repeat(256);
13
- const manual = (str) => {
14
- if (typeof str !== "string") {
15
- throw new Error("Not a string");
16
- }
17
- return str;
18
- };
19
- const stringSchema = index_1.z.string();
20
- const optionalStringSchema = index_1.z.string().optional();
21
- const optionalNullableStringSchema = index_1.z.string().optional().nullable();
22
- suite
23
- .add("empty string", () => {
24
- stringSchema.parse(empty);
25
- })
26
- .add("short string", () => {
27
- stringSchema.parse(short);
28
- })
29
- .add("long string", () => {
30
- stringSchema.parse(long);
31
- })
32
- .add("optional string", () => {
33
- optionalStringSchema.parse(long);
34
- })
35
- .add("nullable string", () => {
36
- optionalNullableStringSchema.parse(long);
37
- })
38
- .add("nullable (null) string", () => {
39
- optionalNullableStringSchema.parse(null);
40
- })
41
- .add("invalid: null", () => {
42
- try {
43
- stringSchema.parse(null);
44
- }
45
- catch (err) { }
46
- })
47
- .add("manual parser: long", () => {
48
- manual(long);
49
- })
50
- .on("cycle", (e) => {
51
- console.log(`${SUITE_NAME}: ${e.target}`);
52
- });
53
- exports.default = {
54
- suites: [suite],
55
- };
@@ -1,5 +0,0 @@
1
- import Benchmark from "benchmark";
2
- declare const _default: {
3
- suites: Benchmark.Suite[];
4
- };
5
- export default _default;
@@ -1,79 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const benchmark_1 = __importDefault(require("benchmark"));
7
- const index_1 = require("../index");
8
- const doubleSuite = new benchmark_1.default.Suite("z.union: double");
9
- const manySuite = new benchmark_1.default.Suite("z.union: many");
10
- const aSchema = index_1.z.object({
11
- type: index_1.z.literal("a"),
12
- });
13
- const objA = {
14
- type: "a",
15
- };
16
- const bSchema = index_1.z.object({
17
- type: index_1.z.literal("b"),
18
- });
19
- const objB = {
20
- type: "b",
21
- };
22
- const cSchema = index_1.z.object({
23
- type: index_1.z.literal("c"),
24
- });
25
- const objC = {
26
- type: "c",
27
- };
28
- const dSchema = index_1.z.object({
29
- type: index_1.z.literal("d"),
30
- });
31
- const double = index_1.z.union([aSchema, bSchema]);
32
- const many = index_1.z.union([aSchema, bSchema, cSchema, dSchema]);
33
- doubleSuite
34
- .add("valid: a", () => {
35
- double.parse(objA);
36
- })
37
- .add("valid: b", () => {
38
- double.parse(objB);
39
- })
40
- .add("invalid: null", () => {
41
- try {
42
- double.parse(null);
43
- }
44
- catch (err) { }
45
- })
46
- .add("invalid: wrong shape", () => {
47
- try {
48
- double.parse(objC);
49
- }
50
- catch (err) { }
51
- })
52
- .on("cycle", (e) => {
53
- console.log(`${doubleSuite.name}: ${e.target}`);
54
- });
55
- manySuite
56
- .add("valid: a", () => {
57
- many.parse(objA);
58
- })
59
- .add("valid: c", () => {
60
- many.parse(objC);
61
- })
62
- .add("invalid: null", () => {
63
- try {
64
- many.parse(null);
65
- }
66
- catch (err) { }
67
- })
68
- .add("invalid: wrong shape", () => {
69
- try {
70
- many.parse({ type: "unknown" });
71
- }
72
- catch (err) { }
73
- })
74
- .on("cycle", (e) => {
75
- console.log(`${manySuite.name}: ${e.target}`);
76
- });
77
- exports.default = {
78
- suites: [doubleSuite, manySuite],
79
- };
package/lib/errors.d.ts DELETED
@@ -1,5 +0,0 @@
1
- import defaultErrorMap from "./locales/en";
2
- import type { ZodErrorMap } from "./ZodError";
3
- export { defaultErrorMap };
4
- export declare function setErrorMap(map: ZodErrorMap): void;
5
- export declare function getErrorMap(): ZodErrorMap;
package/lib/errors.js DELETED
@@ -1,17 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getErrorMap = exports.setErrorMap = exports.defaultErrorMap = void 0;
7
- const en_1 = __importDefault(require("./locales/en"));
8
- exports.defaultErrorMap = en_1.default;
9
- let overrideErrorMap = en_1.default;
10
- function setErrorMap(map) {
11
- overrideErrorMap = map;
12
- }
13
- exports.setErrorMap = setErrorMap;
14
- function getErrorMap() {
15
- return overrideErrorMap;
16
- }
17
- exports.getErrorMap = getErrorMap;
package/lib/external.d.ts DELETED
@@ -1,6 +0,0 @@
1
- export * from "./errors";
2
- export * from "./helpers/parseUtil";
3
- export * from "./helpers/typeAliases";
4
- export * from "./helpers/util";
5
- export * from "./types";
6
- export * from "./ZodError";
package/lib/external.js DELETED
@@ -1,22 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
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);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./errors"), exports);
18
- __exportStar(require("./helpers/parseUtil"), exports);
19
- __exportStar(require("./helpers/typeAliases"), exports);
20
- __exportStar(require("./helpers/util"), exports);
21
- __exportStar(require("./types"), exports);
22
- __exportStar(require("./ZodError"), exports);
@@ -1,8 +0,0 @@
1
- export declare namespace enumUtil {
2
- type UnionToIntersectionFn<T> = (T extends unknown ? (k: () => T) => void : never) extends (k: infer Intersection) => void ? Intersection : never;
3
- type GetUnionLast<T> = UnionToIntersectionFn<T> extends () => infer Last ? Last : never;
4
- type UnionToTuple<T, Tuple extends unknown[] = []> = [T] extends [never] ? Tuple : UnionToTuple<Exclude<T, GetUnionLast<T>>, [GetUnionLast<T>, ...Tuple]>;
5
- type CastToStringTuple<T> = T extends [string, ...string[]] ? T : never;
6
- export type UnionToTupleString<T> = CastToStringTuple<UnionToTuple<T>>;
7
- export {};
8
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,9 +0,0 @@
1
- export declare namespace errorUtil {
2
- type ErrMessage = string | {
3
- message?: string;
4
- };
5
- const errToObj: (message?: ErrMessage) => {
6
- message?: string | undefined;
7
- };
8
- const toString: (message?: ErrMessage) => string | undefined;
9
- }
@@ -1,8 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.errorUtil = void 0;
4
- var errorUtil;
5
- (function (errorUtil) {
6
- errorUtil.errToObj = (message) => typeof message === "string" ? { message } : message || {};
7
- errorUtil.toString = (message) => typeof message === "string" ? message : message === null || message === void 0 ? void 0 : message.message;
8
- })(errorUtil || (exports.errorUtil = errorUtil = {}));
@@ -1,78 +0,0 @@
1
- import type { IssueData, ZodErrorMap, ZodIssue } from "../ZodError";
2
- import type { ZodParsedType } from "./util";
3
- export declare const makeIssue: (params: {
4
- data: any;
5
- path: (string | number)[];
6
- errorMaps: ZodErrorMap[];
7
- issueData: IssueData;
8
- }) => ZodIssue;
9
- export type ParseParams = {
10
- path: (string | number)[];
11
- errorMap: ZodErrorMap;
12
- async: boolean;
13
- };
14
- export type ParsePathComponent = string | number;
15
- export type ParsePath = ParsePathComponent[];
16
- export declare const EMPTY_PATH: ParsePath;
17
- export interface ParseContext {
18
- readonly common: {
19
- readonly issues: ZodIssue[];
20
- readonly contextualErrorMap?: ZodErrorMap;
21
- readonly async: boolean;
22
- };
23
- readonly path: ParsePath;
24
- readonly schemaErrorMap?: ZodErrorMap;
25
- readonly parent: ParseContext | null;
26
- readonly data: any;
27
- readonly parsedType: ZodParsedType;
28
- }
29
- export type ParseInput = {
30
- data: any;
31
- path: (string | number)[];
32
- parent: ParseContext;
33
- };
34
- export declare function addIssueToContext(ctx: ParseContext, issueData: IssueData): void;
35
- export type ObjectPair = {
36
- key: SyncParseReturnType<any>;
37
- value: SyncParseReturnType<any>;
38
- };
39
- export declare class ParseStatus {
40
- value: "aborted" | "dirty" | "valid";
41
- dirty(): void;
42
- abort(): void;
43
- static mergeArray(status: ParseStatus, results: SyncParseReturnType<any>[]): SyncParseReturnType;
44
- static mergeObjectAsync(status: ParseStatus, pairs: {
45
- key: ParseReturnType<any>;
46
- value: ParseReturnType<any>;
47
- }[]): Promise<SyncParseReturnType<any>>;
48
- static mergeObjectSync(status: ParseStatus, pairs: {
49
- key: SyncParseReturnType<any>;
50
- value: SyncParseReturnType<any>;
51
- alwaysSet?: boolean;
52
- }[]): SyncParseReturnType;
53
- }
54
- export interface ParseResult {
55
- status: "aborted" | "dirty" | "valid";
56
- data: any;
57
- }
58
- export type INVALID = {
59
- status: "aborted";
60
- };
61
- export declare const INVALID: INVALID;
62
- export type DIRTY<T> = {
63
- status: "dirty";
64
- value: T;
65
- };
66
- export declare const DIRTY: <T>(value: T) => DIRTY<T>;
67
- export type OK<T> = {
68
- status: "valid";
69
- value: T;
70
- };
71
- export declare const OK: <T>(value: T) => OK<T>;
72
- export type SyncParseReturnType<T = any> = OK<T> | DIRTY<T> | INVALID;
73
- export type AsyncParseReturnType<T> = Promise<SyncParseReturnType<T>>;
74
- export type ParseReturnType<T> = SyncParseReturnType<T> | AsyncParseReturnType<T>;
75
- export declare const isAborted: (x: ParseReturnType<any>) => x is INVALID;
76
- export declare const isDirty: <T>(x: ParseReturnType<T>) => x is OK<T> | DIRTY<T>;
77
- export declare const isValid: <T>(x: ParseReturnType<T>) => x is OK<T>;
78
- export declare const isAsync: <T>(x: ParseReturnType<T>) => x is AsyncParseReturnType<T>;