@hashgraphonline/standards-sdk 0.0.103 → 0.0.104

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 (223) hide show
  1. package/dist/es/services/mirror-node.d.ts +1 -1
  2. package/dist/es/services/mirror-node.d.ts.map +1 -1
  3. package/dist/es/standards-sdk.es100.js +4 -64
  4. package/dist/es/standards-sdk.es100.js.map +1 -1
  5. package/dist/es/standards-sdk.es101.js +38 -5
  6. package/dist/es/standards-sdk.es101.js.map +1 -1
  7. package/dist/es/standards-sdk.es102.js +38 -13
  8. package/dist/es/standards-sdk.es102.js.map +1 -1
  9. package/dist/es/standards-sdk.es103.js +36 -6
  10. package/dist/es/standards-sdk.es103.js.map +1 -1
  11. package/dist/es/standards-sdk.es104.js +73 -40
  12. package/dist/es/standards-sdk.es104.js.map +1 -1
  13. package/dist/es/standards-sdk.es105.js +21 -2
  14. package/dist/es/standards-sdk.es105.js.map +1 -1
  15. package/dist/es/standards-sdk.es106.js +27 -136
  16. package/dist/es/standards-sdk.es106.js.map +1 -1
  17. package/dist/es/standards-sdk.es107.js +26 -172
  18. package/dist/es/standards-sdk.es107.js.map +1 -1
  19. package/dist/es/standards-sdk.es108.js +38 -13
  20. package/dist/es/standards-sdk.es108.js.map +1 -1
  21. package/dist/es/standards-sdk.es109.js +34 -13
  22. package/dist/es/standards-sdk.es109.js.map +1 -1
  23. package/dist/es/standards-sdk.es110.js +31 -30
  24. package/dist/es/standards-sdk.es110.js.map +1 -1
  25. package/dist/es/standards-sdk.es111.js +9 -15
  26. package/dist/es/standards-sdk.es111.js.map +1 -1
  27. package/dist/es/standards-sdk.es112.js +34 -4
  28. package/dist/es/standards-sdk.es112.js.map +1 -1
  29. package/dist/es/standards-sdk.es113.js +3 -4
  30. package/dist/es/standards-sdk.es113.js.map +1 -1
  31. package/dist/es/standards-sdk.es114.js +2 -16
  32. package/dist/es/standards-sdk.es114.js.map +1 -1
  33. package/dist/es/standards-sdk.es115.js +2 -5
  34. package/dist/es/standards-sdk.es115.js.map +1 -1
  35. package/dist/es/standards-sdk.es116.js +7136 -39
  36. package/dist/es/standards-sdk.es116.js.map +1 -1
  37. package/dist/es/standards-sdk.es117.js +98 -37
  38. package/dist/es/standards-sdk.es117.js.map +1 -1
  39. package/dist/es/standards-sdk.es118.js +2 -37
  40. package/dist/es/standards-sdk.es118.js.map +1 -1
  41. package/dist/es/standards-sdk.es119.js +16 -78
  42. package/dist/es/standards-sdk.es119.js.map +1 -1
  43. package/dist/es/standards-sdk.es120.js +409 -3
  44. package/dist/es/standards-sdk.es120.js.map +1 -1
  45. package/dist/es/standards-sdk.es121.js +2282 -2
  46. package/dist/es/standards-sdk.es121.js.map +1 -1
  47. package/dist/es/standards-sdk.es122.js +10 -2
  48. package/dist/es/standards-sdk.es122.js.map +1 -1
  49. package/dist/es/standards-sdk.es123.js +10 -33
  50. package/dist/es/standards-sdk.es123.js.map +1 -1
  51. package/dist/es/standards-sdk.es124.js +16 -31
  52. package/dist/es/standards-sdk.es124.js.map +1 -1
  53. package/dist/es/standards-sdk.es125.js +6 -9
  54. package/dist/es/standards-sdk.es125.js.map +1 -1
  55. package/dist/es/standards-sdk.es126.js +9 -34
  56. package/dist/es/standards-sdk.es126.js.map +1 -1
  57. package/dist/es/standards-sdk.es13.js +3 -3
  58. package/dist/es/standards-sdk.es15.js +1 -1
  59. package/dist/es/standards-sdk.es18.js +2 -2
  60. package/dist/es/standards-sdk.es19.js +2 -2
  61. package/dist/es/standards-sdk.es20.js +2 -2
  62. package/dist/es/standards-sdk.es21.js +6 -14
  63. package/dist/es/standards-sdk.es21.js.map +1 -1
  64. package/dist/es/standards-sdk.es24.js +10 -10
  65. package/dist/es/standards-sdk.es25.js +5 -1769
  66. package/dist/es/standards-sdk.es25.js.map +1 -1
  67. package/dist/es/standards-sdk.es26.js +36 -3
  68. package/dist/es/standards-sdk.es26.js.map +1 -1
  69. package/dist/es/standards-sdk.es27.js +48 -4168
  70. package/dist/es/standards-sdk.es27.js.map +1 -1
  71. package/dist/es/standards-sdk.es28.js +122 -5543
  72. package/dist/es/standards-sdk.es28.js.map +1 -1
  73. package/dist/es/standards-sdk.es29.js +9 -8
  74. package/dist/es/standards-sdk.es29.js.map +1 -1
  75. package/dist/es/standards-sdk.es30.js +7190 -2
  76. package/dist/es/standards-sdk.es30.js.map +1 -1
  77. package/dist/es/standards-sdk.es31.js +3 -36
  78. package/dist/es/standards-sdk.es31.js.map +1 -1
  79. package/dist/es/standards-sdk.es32.js +8 -47
  80. package/dist/es/standards-sdk.es32.js.map +1 -1
  81. package/dist/es/standards-sdk.es33.js +2 -5
  82. package/dist/es/standards-sdk.es33.js.map +1 -1
  83. package/dist/es/standards-sdk.es34.js +4166 -8
  84. package/dist/es/standards-sdk.es34.js.map +1 -1
  85. package/dist/es/standards-sdk.es35.js +419 -2
  86. package/dist/es/standards-sdk.es35.js.map +1 -1
  87. package/dist/es/standards-sdk.es36.js +2 -195
  88. package/dist/es/standards-sdk.es36.js.map +1 -1
  89. package/dist/es/standards-sdk.es37.js +111 -429
  90. package/dist/es/standards-sdk.es37.js.map +1 -1
  91. package/dist/es/standards-sdk.es38.js +3 -24
  92. package/dist/es/standards-sdk.es38.js.map +1 -1
  93. package/dist/es/standards-sdk.es39.js +348 -123
  94. package/dist/es/standards-sdk.es39.js.map +1 -1
  95. package/dist/es/standards-sdk.es40.js +5 -17
  96. package/dist/es/standards-sdk.es40.js.map +1 -1
  97. package/dist/es/standards-sdk.es41.js +173 -23
  98. package/dist/es/standards-sdk.es41.js.map +1 -1
  99. package/dist/es/standards-sdk.es42.js +75 -23
  100. package/dist/es/standards-sdk.es42.js.map +1 -1
  101. package/dist/es/standards-sdk.es43.js +111 -18
  102. package/dist/es/standards-sdk.es43.js.map +1 -1
  103. package/dist/es/standards-sdk.es44.js +46 -38
  104. package/dist/es/standards-sdk.es44.js.map +1 -1
  105. package/dist/es/standards-sdk.es45.js +9 -17
  106. package/dist/es/standards-sdk.es45.js.map +1 -1
  107. package/dist/es/standards-sdk.es46.js +88 -52
  108. package/dist/es/standards-sdk.es46.js.map +1 -1
  109. package/dist/es/standards-sdk.es47.js +3 -1288
  110. package/dist/es/standards-sdk.es47.js.map +1 -1
  111. package/dist/es/standards-sdk.es48.js +2 -148
  112. package/dist/es/standards-sdk.es48.js.map +1 -1
  113. package/dist/es/standards-sdk.es49.js +102 -80
  114. package/dist/es/standards-sdk.es49.js.map +1 -1
  115. package/dist/es/standards-sdk.es5.js +1 -1
  116. package/dist/es/standards-sdk.es50.js +70 -80
  117. package/dist/es/standards-sdk.es50.js.map +1 -1
  118. package/dist/es/standards-sdk.es51.js +5 -31
  119. package/dist/es/standards-sdk.es51.js.map +1 -1
  120. package/dist/es/standards-sdk.es52.js +4 -5
  121. package/dist/es/standards-sdk.es52.js.map +1 -1
  122. package/dist/es/standards-sdk.es53.js +200 -138
  123. package/dist/es/standards-sdk.es53.js.map +1 -1
  124. package/dist/es/standards-sdk.es54.js +55 -20
  125. package/dist/es/standards-sdk.es54.js.map +1 -1
  126. package/dist/es/standards-sdk.es55.js +68 -792
  127. package/dist/es/standards-sdk.es55.js.map +1 -1
  128. package/dist/es/standards-sdk.es56.js +2 -143
  129. package/dist/es/standards-sdk.es56.js.map +1 -1
  130. package/dist/es/standards-sdk.es57.js +71 -161
  131. package/dist/es/standards-sdk.es57.js.map +1 -1
  132. package/dist/es/standards-sdk.es58.js +22 -100
  133. package/dist/es/standards-sdk.es58.js.map +1 -1
  134. package/dist/es/standards-sdk.es59.js +148 -2
  135. package/dist/es/standards-sdk.es59.js.map +1 -1
  136. package/dist/es/standards-sdk.es60.js +90 -15
  137. package/dist/es/standards-sdk.es60.js.map +1 -1
  138. package/dist/es/standards-sdk.es61.js +3 -409
  139. package/dist/es/standards-sdk.es61.js.map +1 -1
  140. package/dist/es/standards-sdk.es62.js +159 -16
  141. package/dist/es/standards-sdk.es62.js.map +1 -1
  142. package/dist/es/standards-sdk.es63.js +29 -24
  143. package/dist/es/standards-sdk.es63.js.map +1 -1
  144. package/dist/es/standards-sdk.es64.js +61 -24
  145. package/dist/es/standards-sdk.es64.js.map +1 -1
  146. package/dist/es/standards-sdk.es65.js +47 -35
  147. package/dist/es/standards-sdk.es65.js.map +1 -1
  148. package/dist/es/standards-sdk.es66.js +10 -2282
  149. package/dist/es/standards-sdk.es66.js.map +1 -1
  150. package/dist/es/standards-sdk.es67.js +55 -154
  151. package/dist/es/standards-sdk.es67.js.map +1 -1
  152. package/dist/es/standards-sdk.es68.js +6 -3
  153. package/dist/es/standards-sdk.es68.js.map +1 -1
  154. package/dist/es/standards-sdk.es69.js +11 -7132
  155. package/dist/es/standards-sdk.es69.js.map +1 -1
  156. package/dist/es/standards-sdk.es7.js +4 -4
  157. package/dist/es/standards-sdk.es70.js +7 -10
  158. package/dist/es/standards-sdk.es70.js.map +1 -1
  159. package/dist/es/standards-sdk.es71.js +45 -11
  160. package/dist/es/standards-sdk.es71.js.map +1 -1
  161. package/dist/es/standards-sdk.es72.js +2 -18
  162. package/dist/es/standards-sdk.es72.js.map +1 -1
  163. package/dist/es/standards-sdk.es73.js +136 -6
  164. package/dist/es/standards-sdk.es73.js.map +1 -1
  165. package/dist/es/standards-sdk.es74.js +172 -9
  166. package/dist/es/standards-sdk.es74.js.map +1 -1
  167. package/dist/es/standards-sdk.es75.js +189 -413
  168. package/dist/es/standards-sdk.es75.js.map +1 -1
  169. package/dist/es/standards-sdk.es76.js +438 -2
  170. package/dist/es/standards-sdk.es76.js.map +1 -1
  171. package/dist/es/standards-sdk.es77.js +20 -115
  172. package/dist/es/standards-sdk.es77.js.map +1 -1
  173. package/dist/es/standards-sdk.es78.js +138 -3
  174. package/dist/es/standards-sdk.es78.js.map +1 -1
  175. package/dist/es/standards-sdk.es79.js +12 -358
  176. package/dist/es/standards-sdk.es79.js.map +1 -1
  177. package/dist/es/standards-sdk.es8.js +3 -3
  178. package/dist/es/standards-sdk.es80.js +28 -5
  179. package/dist/es/standards-sdk.es80.js.map +1 -1
  180. package/dist/es/standards-sdk.es81.js +23 -173
  181. package/dist/es/standards-sdk.es81.js.map +1 -1
  182. package/dist/es/standards-sdk.es82.js +15 -75
  183. package/dist/es/standards-sdk.es82.js.map +1 -1
  184. package/dist/es/standards-sdk.es83.js +39 -109
  185. package/dist/es/standards-sdk.es83.js.map +1 -1
  186. package/dist/es/standards-sdk.es84.js +14 -48
  187. package/dist/es/standards-sdk.es84.js.map +1 -1
  188. package/dist/es/standards-sdk.es85.js +60 -9
  189. package/dist/es/standards-sdk.es85.js.map +1 -1
  190. package/dist/es/standards-sdk.es86.js +1265 -73
  191. package/dist/es/standards-sdk.es86.js.map +1 -1
  192. package/dist/es/standards-sdk.es87.js +31 -3
  193. package/dist/es/standards-sdk.es87.js.map +1 -1
  194. package/dist/es/standards-sdk.es88.js +6 -2
  195. package/dist/es/standards-sdk.es88.js.map +1 -1
  196. package/dist/es/standards-sdk.es89.js +145 -99
  197. package/dist/es/standards-sdk.es89.js.map +1 -1
  198. package/dist/es/standards-sdk.es9.js +1 -1
  199. package/dist/es/standards-sdk.es90.js +790 -71
  200. package/dist/es/standards-sdk.es90.js.map +1 -1
  201. package/dist/es/standards-sdk.es91.js +142 -5
  202. package/dist/es/standards-sdk.es91.js.map +1 -1
  203. package/dist/es/standards-sdk.es92.js +173 -4
  204. package/dist/es/standards-sdk.es92.js.map +1 -1
  205. package/dist/es/standards-sdk.es93.js +13 -221
  206. package/dist/es/standards-sdk.es93.js.map +1 -1
  207. package/dist/es/standards-sdk.es94.js +13 -58
  208. package/dist/es/standards-sdk.es94.js.map +1 -1
  209. package/dist/es/standards-sdk.es95.js +31 -68
  210. package/dist/es/standards-sdk.es95.js.map +1 -1
  211. package/dist/es/standards-sdk.es96.js +14 -31
  212. package/dist/es/standards-sdk.es96.js.map +1 -1
  213. package/dist/es/standards-sdk.es97.js +3 -62
  214. package/dist/es/standards-sdk.es97.js.map +1 -1
  215. package/dist/es/standards-sdk.es98.js +3 -49
  216. package/dist/es/standards-sdk.es98.js.map +1 -1
  217. package/dist/es/standards-sdk.es99.js +14 -8
  218. package/dist/es/standards-sdk.es99.js.map +1 -1
  219. package/dist/umd/services/mirror-node.d.ts +1 -1
  220. package/dist/umd/services/mirror-node.d.ts.map +1 -1
  221. package/dist/umd/standards-sdk.umd.js +1 -1
  222. package/dist/umd/standards-sdk.umd.js.map +1 -1
  223. package/package.json +1 -1
@@ -1,13 +1,4171 @@
1
- import { getBytes } from "./standards-sdk.es49.js";
2
- function decodeBase64(textData) {
3
- textData = atob(textData);
4
- const data = new Uint8Array(textData.length);
5
- for (let i = 0; i < textData.length; i++) {
6
- data[i] = textData.charCodeAt(i);
1
+ var util;
2
+ (function(util2) {
3
+ util2.assertEqual = (val) => val;
4
+ function assertIs(_arg) {
5
+ }
6
+ util2.assertIs = assertIs;
7
+ function assertNever(_x) {
8
+ throw new Error();
9
+ }
10
+ util2.assertNever = assertNever;
11
+ util2.arrayToEnum = (items) => {
12
+ const obj = {};
13
+ for (const item of items) {
14
+ obj[item] = item;
15
+ }
16
+ return obj;
17
+ };
18
+ util2.getValidEnumValues = (obj) => {
19
+ const validKeys = util2.objectKeys(obj).filter((k) => typeof obj[obj[k]] !== "number");
20
+ const filtered = {};
21
+ for (const k of validKeys) {
22
+ filtered[k] = obj[k];
23
+ }
24
+ return util2.objectValues(filtered);
25
+ };
26
+ util2.objectValues = (obj) => {
27
+ return util2.objectKeys(obj).map(function(e) {
28
+ return obj[e];
29
+ });
30
+ };
31
+ util2.objectKeys = typeof Object.keys === "function" ? (obj) => Object.keys(obj) : (object) => {
32
+ const keys = [];
33
+ for (const key in object) {
34
+ if (Object.prototype.hasOwnProperty.call(object, key)) {
35
+ keys.push(key);
36
+ }
37
+ }
38
+ return keys;
39
+ };
40
+ util2.find = (arr, checker) => {
41
+ for (const item of arr) {
42
+ if (checker(item))
43
+ return item;
44
+ }
45
+ return void 0;
46
+ };
47
+ util2.isInteger = typeof Number.isInteger === "function" ? (val) => Number.isInteger(val) : (val) => typeof val === "number" && isFinite(val) && Math.floor(val) === val;
48
+ function joinValues(array, separator = " | ") {
49
+ return array.map((val) => typeof val === "string" ? `'${val}'` : val).join(separator);
50
+ }
51
+ util2.joinValues = joinValues;
52
+ util2.jsonStringifyReplacer = (_, value) => {
53
+ if (typeof value === "bigint") {
54
+ return value.toString();
55
+ }
56
+ return value;
57
+ };
58
+ })(util || (util = {}));
59
+ var objectUtil;
60
+ (function(objectUtil2) {
61
+ objectUtil2.mergeShapes = (first, second) => {
62
+ return {
63
+ ...first,
64
+ ...second
65
+ // second overwrites first
66
+ };
67
+ };
68
+ })(objectUtil || (objectUtil = {}));
69
+ const ZodParsedType = util.arrayToEnum([
70
+ "string",
71
+ "nan",
72
+ "number",
73
+ "integer",
74
+ "float",
75
+ "boolean",
76
+ "date",
77
+ "bigint",
78
+ "symbol",
79
+ "function",
80
+ "undefined",
81
+ "null",
82
+ "array",
83
+ "object",
84
+ "unknown",
85
+ "promise",
86
+ "void",
87
+ "never",
88
+ "map",
89
+ "set"
90
+ ]);
91
+ const getParsedType = (data) => {
92
+ const t = typeof data;
93
+ switch (t) {
94
+ case "undefined":
95
+ return ZodParsedType.undefined;
96
+ case "string":
97
+ return ZodParsedType.string;
98
+ case "number":
99
+ return isNaN(data) ? ZodParsedType.nan : ZodParsedType.number;
100
+ case "boolean":
101
+ return ZodParsedType.boolean;
102
+ case "function":
103
+ return ZodParsedType.function;
104
+ case "bigint":
105
+ return ZodParsedType.bigint;
106
+ case "symbol":
107
+ return ZodParsedType.symbol;
108
+ case "object":
109
+ if (Array.isArray(data)) {
110
+ return ZodParsedType.array;
111
+ }
112
+ if (data === null) {
113
+ return ZodParsedType.null;
114
+ }
115
+ if (data.then && typeof data.then === "function" && data.catch && typeof data.catch === "function") {
116
+ return ZodParsedType.promise;
117
+ }
118
+ if (typeof Map !== "undefined" && data instanceof Map) {
119
+ return ZodParsedType.map;
120
+ }
121
+ if (typeof Set !== "undefined" && data instanceof Set) {
122
+ return ZodParsedType.set;
123
+ }
124
+ if (typeof Date !== "undefined" && data instanceof Date) {
125
+ return ZodParsedType.date;
126
+ }
127
+ return ZodParsedType.object;
128
+ default:
129
+ return ZodParsedType.unknown;
130
+ }
131
+ };
132
+ const ZodIssueCode = util.arrayToEnum([
133
+ "invalid_type",
134
+ "invalid_literal",
135
+ "custom",
136
+ "invalid_union",
137
+ "invalid_union_discriminator",
138
+ "invalid_enum_value",
139
+ "unrecognized_keys",
140
+ "invalid_arguments",
141
+ "invalid_return_type",
142
+ "invalid_date",
143
+ "invalid_string",
144
+ "too_small",
145
+ "too_big",
146
+ "invalid_intersection_types",
147
+ "not_multiple_of",
148
+ "not_finite"
149
+ ]);
150
+ const quotelessJson = (obj) => {
151
+ const json = JSON.stringify(obj, null, 2);
152
+ return json.replace(/"([^"]+)":/g, "$1:");
153
+ };
154
+ class ZodError extends Error {
155
+ get errors() {
156
+ return this.issues;
157
+ }
158
+ constructor(issues) {
159
+ super();
160
+ this.issues = [];
161
+ this.addIssue = (sub) => {
162
+ this.issues = [...this.issues, sub];
163
+ };
164
+ this.addIssues = (subs = []) => {
165
+ this.issues = [...this.issues, ...subs];
166
+ };
167
+ const actualProto = new.target.prototype;
168
+ if (Object.setPrototypeOf) {
169
+ Object.setPrototypeOf(this, actualProto);
170
+ } else {
171
+ this.__proto__ = actualProto;
172
+ }
173
+ this.name = "ZodError";
174
+ this.issues = issues;
175
+ }
176
+ format(_mapper) {
177
+ const mapper = _mapper || function(issue) {
178
+ return issue.message;
179
+ };
180
+ const fieldErrors = { _errors: [] };
181
+ const processError = (error) => {
182
+ for (const issue of error.issues) {
183
+ if (issue.code === "invalid_union") {
184
+ issue.unionErrors.map(processError);
185
+ } else if (issue.code === "invalid_return_type") {
186
+ processError(issue.returnTypeError);
187
+ } else if (issue.code === "invalid_arguments") {
188
+ processError(issue.argumentsError);
189
+ } else if (issue.path.length === 0) {
190
+ fieldErrors._errors.push(mapper(issue));
191
+ } else {
192
+ let curr = fieldErrors;
193
+ let i = 0;
194
+ while (i < issue.path.length) {
195
+ const el = issue.path[i];
196
+ const terminal = i === issue.path.length - 1;
197
+ if (!terminal) {
198
+ curr[el] = curr[el] || { _errors: [] };
199
+ } else {
200
+ curr[el] = curr[el] || { _errors: [] };
201
+ curr[el]._errors.push(mapper(issue));
202
+ }
203
+ curr = curr[el];
204
+ i++;
205
+ }
206
+ }
207
+ }
208
+ };
209
+ processError(this);
210
+ return fieldErrors;
211
+ }
212
+ static assert(value) {
213
+ if (!(value instanceof ZodError)) {
214
+ throw new Error(`Not a ZodError: ${value}`);
215
+ }
216
+ }
217
+ toString() {
218
+ return this.message;
219
+ }
220
+ get message() {
221
+ return JSON.stringify(this.issues, util.jsonStringifyReplacer, 2);
222
+ }
223
+ get isEmpty() {
224
+ return this.issues.length === 0;
225
+ }
226
+ flatten(mapper = (issue) => issue.message) {
227
+ const fieldErrors = {};
228
+ const formErrors = [];
229
+ for (const sub of this.issues) {
230
+ if (sub.path.length > 0) {
231
+ fieldErrors[sub.path[0]] = fieldErrors[sub.path[0]] || [];
232
+ fieldErrors[sub.path[0]].push(mapper(sub));
233
+ } else {
234
+ formErrors.push(mapper(sub));
235
+ }
236
+ }
237
+ return { formErrors, fieldErrors };
238
+ }
239
+ get formErrors() {
240
+ return this.flatten();
241
+ }
242
+ }
243
+ ZodError.create = (issues) => {
244
+ const error = new ZodError(issues);
245
+ return error;
246
+ };
247
+ const errorMap = (issue, _ctx) => {
248
+ let message;
249
+ switch (issue.code) {
250
+ case ZodIssueCode.invalid_type:
251
+ if (issue.received === ZodParsedType.undefined) {
252
+ message = "Required";
253
+ } else {
254
+ message = `Expected ${issue.expected}, received ${issue.received}`;
255
+ }
256
+ break;
257
+ case ZodIssueCode.invalid_literal:
258
+ message = `Invalid literal value, expected ${JSON.stringify(issue.expected, util.jsonStringifyReplacer)}`;
259
+ break;
260
+ case ZodIssueCode.unrecognized_keys:
261
+ message = `Unrecognized key(s) in object: ${util.joinValues(issue.keys, ", ")}`;
262
+ break;
263
+ case ZodIssueCode.invalid_union:
264
+ message = `Invalid input`;
265
+ break;
266
+ case ZodIssueCode.invalid_union_discriminator:
267
+ message = `Invalid discriminator value. Expected ${util.joinValues(issue.options)}`;
268
+ break;
269
+ case ZodIssueCode.invalid_enum_value:
270
+ message = `Invalid enum value. Expected ${util.joinValues(issue.options)}, received '${issue.received}'`;
271
+ break;
272
+ case ZodIssueCode.invalid_arguments:
273
+ message = `Invalid function arguments`;
274
+ break;
275
+ case ZodIssueCode.invalid_return_type:
276
+ message = `Invalid function return type`;
277
+ break;
278
+ case ZodIssueCode.invalid_date:
279
+ message = `Invalid date`;
280
+ break;
281
+ case ZodIssueCode.invalid_string:
282
+ if (typeof issue.validation === "object") {
283
+ if ("includes" in issue.validation) {
284
+ message = `Invalid input: must include "${issue.validation.includes}"`;
285
+ if (typeof issue.validation.position === "number") {
286
+ message = `${message} at one or more positions greater than or equal to ${issue.validation.position}`;
287
+ }
288
+ } else if ("startsWith" in issue.validation) {
289
+ message = `Invalid input: must start with "${issue.validation.startsWith}"`;
290
+ } else if ("endsWith" in issue.validation) {
291
+ message = `Invalid input: must end with "${issue.validation.endsWith}"`;
292
+ } else {
293
+ util.assertNever(issue.validation);
294
+ }
295
+ } else if (issue.validation !== "regex") {
296
+ message = `Invalid ${issue.validation}`;
297
+ } else {
298
+ message = "Invalid";
299
+ }
300
+ break;
301
+ case ZodIssueCode.too_small:
302
+ if (issue.type === "array")
303
+ message = `Array must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `more than`} ${issue.minimum} element(s)`;
304
+ else if (issue.type === "string")
305
+ message = `String must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `over`} ${issue.minimum} character(s)`;
306
+ else if (issue.type === "number")
307
+ message = `Number must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${issue.minimum}`;
308
+ else if (issue.type === "date")
309
+ message = `Date must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${new Date(Number(issue.minimum))}`;
310
+ else
311
+ message = "Invalid input";
312
+ break;
313
+ case ZodIssueCode.too_big:
314
+ if (issue.type === "array")
315
+ message = `Array must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `less than`} ${issue.maximum} element(s)`;
316
+ else if (issue.type === "string")
317
+ message = `String must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `under`} ${issue.maximum} character(s)`;
318
+ else if (issue.type === "number")
319
+ message = `Number must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;
320
+ else if (issue.type === "bigint")
321
+ message = `BigInt must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;
322
+ else if (issue.type === "date")
323
+ message = `Date must be ${issue.exact ? `exactly` : issue.inclusive ? `smaller than or equal to` : `smaller than`} ${new Date(Number(issue.maximum))}`;
324
+ else
325
+ message = "Invalid input";
326
+ break;
327
+ case ZodIssueCode.custom:
328
+ message = `Invalid input`;
329
+ break;
330
+ case ZodIssueCode.invalid_intersection_types:
331
+ message = `Intersection results could not be merged`;
332
+ break;
333
+ case ZodIssueCode.not_multiple_of:
334
+ message = `Number must be a multiple of ${issue.multipleOf}`;
335
+ break;
336
+ case ZodIssueCode.not_finite:
337
+ message = "Number must be finite";
338
+ break;
339
+ default:
340
+ message = _ctx.defaultError;
341
+ util.assertNever(issue);
342
+ }
343
+ return { message };
344
+ };
345
+ let overrideErrorMap = errorMap;
346
+ function setErrorMap(map) {
347
+ overrideErrorMap = map;
348
+ }
349
+ function getErrorMap() {
350
+ return overrideErrorMap;
351
+ }
352
+ const makeIssue = (params) => {
353
+ const { data, path, errorMaps, issueData } = params;
354
+ const fullPath = [...path, ...issueData.path || []];
355
+ const fullIssue = {
356
+ ...issueData,
357
+ path: fullPath
358
+ };
359
+ if (issueData.message !== void 0) {
360
+ return {
361
+ ...issueData,
362
+ path: fullPath,
363
+ message: issueData.message
364
+ };
365
+ }
366
+ let errorMessage = "";
367
+ const maps = errorMaps.filter((m) => !!m).slice().reverse();
368
+ for (const map of maps) {
369
+ errorMessage = map(fullIssue, { data, defaultError: errorMessage }).message;
370
+ }
371
+ return {
372
+ ...issueData,
373
+ path: fullPath,
374
+ message: errorMessage
375
+ };
376
+ };
377
+ const EMPTY_PATH = [];
378
+ function addIssueToContext(ctx, issueData) {
379
+ const overrideMap = getErrorMap();
380
+ const issue = makeIssue({
381
+ issueData,
382
+ data: ctx.data,
383
+ path: ctx.path,
384
+ errorMaps: [
385
+ ctx.common.contextualErrorMap,
386
+ // contextual error map is first priority
387
+ ctx.schemaErrorMap,
388
+ // then schema-bound map if available
389
+ overrideMap,
390
+ // then global override map
391
+ overrideMap === errorMap ? void 0 : errorMap
392
+ // then global default map
393
+ ].filter((x) => !!x)
394
+ });
395
+ ctx.common.issues.push(issue);
396
+ }
397
+ class ParseStatus {
398
+ constructor() {
399
+ this.value = "valid";
400
+ }
401
+ dirty() {
402
+ if (this.value === "valid")
403
+ this.value = "dirty";
404
+ }
405
+ abort() {
406
+ if (this.value !== "aborted")
407
+ this.value = "aborted";
408
+ }
409
+ static mergeArray(status, results) {
410
+ const arrayValue = [];
411
+ for (const s of results) {
412
+ if (s.status === "aborted")
413
+ return INVALID;
414
+ if (s.status === "dirty")
415
+ status.dirty();
416
+ arrayValue.push(s.value);
417
+ }
418
+ return { status: status.value, value: arrayValue };
419
+ }
420
+ static async mergeObjectAsync(status, pairs) {
421
+ const syncPairs = [];
422
+ for (const pair of pairs) {
423
+ const key = await pair.key;
424
+ const value = await pair.value;
425
+ syncPairs.push({
426
+ key,
427
+ value
428
+ });
429
+ }
430
+ return ParseStatus.mergeObjectSync(status, syncPairs);
431
+ }
432
+ static mergeObjectSync(status, pairs) {
433
+ const finalObject = {};
434
+ for (const pair of pairs) {
435
+ const { key, value } = pair;
436
+ if (key.status === "aborted")
437
+ return INVALID;
438
+ if (value.status === "aborted")
439
+ return INVALID;
440
+ if (key.status === "dirty")
441
+ status.dirty();
442
+ if (value.status === "dirty")
443
+ status.dirty();
444
+ if (key.value !== "__proto__" && (typeof value.value !== "undefined" || pair.alwaysSet)) {
445
+ finalObject[key.value] = value.value;
446
+ }
447
+ }
448
+ return { status: status.value, value: finalObject };
449
+ }
450
+ }
451
+ const INVALID = Object.freeze({
452
+ status: "aborted"
453
+ });
454
+ const DIRTY = (value) => ({ status: "dirty", value });
455
+ const OK = (value) => ({ status: "valid", value });
456
+ const isAborted = (x) => x.status === "aborted";
457
+ const isDirty = (x) => x.status === "dirty";
458
+ const isValid = (x) => x.status === "valid";
459
+ const isAsync = (x) => typeof Promise !== "undefined" && x instanceof Promise;
460
+ function __classPrivateFieldGet(receiver, state, kind, f) {
461
+ if (typeof state === "function" ? receiver !== state || true : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
462
+ return state.get(receiver);
463
+ }
464
+ function __classPrivateFieldSet(receiver, state, value, kind, f) {
465
+ if (typeof state === "function" ? receiver !== state || true : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
466
+ return state.set(receiver, value), value;
467
+ }
468
+ typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed, message) {
469
+ var e = new Error(message);
470
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
471
+ };
472
+ var errorUtil;
473
+ (function(errorUtil2) {
474
+ errorUtil2.errToObj = (message) => typeof message === "string" ? { message } : message || {};
475
+ errorUtil2.toString = (message) => typeof message === "string" ? message : message === null || message === void 0 ? void 0 : message.message;
476
+ })(errorUtil || (errorUtil = {}));
477
+ var _ZodEnum_cache, _ZodNativeEnum_cache;
478
+ class ParseInputLazyPath {
479
+ constructor(parent, value, path, key) {
480
+ this._cachedPath = [];
481
+ this.parent = parent;
482
+ this.data = value;
483
+ this._path = path;
484
+ this._key = key;
485
+ }
486
+ get path() {
487
+ if (!this._cachedPath.length) {
488
+ if (this._key instanceof Array) {
489
+ this._cachedPath.push(...this._path, ...this._key);
490
+ } else {
491
+ this._cachedPath.push(...this._path, this._key);
492
+ }
493
+ }
494
+ return this._cachedPath;
495
+ }
496
+ }
497
+ const handleResult = (ctx, result) => {
498
+ if (isValid(result)) {
499
+ return { success: true, data: result.value };
500
+ } else {
501
+ if (!ctx.common.issues.length) {
502
+ throw new Error("Validation failed but no issues detected.");
503
+ }
504
+ return {
505
+ success: false,
506
+ get error() {
507
+ if (this._error)
508
+ return this._error;
509
+ const error = new ZodError(ctx.common.issues);
510
+ this._error = error;
511
+ return this._error;
512
+ }
513
+ };
514
+ }
515
+ };
516
+ function processCreateParams(params) {
517
+ if (!params)
518
+ return {};
519
+ const { errorMap: errorMap2, invalid_type_error, required_error, description } = params;
520
+ if (errorMap2 && (invalid_type_error || required_error)) {
521
+ throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);
522
+ }
523
+ if (errorMap2)
524
+ return { errorMap: errorMap2, description };
525
+ const customMap = (iss, ctx) => {
526
+ var _a, _b;
527
+ const { message } = params;
528
+ if (iss.code === "invalid_enum_value") {
529
+ return { message: message !== null && message !== void 0 ? message : ctx.defaultError };
530
+ }
531
+ if (typeof ctx.data === "undefined") {
532
+ return { message: (_a = message !== null && message !== void 0 ? message : required_error) !== null && _a !== void 0 ? _a : ctx.defaultError };
533
+ }
534
+ if (iss.code !== "invalid_type")
535
+ return { message: ctx.defaultError };
536
+ return { message: (_b = message !== null && message !== void 0 ? message : invalid_type_error) !== null && _b !== void 0 ? _b : ctx.defaultError };
537
+ };
538
+ return { errorMap: customMap, description };
539
+ }
540
+ class ZodType {
541
+ get description() {
542
+ return this._def.description;
543
+ }
544
+ _getType(input) {
545
+ return getParsedType(input.data);
546
+ }
547
+ _getOrReturnCtx(input, ctx) {
548
+ return ctx || {
549
+ common: input.parent.common,
550
+ data: input.data,
551
+ parsedType: getParsedType(input.data),
552
+ schemaErrorMap: this._def.errorMap,
553
+ path: input.path,
554
+ parent: input.parent
555
+ };
556
+ }
557
+ _processInputParams(input) {
558
+ return {
559
+ status: new ParseStatus(),
560
+ ctx: {
561
+ common: input.parent.common,
562
+ data: input.data,
563
+ parsedType: getParsedType(input.data),
564
+ schemaErrorMap: this._def.errorMap,
565
+ path: input.path,
566
+ parent: input.parent
567
+ }
568
+ };
569
+ }
570
+ _parseSync(input) {
571
+ const result = this._parse(input);
572
+ if (isAsync(result)) {
573
+ throw new Error("Synchronous parse encountered promise.");
574
+ }
575
+ return result;
576
+ }
577
+ _parseAsync(input) {
578
+ const result = this._parse(input);
579
+ return Promise.resolve(result);
580
+ }
581
+ parse(data, params) {
582
+ const result = this.safeParse(data, params);
583
+ if (result.success)
584
+ return result.data;
585
+ throw result.error;
586
+ }
587
+ safeParse(data, params) {
588
+ var _a;
589
+ const ctx = {
590
+ common: {
591
+ issues: [],
592
+ async: (_a = params === null || params === void 0 ? void 0 : params.async) !== null && _a !== void 0 ? _a : false,
593
+ contextualErrorMap: params === null || params === void 0 ? void 0 : params.errorMap
594
+ },
595
+ path: (params === null || params === void 0 ? void 0 : params.path) || [],
596
+ schemaErrorMap: this._def.errorMap,
597
+ parent: null,
598
+ data,
599
+ parsedType: getParsedType(data)
600
+ };
601
+ const result = this._parseSync({ data, path: ctx.path, parent: ctx });
602
+ return handleResult(ctx, result);
603
+ }
604
+ "~validate"(data) {
605
+ var _a, _b;
606
+ const ctx = {
607
+ common: {
608
+ issues: [],
609
+ async: !!this["~standard"].async
610
+ },
611
+ path: [],
612
+ schemaErrorMap: this._def.errorMap,
613
+ parent: null,
614
+ data,
615
+ parsedType: getParsedType(data)
616
+ };
617
+ if (!this["~standard"].async) {
618
+ try {
619
+ const result = this._parseSync({ data, path: [], parent: ctx });
620
+ return isValid(result) ? {
621
+ value: result.value
622
+ } : {
623
+ issues: ctx.common.issues
624
+ };
625
+ } catch (err) {
626
+ 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")) {
627
+ this["~standard"].async = true;
628
+ }
629
+ ctx.common = {
630
+ issues: [],
631
+ async: true
632
+ };
633
+ }
634
+ }
635
+ return this._parseAsync({ data, path: [], parent: ctx }).then((result) => isValid(result) ? {
636
+ value: result.value
637
+ } : {
638
+ issues: ctx.common.issues
639
+ });
640
+ }
641
+ async parseAsync(data, params) {
642
+ const result = await this.safeParseAsync(data, params);
643
+ if (result.success)
644
+ return result.data;
645
+ throw result.error;
646
+ }
647
+ async safeParseAsync(data, params) {
648
+ const ctx = {
649
+ common: {
650
+ issues: [],
651
+ contextualErrorMap: params === null || params === void 0 ? void 0 : params.errorMap,
652
+ async: true
653
+ },
654
+ path: (params === null || params === void 0 ? void 0 : params.path) || [],
655
+ schemaErrorMap: this._def.errorMap,
656
+ parent: null,
657
+ data,
658
+ parsedType: getParsedType(data)
659
+ };
660
+ const maybeAsyncResult = this._parse({ data, path: ctx.path, parent: ctx });
661
+ const result = await (isAsync(maybeAsyncResult) ? maybeAsyncResult : Promise.resolve(maybeAsyncResult));
662
+ return handleResult(ctx, result);
663
+ }
664
+ refine(check, message) {
665
+ const getIssueProperties = (val) => {
666
+ if (typeof message === "string" || typeof message === "undefined") {
667
+ return { message };
668
+ } else if (typeof message === "function") {
669
+ return message(val);
670
+ } else {
671
+ return message;
672
+ }
673
+ };
674
+ return this._refinement((val, ctx) => {
675
+ const result = check(val);
676
+ const setError = () => ctx.addIssue({
677
+ code: ZodIssueCode.custom,
678
+ ...getIssueProperties(val)
679
+ });
680
+ if (typeof Promise !== "undefined" && result instanceof Promise) {
681
+ return result.then((data) => {
682
+ if (!data) {
683
+ setError();
684
+ return false;
685
+ } else {
686
+ return true;
687
+ }
688
+ });
689
+ }
690
+ if (!result) {
691
+ setError();
692
+ return false;
693
+ } else {
694
+ return true;
695
+ }
696
+ });
697
+ }
698
+ refinement(check, refinementData) {
699
+ return this._refinement((val, ctx) => {
700
+ if (!check(val)) {
701
+ ctx.addIssue(typeof refinementData === "function" ? refinementData(val, ctx) : refinementData);
702
+ return false;
703
+ } else {
704
+ return true;
705
+ }
706
+ });
707
+ }
708
+ _refinement(refinement) {
709
+ return new ZodEffects({
710
+ schema: this,
711
+ typeName: ZodFirstPartyTypeKind.ZodEffects,
712
+ effect: { type: "refinement", refinement }
713
+ });
714
+ }
715
+ superRefine(refinement) {
716
+ return this._refinement(refinement);
717
+ }
718
+ constructor(def) {
719
+ this.spa = this.safeParseAsync;
720
+ this._def = def;
721
+ this.parse = this.parse.bind(this);
722
+ this.safeParse = this.safeParse.bind(this);
723
+ this.parseAsync = this.parseAsync.bind(this);
724
+ this.safeParseAsync = this.safeParseAsync.bind(this);
725
+ this.spa = this.spa.bind(this);
726
+ this.refine = this.refine.bind(this);
727
+ this.refinement = this.refinement.bind(this);
728
+ this.superRefine = this.superRefine.bind(this);
729
+ this.optional = this.optional.bind(this);
730
+ this.nullable = this.nullable.bind(this);
731
+ this.nullish = this.nullish.bind(this);
732
+ this.array = this.array.bind(this);
733
+ this.promise = this.promise.bind(this);
734
+ this.or = this.or.bind(this);
735
+ this.and = this.and.bind(this);
736
+ this.transform = this.transform.bind(this);
737
+ this.brand = this.brand.bind(this);
738
+ this.default = this.default.bind(this);
739
+ this.catch = this.catch.bind(this);
740
+ this.describe = this.describe.bind(this);
741
+ this.pipe = this.pipe.bind(this);
742
+ this.readonly = this.readonly.bind(this);
743
+ this.isNullable = this.isNullable.bind(this);
744
+ this.isOptional = this.isOptional.bind(this);
745
+ this["~standard"] = {
746
+ version: 1,
747
+ vendor: "zod",
748
+ validate: (data) => this["~validate"](data)
749
+ };
750
+ }
751
+ optional() {
752
+ return ZodOptional.create(this, this._def);
753
+ }
754
+ nullable() {
755
+ return ZodNullable.create(this, this._def);
756
+ }
757
+ nullish() {
758
+ return this.nullable().optional();
759
+ }
760
+ array() {
761
+ return ZodArray.create(this);
762
+ }
763
+ promise() {
764
+ return ZodPromise.create(this, this._def);
765
+ }
766
+ or(option) {
767
+ return ZodUnion.create([this, option], this._def);
768
+ }
769
+ and(incoming) {
770
+ return ZodIntersection.create(this, incoming, this._def);
771
+ }
772
+ transform(transform) {
773
+ return new ZodEffects({
774
+ ...processCreateParams(this._def),
775
+ schema: this,
776
+ typeName: ZodFirstPartyTypeKind.ZodEffects,
777
+ effect: { type: "transform", transform }
778
+ });
779
+ }
780
+ default(def) {
781
+ const defaultValueFunc = typeof def === "function" ? def : () => def;
782
+ return new ZodDefault({
783
+ ...processCreateParams(this._def),
784
+ innerType: this,
785
+ defaultValue: defaultValueFunc,
786
+ typeName: ZodFirstPartyTypeKind.ZodDefault
787
+ });
788
+ }
789
+ brand() {
790
+ return new ZodBranded({
791
+ typeName: ZodFirstPartyTypeKind.ZodBranded,
792
+ type: this,
793
+ ...processCreateParams(this._def)
794
+ });
795
+ }
796
+ catch(def) {
797
+ const catchValueFunc = typeof def === "function" ? def : () => def;
798
+ return new ZodCatch({
799
+ ...processCreateParams(this._def),
800
+ innerType: this,
801
+ catchValue: catchValueFunc,
802
+ typeName: ZodFirstPartyTypeKind.ZodCatch
803
+ });
804
+ }
805
+ describe(description) {
806
+ const This = this.constructor;
807
+ return new This({
808
+ ...this._def,
809
+ description
810
+ });
811
+ }
812
+ pipe(target) {
813
+ return ZodPipeline.create(this, target);
814
+ }
815
+ readonly() {
816
+ return ZodReadonly.create(this);
817
+ }
818
+ isOptional() {
819
+ return this.safeParse(void 0).success;
820
+ }
821
+ isNullable() {
822
+ return this.safeParse(null).success;
823
+ }
824
+ }
825
+ const cuidRegex = /^c[^\s-]{8,}$/i;
826
+ const cuid2Regex = /^[0-9a-z]+$/;
827
+ const ulidRegex = /^[0-9A-HJKMNP-TV-Z]{26}$/i;
828
+ const uuidRegex = /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i;
829
+ const nanoidRegex = /^[a-z0-9_-]{21}$/i;
830
+ const jwtRegex = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/;
831
+ const durationRegex = /^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/;
832
+ const emailRegex = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;
833
+ const _emojiRegex = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
834
+ let emojiRegex;
835
+ const ipv4Regex = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/;
836
+ const ipv4CidrRegex = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/;
837
+ const ipv6Regex = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/;
838
+ const ipv6CidrRegex = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/;
839
+ const base64Regex = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;
840
+ const base64urlRegex = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/;
841
+ const dateRegexSource = `((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))`;
842
+ const dateRegex = new RegExp(`^${dateRegexSource}$`);
843
+ function timeRegexSource(args) {
844
+ let secondsRegexSource = `[0-5]\\d`;
845
+ if (args.precision) {
846
+ secondsRegexSource = `${secondsRegexSource}\\.\\d{${args.precision}}`;
847
+ } else if (args.precision == null) {
848
+ secondsRegexSource = `${secondsRegexSource}(\\.\\d+)?`;
849
+ }
850
+ const secondsQuantifier = args.precision ? "+" : "?";
851
+ return `([01]\\d|2[0-3]):[0-5]\\d(:${secondsRegexSource})${secondsQuantifier}`;
852
+ }
853
+ function timeRegex(args) {
854
+ return new RegExp(`^${timeRegexSource(args)}$`);
855
+ }
856
+ function datetimeRegex(args) {
857
+ let regex = `${dateRegexSource}T${timeRegexSource(args)}`;
858
+ const opts = [];
859
+ opts.push(args.local ? `Z?` : `Z`);
860
+ if (args.offset)
861
+ opts.push(`([+-]\\d{2}:?\\d{2})`);
862
+ regex = `${regex}(${opts.join("|")})`;
863
+ return new RegExp(`^${regex}$`);
864
+ }
865
+ function isValidIP(ip, version) {
866
+ if ((version === "v4" || !version) && ipv4Regex.test(ip)) {
867
+ return true;
868
+ }
869
+ if ((version === "v6" || !version) && ipv6Regex.test(ip)) {
870
+ return true;
871
+ }
872
+ return false;
873
+ }
874
+ function isValidJWT(jwt, alg) {
875
+ if (!jwtRegex.test(jwt))
876
+ return false;
877
+ try {
878
+ const [header] = jwt.split(".");
879
+ const base64 = header.replace(/-/g, "+").replace(/_/g, "/").padEnd(header.length + (4 - header.length % 4) % 4, "=");
880
+ const decoded = JSON.parse(atob(base64));
881
+ if (typeof decoded !== "object" || decoded === null)
882
+ return false;
883
+ if (!decoded.typ || !decoded.alg)
884
+ return false;
885
+ if (alg && decoded.alg !== alg)
886
+ return false;
887
+ return true;
888
+ } catch (_a) {
889
+ return false;
890
+ }
891
+ }
892
+ function isValidCidr(ip, version) {
893
+ if ((version === "v4" || !version) && ipv4CidrRegex.test(ip)) {
894
+ return true;
895
+ }
896
+ if ((version === "v6" || !version) && ipv6CidrRegex.test(ip)) {
897
+ return true;
898
+ }
899
+ return false;
900
+ }
901
+ class ZodString extends ZodType {
902
+ _parse(input) {
903
+ if (this._def.coerce) {
904
+ input.data = String(input.data);
905
+ }
906
+ const parsedType = this._getType(input);
907
+ if (parsedType !== ZodParsedType.string) {
908
+ const ctx2 = this._getOrReturnCtx(input);
909
+ addIssueToContext(ctx2, {
910
+ code: ZodIssueCode.invalid_type,
911
+ expected: ZodParsedType.string,
912
+ received: ctx2.parsedType
913
+ });
914
+ return INVALID;
915
+ }
916
+ const status = new ParseStatus();
917
+ let ctx = void 0;
918
+ for (const check of this._def.checks) {
919
+ if (check.kind === "min") {
920
+ if (input.data.length < check.value) {
921
+ ctx = this._getOrReturnCtx(input, ctx);
922
+ addIssueToContext(ctx, {
923
+ code: ZodIssueCode.too_small,
924
+ minimum: check.value,
925
+ type: "string",
926
+ inclusive: true,
927
+ exact: false,
928
+ message: check.message
929
+ });
930
+ status.dirty();
931
+ }
932
+ } else if (check.kind === "max") {
933
+ if (input.data.length > check.value) {
934
+ ctx = this._getOrReturnCtx(input, ctx);
935
+ addIssueToContext(ctx, {
936
+ code: ZodIssueCode.too_big,
937
+ maximum: check.value,
938
+ type: "string",
939
+ inclusive: true,
940
+ exact: false,
941
+ message: check.message
942
+ });
943
+ status.dirty();
944
+ }
945
+ } else if (check.kind === "length") {
946
+ const tooBig = input.data.length > check.value;
947
+ const tooSmall = input.data.length < check.value;
948
+ if (tooBig || tooSmall) {
949
+ ctx = this._getOrReturnCtx(input, ctx);
950
+ if (tooBig) {
951
+ addIssueToContext(ctx, {
952
+ code: ZodIssueCode.too_big,
953
+ maximum: check.value,
954
+ type: "string",
955
+ inclusive: true,
956
+ exact: true,
957
+ message: check.message
958
+ });
959
+ } else if (tooSmall) {
960
+ addIssueToContext(ctx, {
961
+ code: ZodIssueCode.too_small,
962
+ minimum: check.value,
963
+ type: "string",
964
+ inclusive: true,
965
+ exact: true,
966
+ message: check.message
967
+ });
968
+ }
969
+ status.dirty();
970
+ }
971
+ } else if (check.kind === "email") {
972
+ if (!emailRegex.test(input.data)) {
973
+ ctx = this._getOrReturnCtx(input, ctx);
974
+ addIssueToContext(ctx, {
975
+ validation: "email",
976
+ code: ZodIssueCode.invalid_string,
977
+ message: check.message
978
+ });
979
+ status.dirty();
980
+ }
981
+ } else if (check.kind === "emoji") {
982
+ if (!emojiRegex) {
983
+ emojiRegex = new RegExp(_emojiRegex, "u");
984
+ }
985
+ if (!emojiRegex.test(input.data)) {
986
+ ctx = this._getOrReturnCtx(input, ctx);
987
+ addIssueToContext(ctx, {
988
+ validation: "emoji",
989
+ code: ZodIssueCode.invalid_string,
990
+ message: check.message
991
+ });
992
+ status.dirty();
993
+ }
994
+ } else if (check.kind === "uuid") {
995
+ if (!uuidRegex.test(input.data)) {
996
+ ctx = this._getOrReturnCtx(input, ctx);
997
+ addIssueToContext(ctx, {
998
+ validation: "uuid",
999
+ code: ZodIssueCode.invalid_string,
1000
+ message: check.message
1001
+ });
1002
+ status.dirty();
1003
+ }
1004
+ } else if (check.kind === "nanoid") {
1005
+ if (!nanoidRegex.test(input.data)) {
1006
+ ctx = this._getOrReturnCtx(input, ctx);
1007
+ addIssueToContext(ctx, {
1008
+ validation: "nanoid",
1009
+ code: ZodIssueCode.invalid_string,
1010
+ message: check.message
1011
+ });
1012
+ status.dirty();
1013
+ }
1014
+ } else if (check.kind === "cuid") {
1015
+ if (!cuidRegex.test(input.data)) {
1016
+ ctx = this._getOrReturnCtx(input, ctx);
1017
+ addIssueToContext(ctx, {
1018
+ validation: "cuid",
1019
+ code: ZodIssueCode.invalid_string,
1020
+ message: check.message
1021
+ });
1022
+ status.dirty();
1023
+ }
1024
+ } else if (check.kind === "cuid2") {
1025
+ if (!cuid2Regex.test(input.data)) {
1026
+ ctx = this._getOrReturnCtx(input, ctx);
1027
+ addIssueToContext(ctx, {
1028
+ validation: "cuid2",
1029
+ code: ZodIssueCode.invalid_string,
1030
+ message: check.message
1031
+ });
1032
+ status.dirty();
1033
+ }
1034
+ } else if (check.kind === "ulid") {
1035
+ if (!ulidRegex.test(input.data)) {
1036
+ ctx = this._getOrReturnCtx(input, ctx);
1037
+ addIssueToContext(ctx, {
1038
+ validation: "ulid",
1039
+ code: ZodIssueCode.invalid_string,
1040
+ message: check.message
1041
+ });
1042
+ status.dirty();
1043
+ }
1044
+ } else if (check.kind === "url") {
1045
+ try {
1046
+ new URL(input.data);
1047
+ } catch (_a) {
1048
+ ctx = this._getOrReturnCtx(input, ctx);
1049
+ addIssueToContext(ctx, {
1050
+ validation: "url",
1051
+ code: ZodIssueCode.invalid_string,
1052
+ message: check.message
1053
+ });
1054
+ status.dirty();
1055
+ }
1056
+ } else if (check.kind === "regex") {
1057
+ check.regex.lastIndex = 0;
1058
+ const testResult = check.regex.test(input.data);
1059
+ if (!testResult) {
1060
+ ctx = this._getOrReturnCtx(input, ctx);
1061
+ addIssueToContext(ctx, {
1062
+ validation: "regex",
1063
+ code: ZodIssueCode.invalid_string,
1064
+ message: check.message
1065
+ });
1066
+ status.dirty();
1067
+ }
1068
+ } else if (check.kind === "trim") {
1069
+ input.data = input.data.trim();
1070
+ } else if (check.kind === "includes") {
1071
+ if (!input.data.includes(check.value, check.position)) {
1072
+ ctx = this._getOrReturnCtx(input, ctx);
1073
+ addIssueToContext(ctx, {
1074
+ code: ZodIssueCode.invalid_string,
1075
+ validation: { includes: check.value, position: check.position },
1076
+ message: check.message
1077
+ });
1078
+ status.dirty();
1079
+ }
1080
+ } else if (check.kind === "toLowerCase") {
1081
+ input.data = input.data.toLowerCase();
1082
+ } else if (check.kind === "toUpperCase") {
1083
+ input.data = input.data.toUpperCase();
1084
+ } else if (check.kind === "startsWith") {
1085
+ if (!input.data.startsWith(check.value)) {
1086
+ ctx = this._getOrReturnCtx(input, ctx);
1087
+ addIssueToContext(ctx, {
1088
+ code: ZodIssueCode.invalid_string,
1089
+ validation: { startsWith: check.value },
1090
+ message: check.message
1091
+ });
1092
+ status.dirty();
1093
+ }
1094
+ } else if (check.kind === "endsWith") {
1095
+ if (!input.data.endsWith(check.value)) {
1096
+ ctx = this._getOrReturnCtx(input, ctx);
1097
+ addIssueToContext(ctx, {
1098
+ code: ZodIssueCode.invalid_string,
1099
+ validation: { endsWith: check.value },
1100
+ message: check.message
1101
+ });
1102
+ status.dirty();
1103
+ }
1104
+ } else if (check.kind === "datetime") {
1105
+ const regex = datetimeRegex(check);
1106
+ if (!regex.test(input.data)) {
1107
+ ctx = this._getOrReturnCtx(input, ctx);
1108
+ addIssueToContext(ctx, {
1109
+ code: ZodIssueCode.invalid_string,
1110
+ validation: "datetime",
1111
+ message: check.message
1112
+ });
1113
+ status.dirty();
1114
+ }
1115
+ } else if (check.kind === "date") {
1116
+ const regex = dateRegex;
1117
+ if (!regex.test(input.data)) {
1118
+ ctx = this._getOrReturnCtx(input, ctx);
1119
+ addIssueToContext(ctx, {
1120
+ code: ZodIssueCode.invalid_string,
1121
+ validation: "date",
1122
+ message: check.message
1123
+ });
1124
+ status.dirty();
1125
+ }
1126
+ } else if (check.kind === "time") {
1127
+ const regex = timeRegex(check);
1128
+ if (!regex.test(input.data)) {
1129
+ ctx = this._getOrReturnCtx(input, ctx);
1130
+ addIssueToContext(ctx, {
1131
+ code: ZodIssueCode.invalid_string,
1132
+ validation: "time",
1133
+ message: check.message
1134
+ });
1135
+ status.dirty();
1136
+ }
1137
+ } else if (check.kind === "duration") {
1138
+ if (!durationRegex.test(input.data)) {
1139
+ ctx = this._getOrReturnCtx(input, ctx);
1140
+ addIssueToContext(ctx, {
1141
+ validation: "duration",
1142
+ code: ZodIssueCode.invalid_string,
1143
+ message: check.message
1144
+ });
1145
+ status.dirty();
1146
+ }
1147
+ } else if (check.kind === "ip") {
1148
+ if (!isValidIP(input.data, check.version)) {
1149
+ ctx = this._getOrReturnCtx(input, ctx);
1150
+ addIssueToContext(ctx, {
1151
+ validation: "ip",
1152
+ code: ZodIssueCode.invalid_string,
1153
+ message: check.message
1154
+ });
1155
+ status.dirty();
1156
+ }
1157
+ } else if (check.kind === "jwt") {
1158
+ if (!isValidJWT(input.data, check.alg)) {
1159
+ ctx = this._getOrReturnCtx(input, ctx);
1160
+ addIssueToContext(ctx, {
1161
+ validation: "jwt",
1162
+ code: ZodIssueCode.invalid_string,
1163
+ message: check.message
1164
+ });
1165
+ status.dirty();
1166
+ }
1167
+ } else if (check.kind === "cidr") {
1168
+ if (!isValidCidr(input.data, check.version)) {
1169
+ ctx = this._getOrReturnCtx(input, ctx);
1170
+ addIssueToContext(ctx, {
1171
+ validation: "cidr",
1172
+ code: ZodIssueCode.invalid_string,
1173
+ message: check.message
1174
+ });
1175
+ status.dirty();
1176
+ }
1177
+ } else if (check.kind === "base64") {
1178
+ if (!base64Regex.test(input.data)) {
1179
+ ctx = this._getOrReturnCtx(input, ctx);
1180
+ addIssueToContext(ctx, {
1181
+ validation: "base64",
1182
+ code: ZodIssueCode.invalid_string,
1183
+ message: check.message
1184
+ });
1185
+ status.dirty();
1186
+ }
1187
+ } else if (check.kind === "base64url") {
1188
+ if (!base64urlRegex.test(input.data)) {
1189
+ ctx = this._getOrReturnCtx(input, ctx);
1190
+ addIssueToContext(ctx, {
1191
+ validation: "base64url",
1192
+ code: ZodIssueCode.invalid_string,
1193
+ message: check.message
1194
+ });
1195
+ status.dirty();
1196
+ }
1197
+ } else {
1198
+ util.assertNever(check);
1199
+ }
1200
+ }
1201
+ return { status: status.value, value: input.data };
1202
+ }
1203
+ _regex(regex, validation, message) {
1204
+ return this.refinement((data) => regex.test(data), {
1205
+ validation,
1206
+ code: ZodIssueCode.invalid_string,
1207
+ ...errorUtil.errToObj(message)
1208
+ });
1209
+ }
1210
+ _addCheck(check) {
1211
+ return new ZodString({
1212
+ ...this._def,
1213
+ checks: [...this._def.checks, check]
1214
+ });
1215
+ }
1216
+ email(message) {
1217
+ return this._addCheck({ kind: "email", ...errorUtil.errToObj(message) });
1218
+ }
1219
+ url(message) {
1220
+ return this._addCheck({ kind: "url", ...errorUtil.errToObj(message) });
1221
+ }
1222
+ emoji(message) {
1223
+ return this._addCheck({ kind: "emoji", ...errorUtil.errToObj(message) });
1224
+ }
1225
+ uuid(message) {
1226
+ return this._addCheck({ kind: "uuid", ...errorUtil.errToObj(message) });
1227
+ }
1228
+ nanoid(message) {
1229
+ return this._addCheck({ kind: "nanoid", ...errorUtil.errToObj(message) });
1230
+ }
1231
+ cuid(message) {
1232
+ return this._addCheck({ kind: "cuid", ...errorUtil.errToObj(message) });
1233
+ }
1234
+ cuid2(message) {
1235
+ return this._addCheck({ kind: "cuid2", ...errorUtil.errToObj(message) });
1236
+ }
1237
+ ulid(message) {
1238
+ return this._addCheck({ kind: "ulid", ...errorUtil.errToObj(message) });
1239
+ }
1240
+ base64(message) {
1241
+ return this._addCheck({ kind: "base64", ...errorUtil.errToObj(message) });
1242
+ }
1243
+ base64url(message) {
1244
+ return this._addCheck({
1245
+ kind: "base64url",
1246
+ ...errorUtil.errToObj(message)
1247
+ });
1248
+ }
1249
+ jwt(options) {
1250
+ return this._addCheck({ kind: "jwt", ...errorUtil.errToObj(options) });
1251
+ }
1252
+ ip(options) {
1253
+ return this._addCheck({ kind: "ip", ...errorUtil.errToObj(options) });
1254
+ }
1255
+ cidr(options) {
1256
+ return this._addCheck({ kind: "cidr", ...errorUtil.errToObj(options) });
1257
+ }
1258
+ datetime(options) {
1259
+ var _a, _b;
1260
+ if (typeof options === "string") {
1261
+ return this._addCheck({
1262
+ kind: "datetime",
1263
+ precision: null,
1264
+ offset: false,
1265
+ local: false,
1266
+ message: options
1267
+ });
1268
+ }
1269
+ return this._addCheck({
1270
+ kind: "datetime",
1271
+ precision: typeof (options === null || options === void 0 ? void 0 : options.precision) === "undefined" ? null : options === null || options === void 0 ? void 0 : options.precision,
1272
+ offset: (_a = options === null || options === void 0 ? void 0 : options.offset) !== null && _a !== void 0 ? _a : false,
1273
+ local: (_b = options === null || options === void 0 ? void 0 : options.local) !== null && _b !== void 0 ? _b : false,
1274
+ ...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message)
1275
+ });
1276
+ }
1277
+ date(message) {
1278
+ return this._addCheck({ kind: "date", message });
1279
+ }
1280
+ time(options) {
1281
+ if (typeof options === "string") {
1282
+ return this._addCheck({
1283
+ kind: "time",
1284
+ precision: null,
1285
+ message: options
1286
+ });
1287
+ }
1288
+ return this._addCheck({
1289
+ kind: "time",
1290
+ precision: typeof (options === null || options === void 0 ? void 0 : options.precision) === "undefined" ? null : options === null || options === void 0 ? void 0 : options.precision,
1291
+ ...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message)
1292
+ });
1293
+ }
1294
+ duration(message) {
1295
+ return this._addCheck({ kind: "duration", ...errorUtil.errToObj(message) });
1296
+ }
1297
+ regex(regex, message) {
1298
+ return this._addCheck({
1299
+ kind: "regex",
1300
+ regex,
1301
+ ...errorUtil.errToObj(message)
1302
+ });
1303
+ }
1304
+ includes(value, options) {
1305
+ return this._addCheck({
1306
+ kind: "includes",
1307
+ value,
1308
+ position: options === null || options === void 0 ? void 0 : options.position,
1309
+ ...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message)
1310
+ });
1311
+ }
1312
+ startsWith(value, message) {
1313
+ return this._addCheck({
1314
+ kind: "startsWith",
1315
+ value,
1316
+ ...errorUtil.errToObj(message)
1317
+ });
1318
+ }
1319
+ endsWith(value, message) {
1320
+ return this._addCheck({
1321
+ kind: "endsWith",
1322
+ value,
1323
+ ...errorUtil.errToObj(message)
1324
+ });
1325
+ }
1326
+ min(minLength, message) {
1327
+ return this._addCheck({
1328
+ kind: "min",
1329
+ value: minLength,
1330
+ ...errorUtil.errToObj(message)
1331
+ });
1332
+ }
1333
+ max(maxLength, message) {
1334
+ return this._addCheck({
1335
+ kind: "max",
1336
+ value: maxLength,
1337
+ ...errorUtil.errToObj(message)
1338
+ });
1339
+ }
1340
+ length(len, message) {
1341
+ return this._addCheck({
1342
+ kind: "length",
1343
+ value: len,
1344
+ ...errorUtil.errToObj(message)
1345
+ });
1346
+ }
1347
+ /**
1348
+ * Equivalent to `.min(1)`
1349
+ */
1350
+ nonempty(message) {
1351
+ return this.min(1, errorUtil.errToObj(message));
1352
+ }
1353
+ trim() {
1354
+ return new ZodString({
1355
+ ...this._def,
1356
+ checks: [...this._def.checks, { kind: "trim" }]
1357
+ });
1358
+ }
1359
+ toLowerCase() {
1360
+ return new ZodString({
1361
+ ...this._def,
1362
+ checks: [...this._def.checks, { kind: "toLowerCase" }]
1363
+ });
1364
+ }
1365
+ toUpperCase() {
1366
+ return new ZodString({
1367
+ ...this._def,
1368
+ checks: [...this._def.checks, { kind: "toUpperCase" }]
1369
+ });
1370
+ }
1371
+ get isDatetime() {
1372
+ return !!this._def.checks.find((ch) => ch.kind === "datetime");
1373
+ }
1374
+ get isDate() {
1375
+ return !!this._def.checks.find((ch) => ch.kind === "date");
1376
+ }
1377
+ get isTime() {
1378
+ return !!this._def.checks.find((ch) => ch.kind === "time");
1379
+ }
1380
+ get isDuration() {
1381
+ return !!this._def.checks.find((ch) => ch.kind === "duration");
1382
+ }
1383
+ get isEmail() {
1384
+ return !!this._def.checks.find((ch) => ch.kind === "email");
1385
+ }
1386
+ get isURL() {
1387
+ return !!this._def.checks.find((ch) => ch.kind === "url");
1388
+ }
1389
+ get isEmoji() {
1390
+ return !!this._def.checks.find((ch) => ch.kind === "emoji");
1391
+ }
1392
+ get isUUID() {
1393
+ return !!this._def.checks.find((ch) => ch.kind === "uuid");
1394
+ }
1395
+ get isNANOID() {
1396
+ return !!this._def.checks.find((ch) => ch.kind === "nanoid");
1397
+ }
1398
+ get isCUID() {
1399
+ return !!this._def.checks.find((ch) => ch.kind === "cuid");
1400
+ }
1401
+ get isCUID2() {
1402
+ return !!this._def.checks.find((ch) => ch.kind === "cuid2");
1403
+ }
1404
+ get isULID() {
1405
+ return !!this._def.checks.find((ch) => ch.kind === "ulid");
1406
+ }
1407
+ get isIP() {
1408
+ return !!this._def.checks.find((ch) => ch.kind === "ip");
1409
+ }
1410
+ get isCIDR() {
1411
+ return !!this._def.checks.find((ch) => ch.kind === "cidr");
1412
+ }
1413
+ get isBase64() {
1414
+ return !!this._def.checks.find((ch) => ch.kind === "base64");
1415
+ }
1416
+ get isBase64url() {
1417
+ return !!this._def.checks.find((ch) => ch.kind === "base64url");
1418
+ }
1419
+ get minLength() {
1420
+ let min = null;
1421
+ for (const ch of this._def.checks) {
1422
+ if (ch.kind === "min") {
1423
+ if (min === null || ch.value > min)
1424
+ min = ch.value;
1425
+ }
1426
+ }
1427
+ return min;
1428
+ }
1429
+ get maxLength() {
1430
+ let max = null;
1431
+ for (const ch of this._def.checks) {
1432
+ if (ch.kind === "max") {
1433
+ if (max === null || ch.value < max)
1434
+ max = ch.value;
1435
+ }
1436
+ }
1437
+ return max;
7
1438
  }
8
- return getBytes(data);
9
1439
  }
1440
+ ZodString.create = (params) => {
1441
+ var _a;
1442
+ return new ZodString({
1443
+ checks: [],
1444
+ typeName: ZodFirstPartyTypeKind.ZodString,
1445
+ coerce: (_a = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a !== void 0 ? _a : false,
1446
+ ...processCreateParams(params)
1447
+ });
1448
+ };
1449
+ function floatSafeRemainder(val, step) {
1450
+ const valDecCount = (val.toString().split(".")[1] || "").length;
1451
+ const stepDecCount = (step.toString().split(".")[1] || "").length;
1452
+ const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;
1453
+ const valInt = parseInt(val.toFixed(decCount).replace(".", ""));
1454
+ const stepInt = parseInt(step.toFixed(decCount).replace(".", ""));
1455
+ return valInt % stepInt / Math.pow(10, decCount);
1456
+ }
1457
+ class ZodNumber extends ZodType {
1458
+ constructor() {
1459
+ super(...arguments);
1460
+ this.min = this.gte;
1461
+ this.max = this.lte;
1462
+ this.step = this.multipleOf;
1463
+ }
1464
+ _parse(input) {
1465
+ if (this._def.coerce) {
1466
+ input.data = Number(input.data);
1467
+ }
1468
+ const parsedType = this._getType(input);
1469
+ if (parsedType !== ZodParsedType.number) {
1470
+ const ctx2 = this._getOrReturnCtx(input);
1471
+ addIssueToContext(ctx2, {
1472
+ code: ZodIssueCode.invalid_type,
1473
+ expected: ZodParsedType.number,
1474
+ received: ctx2.parsedType
1475
+ });
1476
+ return INVALID;
1477
+ }
1478
+ let ctx = void 0;
1479
+ const status = new ParseStatus();
1480
+ for (const check of this._def.checks) {
1481
+ if (check.kind === "int") {
1482
+ if (!util.isInteger(input.data)) {
1483
+ ctx = this._getOrReturnCtx(input, ctx);
1484
+ addIssueToContext(ctx, {
1485
+ code: ZodIssueCode.invalid_type,
1486
+ expected: "integer",
1487
+ received: "float",
1488
+ message: check.message
1489
+ });
1490
+ status.dirty();
1491
+ }
1492
+ } else if (check.kind === "min") {
1493
+ const tooSmall = check.inclusive ? input.data < check.value : input.data <= check.value;
1494
+ if (tooSmall) {
1495
+ ctx = this._getOrReturnCtx(input, ctx);
1496
+ addIssueToContext(ctx, {
1497
+ code: ZodIssueCode.too_small,
1498
+ minimum: check.value,
1499
+ type: "number",
1500
+ inclusive: check.inclusive,
1501
+ exact: false,
1502
+ message: check.message
1503
+ });
1504
+ status.dirty();
1505
+ }
1506
+ } else if (check.kind === "max") {
1507
+ const tooBig = check.inclusive ? input.data > check.value : input.data >= check.value;
1508
+ if (tooBig) {
1509
+ ctx = this._getOrReturnCtx(input, ctx);
1510
+ addIssueToContext(ctx, {
1511
+ code: ZodIssueCode.too_big,
1512
+ maximum: check.value,
1513
+ type: "number",
1514
+ inclusive: check.inclusive,
1515
+ exact: false,
1516
+ message: check.message
1517
+ });
1518
+ status.dirty();
1519
+ }
1520
+ } else if (check.kind === "multipleOf") {
1521
+ if (floatSafeRemainder(input.data, check.value) !== 0) {
1522
+ ctx = this._getOrReturnCtx(input, ctx);
1523
+ addIssueToContext(ctx, {
1524
+ code: ZodIssueCode.not_multiple_of,
1525
+ multipleOf: check.value,
1526
+ message: check.message
1527
+ });
1528
+ status.dirty();
1529
+ }
1530
+ } else if (check.kind === "finite") {
1531
+ if (!Number.isFinite(input.data)) {
1532
+ ctx = this._getOrReturnCtx(input, ctx);
1533
+ addIssueToContext(ctx, {
1534
+ code: ZodIssueCode.not_finite,
1535
+ message: check.message
1536
+ });
1537
+ status.dirty();
1538
+ }
1539
+ } else {
1540
+ util.assertNever(check);
1541
+ }
1542
+ }
1543
+ return { status: status.value, value: input.data };
1544
+ }
1545
+ gte(value, message) {
1546
+ return this.setLimit("min", value, true, errorUtil.toString(message));
1547
+ }
1548
+ gt(value, message) {
1549
+ return this.setLimit("min", value, false, errorUtil.toString(message));
1550
+ }
1551
+ lte(value, message) {
1552
+ return this.setLimit("max", value, true, errorUtil.toString(message));
1553
+ }
1554
+ lt(value, message) {
1555
+ return this.setLimit("max", value, false, errorUtil.toString(message));
1556
+ }
1557
+ setLimit(kind, value, inclusive, message) {
1558
+ return new ZodNumber({
1559
+ ...this._def,
1560
+ checks: [
1561
+ ...this._def.checks,
1562
+ {
1563
+ kind,
1564
+ value,
1565
+ inclusive,
1566
+ message: errorUtil.toString(message)
1567
+ }
1568
+ ]
1569
+ });
1570
+ }
1571
+ _addCheck(check) {
1572
+ return new ZodNumber({
1573
+ ...this._def,
1574
+ checks: [...this._def.checks, check]
1575
+ });
1576
+ }
1577
+ int(message) {
1578
+ return this._addCheck({
1579
+ kind: "int",
1580
+ message: errorUtil.toString(message)
1581
+ });
1582
+ }
1583
+ positive(message) {
1584
+ return this._addCheck({
1585
+ kind: "min",
1586
+ value: 0,
1587
+ inclusive: false,
1588
+ message: errorUtil.toString(message)
1589
+ });
1590
+ }
1591
+ negative(message) {
1592
+ return this._addCheck({
1593
+ kind: "max",
1594
+ value: 0,
1595
+ inclusive: false,
1596
+ message: errorUtil.toString(message)
1597
+ });
1598
+ }
1599
+ nonpositive(message) {
1600
+ return this._addCheck({
1601
+ kind: "max",
1602
+ value: 0,
1603
+ inclusive: true,
1604
+ message: errorUtil.toString(message)
1605
+ });
1606
+ }
1607
+ nonnegative(message) {
1608
+ return this._addCheck({
1609
+ kind: "min",
1610
+ value: 0,
1611
+ inclusive: true,
1612
+ message: errorUtil.toString(message)
1613
+ });
1614
+ }
1615
+ multipleOf(value, message) {
1616
+ return this._addCheck({
1617
+ kind: "multipleOf",
1618
+ value,
1619
+ message: errorUtil.toString(message)
1620
+ });
1621
+ }
1622
+ finite(message) {
1623
+ return this._addCheck({
1624
+ kind: "finite",
1625
+ message: errorUtil.toString(message)
1626
+ });
1627
+ }
1628
+ safe(message) {
1629
+ return this._addCheck({
1630
+ kind: "min",
1631
+ inclusive: true,
1632
+ value: Number.MIN_SAFE_INTEGER,
1633
+ message: errorUtil.toString(message)
1634
+ })._addCheck({
1635
+ kind: "max",
1636
+ inclusive: true,
1637
+ value: Number.MAX_SAFE_INTEGER,
1638
+ message: errorUtil.toString(message)
1639
+ });
1640
+ }
1641
+ get minValue() {
1642
+ let min = null;
1643
+ for (const ch of this._def.checks) {
1644
+ if (ch.kind === "min") {
1645
+ if (min === null || ch.value > min)
1646
+ min = ch.value;
1647
+ }
1648
+ }
1649
+ return min;
1650
+ }
1651
+ get maxValue() {
1652
+ let max = null;
1653
+ for (const ch of this._def.checks) {
1654
+ if (ch.kind === "max") {
1655
+ if (max === null || ch.value < max)
1656
+ max = ch.value;
1657
+ }
1658
+ }
1659
+ return max;
1660
+ }
1661
+ get isInt() {
1662
+ return !!this._def.checks.find((ch) => ch.kind === "int" || ch.kind === "multipleOf" && util.isInteger(ch.value));
1663
+ }
1664
+ get isFinite() {
1665
+ let max = null, min = null;
1666
+ for (const ch of this._def.checks) {
1667
+ if (ch.kind === "finite" || ch.kind === "int" || ch.kind === "multipleOf") {
1668
+ return true;
1669
+ } else if (ch.kind === "min") {
1670
+ if (min === null || ch.value > min)
1671
+ min = ch.value;
1672
+ } else if (ch.kind === "max") {
1673
+ if (max === null || ch.value < max)
1674
+ max = ch.value;
1675
+ }
1676
+ }
1677
+ return Number.isFinite(min) && Number.isFinite(max);
1678
+ }
1679
+ }
1680
+ ZodNumber.create = (params) => {
1681
+ return new ZodNumber({
1682
+ checks: [],
1683
+ typeName: ZodFirstPartyTypeKind.ZodNumber,
1684
+ coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false,
1685
+ ...processCreateParams(params)
1686
+ });
1687
+ };
1688
+ class ZodBigInt extends ZodType {
1689
+ constructor() {
1690
+ super(...arguments);
1691
+ this.min = this.gte;
1692
+ this.max = this.lte;
1693
+ }
1694
+ _parse(input) {
1695
+ if (this._def.coerce) {
1696
+ try {
1697
+ input.data = BigInt(input.data);
1698
+ } catch (_a) {
1699
+ return this._getInvalidInput(input);
1700
+ }
1701
+ }
1702
+ const parsedType = this._getType(input);
1703
+ if (parsedType !== ZodParsedType.bigint) {
1704
+ return this._getInvalidInput(input);
1705
+ }
1706
+ let ctx = void 0;
1707
+ const status = new ParseStatus();
1708
+ for (const check of this._def.checks) {
1709
+ if (check.kind === "min") {
1710
+ const tooSmall = check.inclusive ? input.data < check.value : input.data <= check.value;
1711
+ if (tooSmall) {
1712
+ ctx = this._getOrReturnCtx(input, ctx);
1713
+ addIssueToContext(ctx, {
1714
+ code: ZodIssueCode.too_small,
1715
+ type: "bigint",
1716
+ minimum: check.value,
1717
+ inclusive: check.inclusive,
1718
+ message: check.message
1719
+ });
1720
+ status.dirty();
1721
+ }
1722
+ } else if (check.kind === "max") {
1723
+ const tooBig = check.inclusive ? input.data > check.value : input.data >= check.value;
1724
+ if (tooBig) {
1725
+ ctx = this._getOrReturnCtx(input, ctx);
1726
+ addIssueToContext(ctx, {
1727
+ code: ZodIssueCode.too_big,
1728
+ type: "bigint",
1729
+ maximum: check.value,
1730
+ inclusive: check.inclusive,
1731
+ message: check.message
1732
+ });
1733
+ status.dirty();
1734
+ }
1735
+ } else if (check.kind === "multipleOf") {
1736
+ if (input.data % check.value !== BigInt(0)) {
1737
+ ctx = this._getOrReturnCtx(input, ctx);
1738
+ addIssueToContext(ctx, {
1739
+ code: ZodIssueCode.not_multiple_of,
1740
+ multipleOf: check.value,
1741
+ message: check.message
1742
+ });
1743
+ status.dirty();
1744
+ }
1745
+ } else {
1746
+ util.assertNever(check);
1747
+ }
1748
+ }
1749
+ return { status: status.value, value: input.data };
1750
+ }
1751
+ _getInvalidInput(input) {
1752
+ const ctx = this._getOrReturnCtx(input);
1753
+ addIssueToContext(ctx, {
1754
+ code: ZodIssueCode.invalid_type,
1755
+ expected: ZodParsedType.bigint,
1756
+ received: ctx.parsedType
1757
+ });
1758
+ return INVALID;
1759
+ }
1760
+ gte(value, message) {
1761
+ return this.setLimit("min", value, true, errorUtil.toString(message));
1762
+ }
1763
+ gt(value, message) {
1764
+ return this.setLimit("min", value, false, errorUtil.toString(message));
1765
+ }
1766
+ lte(value, message) {
1767
+ return this.setLimit("max", value, true, errorUtil.toString(message));
1768
+ }
1769
+ lt(value, message) {
1770
+ return this.setLimit("max", value, false, errorUtil.toString(message));
1771
+ }
1772
+ setLimit(kind, value, inclusive, message) {
1773
+ return new ZodBigInt({
1774
+ ...this._def,
1775
+ checks: [
1776
+ ...this._def.checks,
1777
+ {
1778
+ kind,
1779
+ value,
1780
+ inclusive,
1781
+ message: errorUtil.toString(message)
1782
+ }
1783
+ ]
1784
+ });
1785
+ }
1786
+ _addCheck(check) {
1787
+ return new ZodBigInt({
1788
+ ...this._def,
1789
+ checks: [...this._def.checks, check]
1790
+ });
1791
+ }
1792
+ positive(message) {
1793
+ return this._addCheck({
1794
+ kind: "min",
1795
+ value: BigInt(0),
1796
+ inclusive: false,
1797
+ message: errorUtil.toString(message)
1798
+ });
1799
+ }
1800
+ negative(message) {
1801
+ return this._addCheck({
1802
+ kind: "max",
1803
+ value: BigInt(0),
1804
+ inclusive: false,
1805
+ message: errorUtil.toString(message)
1806
+ });
1807
+ }
1808
+ nonpositive(message) {
1809
+ return this._addCheck({
1810
+ kind: "max",
1811
+ value: BigInt(0),
1812
+ inclusive: true,
1813
+ message: errorUtil.toString(message)
1814
+ });
1815
+ }
1816
+ nonnegative(message) {
1817
+ return this._addCheck({
1818
+ kind: "min",
1819
+ value: BigInt(0),
1820
+ inclusive: true,
1821
+ message: errorUtil.toString(message)
1822
+ });
1823
+ }
1824
+ multipleOf(value, message) {
1825
+ return this._addCheck({
1826
+ kind: "multipleOf",
1827
+ value,
1828
+ message: errorUtil.toString(message)
1829
+ });
1830
+ }
1831
+ get minValue() {
1832
+ let min = null;
1833
+ for (const ch of this._def.checks) {
1834
+ if (ch.kind === "min") {
1835
+ if (min === null || ch.value > min)
1836
+ min = ch.value;
1837
+ }
1838
+ }
1839
+ return min;
1840
+ }
1841
+ get maxValue() {
1842
+ let max = null;
1843
+ for (const ch of this._def.checks) {
1844
+ if (ch.kind === "max") {
1845
+ if (max === null || ch.value < max)
1846
+ max = ch.value;
1847
+ }
1848
+ }
1849
+ return max;
1850
+ }
1851
+ }
1852
+ ZodBigInt.create = (params) => {
1853
+ var _a;
1854
+ return new ZodBigInt({
1855
+ checks: [],
1856
+ typeName: ZodFirstPartyTypeKind.ZodBigInt,
1857
+ coerce: (_a = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a !== void 0 ? _a : false,
1858
+ ...processCreateParams(params)
1859
+ });
1860
+ };
1861
+ class ZodBoolean extends ZodType {
1862
+ _parse(input) {
1863
+ if (this._def.coerce) {
1864
+ input.data = Boolean(input.data);
1865
+ }
1866
+ const parsedType = this._getType(input);
1867
+ if (parsedType !== ZodParsedType.boolean) {
1868
+ const ctx = this._getOrReturnCtx(input);
1869
+ addIssueToContext(ctx, {
1870
+ code: ZodIssueCode.invalid_type,
1871
+ expected: ZodParsedType.boolean,
1872
+ received: ctx.parsedType
1873
+ });
1874
+ return INVALID;
1875
+ }
1876
+ return OK(input.data);
1877
+ }
1878
+ }
1879
+ ZodBoolean.create = (params) => {
1880
+ return new ZodBoolean({
1881
+ typeName: ZodFirstPartyTypeKind.ZodBoolean,
1882
+ coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false,
1883
+ ...processCreateParams(params)
1884
+ });
1885
+ };
1886
+ class ZodDate extends ZodType {
1887
+ _parse(input) {
1888
+ if (this._def.coerce) {
1889
+ input.data = new Date(input.data);
1890
+ }
1891
+ const parsedType = this._getType(input);
1892
+ if (parsedType !== ZodParsedType.date) {
1893
+ const ctx2 = this._getOrReturnCtx(input);
1894
+ addIssueToContext(ctx2, {
1895
+ code: ZodIssueCode.invalid_type,
1896
+ expected: ZodParsedType.date,
1897
+ received: ctx2.parsedType
1898
+ });
1899
+ return INVALID;
1900
+ }
1901
+ if (isNaN(input.data.getTime())) {
1902
+ const ctx2 = this._getOrReturnCtx(input);
1903
+ addIssueToContext(ctx2, {
1904
+ code: ZodIssueCode.invalid_date
1905
+ });
1906
+ return INVALID;
1907
+ }
1908
+ const status = new ParseStatus();
1909
+ let ctx = void 0;
1910
+ for (const check of this._def.checks) {
1911
+ if (check.kind === "min") {
1912
+ if (input.data.getTime() < check.value) {
1913
+ ctx = this._getOrReturnCtx(input, ctx);
1914
+ addIssueToContext(ctx, {
1915
+ code: ZodIssueCode.too_small,
1916
+ message: check.message,
1917
+ inclusive: true,
1918
+ exact: false,
1919
+ minimum: check.value,
1920
+ type: "date"
1921
+ });
1922
+ status.dirty();
1923
+ }
1924
+ } else if (check.kind === "max") {
1925
+ if (input.data.getTime() > check.value) {
1926
+ ctx = this._getOrReturnCtx(input, ctx);
1927
+ addIssueToContext(ctx, {
1928
+ code: ZodIssueCode.too_big,
1929
+ message: check.message,
1930
+ inclusive: true,
1931
+ exact: false,
1932
+ maximum: check.value,
1933
+ type: "date"
1934
+ });
1935
+ status.dirty();
1936
+ }
1937
+ } else {
1938
+ util.assertNever(check);
1939
+ }
1940
+ }
1941
+ return {
1942
+ status: status.value,
1943
+ value: new Date(input.data.getTime())
1944
+ };
1945
+ }
1946
+ _addCheck(check) {
1947
+ return new ZodDate({
1948
+ ...this._def,
1949
+ checks: [...this._def.checks, check]
1950
+ });
1951
+ }
1952
+ min(minDate, message) {
1953
+ return this._addCheck({
1954
+ kind: "min",
1955
+ value: minDate.getTime(),
1956
+ message: errorUtil.toString(message)
1957
+ });
1958
+ }
1959
+ max(maxDate, message) {
1960
+ return this._addCheck({
1961
+ kind: "max",
1962
+ value: maxDate.getTime(),
1963
+ message: errorUtil.toString(message)
1964
+ });
1965
+ }
1966
+ get minDate() {
1967
+ let min = null;
1968
+ for (const ch of this._def.checks) {
1969
+ if (ch.kind === "min") {
1970
+ if (min === null || ch.value > min)
1971
+ min = ch.value;
1972
+ }
1973
+ }
1974
+ return min != null ? new Date(min) : null;
1975
+ }
1976
+ get maxDate() {
1977
+ let max = null;
1978
+ for (const ch of this._def.checks) {
1979
+ if (ch.kind === "max") {
1980
+ if (max === null || ch.value < max)
1981
+ max = ch.value;
1982
+ }
1983
+ }
1984
+ return max != null ? new Date(max) : null;
1985
+ }
1986
+ }
1987
+ ZodDate.create = (params) => {
1988
+ return new ZodDate({
1989
+ checks: [],
1990
+ coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false,
1991
+ typeName: ZodFirstPartyTypeKind.ZodDate,
1992
+ ...processCreateParams(params)
1993
+ });
1994
+ };
1995
+ class ZodSymbol extends ZodType {
1996
+ _parse(input) {
1997
+ const parsedType = this._getType(input);
1998
+ if (parsedType !== ZodParsedType.symbol) {
1999
+ const ctx = this._getOrReturnCtx(input);
2000
+ addIssueToContext(ctx, {
2001
+ code: ZodIssueCode.invalid_type,
2002
+ expected: ZodParsedType.symbol,
2003
+ received: ctx.parsedType
2004
+ });
2005
+ return INVALID;
2006
+ }
2007
+ return OK(input.data);
2008
+ }
2009
+ }
2010
+ ZodSymbol.create = (params) => {
2011
+ return new ZodSymbol({
2012
+ typeName: ZodFirstPartyTypeKind.ZodSymbol,
2013
+ ...processCreateParams(params)
2014
+ });
2015
+ };
2016
+ class ZodUndefined extends ZodType {
2017
+ _parse(input) {
2018
+ const parsedType = this._getType(input);
2019
+ if (parsedType !== ZodParsedType.undefined) {
2020
+ const ctx = this._getOrReturnCtx(input);
2021
+ addIssueToContext(ctx, {
2022
+ code: ZodIssueCode.invalid_type,
2023
+ expected: ZodParsedType.undefined,
2024
+ received: ctx.parsedType
2025
+ });
2026
+ return INVALID;
2027
+ }
2028
+ return OK(input.data);
2029
+ }
2030
+ }
2031
+ ZodUndefined.create = (params) => {
2032
+ return new ZodUndefined({
2033
+ typeName: ZodFirstPartyTypeKind.ZodUndefined,
2034
+ ...processCreateParams(params)
2035
+ });
2036
+ };
2037
+ class ZodNull extends ZodType {
2038
+ _parse(input) {
2039
+ const parsedType = this._getType(input);
2040
+ if (parsedType !== ZodParsedType.null) {
2041
+ const ctx = this._getOrReturnCtx(input);
2042
+ addIssueToContext(ctx, {
2043
+ code: ZodIssueCode.invalid_type,
2044
+ expected: ZodParsedType.null,
2045
+ received: ctx.parsedType
2046
+ });
2047
+ return INVALID;
2048
+ }
2049
+ return OK(input.data);
2050
+ }
2051
+ }
2052
+ ZodNull.create = (params) => {
2053
+ return new ZodNull({
2054
+ typeName: ZodFirstPartyTypeKind.ZodNull,
2055
+ ...processCreateParams(params)
2056
+ });
2057
+ };
2058
+ class ZodAny extends ZodType {
2059
+ constructor() {
2060
+ super(...arguments);
2061
+ this._any = true;
2062
+ }
2063
+ _parse(input) {
2064
+ return OK(input.data);
2065
+ }
2066
+ }
2067
+ ZodAny.create = (params) => {
2068
+ return new ZodAny({
2069
+ typeName: ZodFirstPartyTypeKind.ZodAny,
2070
+ ...processCreateParams(params)
2071
+ });
2072
+ };
2073
+ class ZodUnknown extends ZodType {
2074
+ constructor() {
2075
+ super(...arguments);
2076
+ this._unknown = true;
2077
+ }
2078
+ _parse(input) {
2079
+ return OK(input.data);
2080
+ }
2081
+ }
2082
+ ZodUnknown.create = (params) => {
2083
+ return new ZodUnknown({
2084
+ typeName: ZodFirstPartyTypeKind.ZodUnknown,
2085
+ ...processCreateParams(params)
2086
+ });
2087
+ };
2088
+ class ZodNever extends ZodType {
2089
+ _parse(input) {
2090
+ const ctx = this._getOrReturnCtx(input);
2091
+ addIssueToContext(ctx, {
2092
+ code: ZodIssueCode.invalid_type,
2093
+ expected: ZodParsedType.never,
2094
+ received: ctx.parsedType
2095
+ });
2096
+ return INVALID;
2097
+ }
2098
+ }
2099
+ ZodNever.create = (params) => {
2100
+ return new ZodNever({
2101
+ typeName: ZodFirstPartyTypeKind.ZodNever,
2102
+ ...processCreateParams(params)
2103
+ });
2104
+ };
2105
+ class ZodVoid extends ZodType {
2106
+ _parse(input) {
2107
+ const parsedType = this._getType(input);
2108
+ if (parsedType !== ZodParsedType.undefined) {
2109
+ const ctx = this._getOrReturnCtx(input);
2110
+ addIssueToContext(ctx, {
2111
+ code: ZodIssueCode.invalid_type,
2112
+ expected: ZodParsedType.void,
2113
+ received: ctx.parsedType
2114
+ });
2115
+ return INVALID;
2116
+ }
2117
+ return OK(input.data);
2118
+ }
2119
+ }
2120
+ ZodVoid.create = (params) => {
2121
+ return new ZodVoid({
2122
+ typeName: ZodFirstPartyTypeKind.ZodVoid,
2123
+ ...processCreateParams(params)
2124
+ });
2125
+ };
2126
+ class ZodArray extends ZodType {
2127
+ _parse(input) {
2128
+ const { ctx, status } = this._processInputParams(input);
2129
+ const def = this._def;
2130
+ if (ctx.parsedType !== ZodParsedType.array) {
2131
+ addIssueToContext(ctx, {
2132
+ code: ZodIssueCode.invalid_type,
2133
+ expected: ZodParsedType.array,
2134
+ received: ctx.parsedType
2135
+ });
2136
+ return INVALID;
2137
+ }
2138
+ if (def.exactLength !== null) {
2139
+ const tooBig = ctx.data.length > def.exactLength.value;
2140
+ const tooSmall = ctx.data.length < def.exactLength.value;
2141
+ if (tooBig || tooSmall) {
2142
+ addIssueToContext(ctx, {
2143
+ code: tooBig ? ZodIssueCode.too_big : ZodIssueCode.too_small,
2144
+ minimum: tooSmall ? def.exactLength.value : void 0,
2145
+ maximum: tooBig ? def.exactLength.value : void 0,
2146
+ type: "array",
2147
+ inclusive: true,
2148
+ exact: true,
2149
+ message: def.exactLength.message
2150
+ });
2151
+ status.dirty();
2152
+ }
2153
+ }
2154
+ if (def.minLength !== null) {
2155
+ if (ctx.data.length < def.minLength.value) {
2156
+ addIssueToContext(ctx, {
2157
+ code: ZodIssueCode.too_small,
2158
+ minimum: def.minLength.value,
2159
+ type: "array",
2160
+ inclusive: true,
2161
+ exact: false,
2162
+ message: def.minLength.message
2163
+ });
2164
+ status.dirty();
2165
+ }
2166
+ }
2167
+ if (def.maxLength !== null) {
2168
+ if (ctx.data.length > def.maxLength.value) {
2169
+ addIssueToContext(ctx, {
2170
+ code: ZodIssueCode.too_big,
2171
+ maximum: def.maxLength.value,
2172
+ type: "array",
2173
+ inclusive: true,
2174
+ exact: false,
2175
+ message: def.maxLength.message
2176
+ });
2177
+ status.dirty();
2178
+ }
2179
+ }
2180
+ if (ctx.common.async) {
2181
+ return Promise.all([...ctx.data].map((item, i) => {
2182
+ return def.type._parseAsync(new ParseInputLazyPath(ctx, item, ctx.path, i));
2183
+ })).then((result2) => {
2184
+ return ParseStatus.mergeArray(status, result2);
2185
+ });
2186
+ }
2187
+ const result = [...ctx.data].map((item, i) => {
2188
+ return def.type._parseSync(new ParseInputLazyPath(ctx, item, ctx.path, i));
2189
+ });
2190
+ return ParseStatus.mergeArray(status, result);
2191
+ }
2192
+ get element() {
2193
+ return this._def.type;
2194
+ }
2195
+ min(minLength, message) {
2196
+ return new ZodArray({
2197
+ ...this._def,
2198
+ minLength: { value: minLength, message: errorUtil.toString(message) }
2199
+ });
2200
+ }
2201
+ max(maxLength, message) {
2202
+ return new ZodArray({
2203
+ ...this._def,
2204
+ maxLength: { value: maxLength, message: errorUtil.toString(message) }
2205
+ });
2206
+ }
2207
+ length(len, message) {
2208
+ return new ZodArray({
2209
+ ...this._def,
2210
+ exactLength: { value: len, message: errorUtil.toString(message) }
2211
+ });
2212
+ }
2213
+ nonempty(message) {
2214
+ return this.min(1, message);
2215
+ }
2216
+ }
2217
+ ZodArray.create = (schema, params) => {
2218
+ return new ZodArray({
2219
+ type: schema,
2220
+ minLength: null,
2221
+ maxLength: null,
2222
+ exactLength: null,
2223
+ typeName: ZodFirstPartyTypeKind.ZodArray,
2224
+ ...processCreateParams(params)
2225
+ });
2226
+ };
2227
+ function deepPartialify(schema) {
2228
+ if (schema instanceof ZodObject) {
2229
+ const newShape = {};
2230
+ for (const key in schema.shape) {
2231
+ const fieldSchema = schema.shape[key];
2232
+ newShape[key] = ZodOptional.create(deepPartialify(fieldSchema));
2233
+ }
2234
+ return new ZodObject({
2235
+ ...schema._def,
2236
+ shape: () => newShape
2237
+ });
2238
+ } else if (schema instanceof ZodArray) {
2239
+ return new ZodArray({
2240
+ ...schema._def,
2241
+ type: deepPartialify(schema.element)
2242
+ });
2243
+ } else if (schema instanceof ZodOptional) {
2244
+ return ZodOptional.create(deepPartialify(schema.unwrap()));
2245
+ } else if (schema instanceof ZodNullable) {
2246
+ return ZodNullable.create(deepPartialify(schema.unwrap()));
2247
+ } else if (schema instanceof ZodTuple) {
2248
+ return ZodTuple.create(schema.items.map((item) => deepPartialify(item)));
2249
+ } else {
2250
+ return schema;
2251
+ }
2252
+ }
2253
+ class ZodObject extends ZodType {
2254
+ constructor() {
2255
+ super(...arguments);
2256
+ this._cached = null;
2257
+ this.nonstrict = this.passthrough;
2258
+ this.augment = this.extend;
2259
+ }
2260
+ _getCached() {
2261
+ if (this._cached !== null)
2262
+ return this._cached;
2263
+ const shape = this._def.shape();
2264
+ const keys = util.objectKeys(shape);
2265
+ return this._cached = { shape, keys };
2266
+ }
2267
+ _parse(input) {
2268
+ const parsedType = this._getType(input);
2269
+ if (parsedType !== ZodParsedType.object) {
2270
+ const ctx2 = this._getOrReturnCtx(input);
2271
+ addIssueToContext(ctx2, {
2272
+ code: ZodIssueCode.invalid_type,
2273
+ expected: ZodParsedType.object,
2274
+ received: ctx2.parsedType
2275
+ });
2276
+ return INVALID;
2277
+ }
2278
+ const { status, ctx } = this._processInputParams(input);
2279
+ const { shape, keys: shapeKeys } = this._getCached();
2280
+ const extraKeys = [];
2281
+ if (!(this._def.catchall instanceof ZodNever && this._def.unknownKeys === "strip")) {
2282
+ for (const key in ctx.data) {
2283
+ if (!shapeKeys.includes(key)) {
2284
+ extraKeys.push(key);
2285
+ }
2286
+ }
2287
+ }
2288
+ const pairs = [];
2289
+ for (const key of shapeKeys) {
2290
+ const keyValidator = shape[key];
2291
+ const value = ctx.data[key];
2292
+ pairs.push({
2293
+ key: { status: "valid", value: key },
2294
+ value: keyValidator._parse(new ParseInputLazyPath(ctx, value, ctx.path, key)),
2295
+ alwaysSet: key in ctx.data
2296
+ });
2297
+ }
2298
+ if (this._def.catchall instanceof ZodNever) {
2299
+ const unknownKeys = this._def.unknownKeys;
2300
+ if (unknownKeys === "passthrough") {
2301
+ for (const key of extraKeys) {
2302
+ pairs.push({
2303
+ key: { status: "valid", value: key },
2304
+ value: { status: "valid", value: ctx.data[key] }
2305
+ });
2306
+ }
2307
+ } else if (unknownKeys === "strict") {
2308
+ if (extraKeys.length > 0) {
2309
+ addIssueToContext(ctx, {
2310
+ code: ZodIssueCode.unrecognized_keys,
2311
+ keys: extraKeys
2312
+ });
2313
+ status.dirty();
2314
+ }
2315
+ } else if (unknownKeys === "strip") ;
2316
+ else {
2317
+ throw new Error(`Internal ZodObject error: invalid unknownKeys value.`);
2318
+ }
2319
+ } else {
2320
+ const catchall = this._def.catchall;
2321
+ for (const key of extraKeys) {
2322
+ const value = ctx.data[key];
2323
+ pairs.push({
2324
+ key: { status: "valid", value: key },
2325
+ value: catchall._parse(
2326
+ new ParseInputLazyPath(ctx, value, ctx.path, key)
2327
+ //, ctx.child(key), value, getParsedType(value)
2328
+ ),
2329
+ alwaysSet: key in ctx.data
2330
+ });
2331
+ }
2332
+ }
2333
+ if (ctx.common.async) {
2334
+ return Promise.resolve().then(async () => {
2335
+ const syncPairs = [];
2336
+ for (const pair of pairs) {
2337
+ const key = await pair.key;
2338
+ const value = await pair.value;
2339
+ syncPairs.push({
2340
+ key,
2341
+ value,
2342
+ alwaysSet: pair.alwaysSet
2343
+ });
2344
+ }
2345
+ return syncPairs;
2346
+ }).then((syncPairs) => {
2347
+ return ParseStatus.mergeObjectSync(status, syncPairs);
2348
+ });
2349
+ } else {
2350
+ return ParseStatus.mergeObjectSync(status, pairs);
2351
+ }
2352
+ }
2353
+ get shape() {
2354
+ return this._def.shape();
2355
+ }
2356
+ strict(message) {
2357
+ errorUtil.errToObj;
2358
+ return new ZodObject({
2359
+ ...this._def,
2360
+ unknownKeys: "strict",
2361
+ ...message !== void 0 ? {
2362
+ errorMap: (issue, ctx) => {
2363
+ var _a, _b, _c, _d;
2364
+ 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;
2365
+ if (issue.code === "unrecognized_keys")
2366
+ return {
2367
+ message: (_d = errorUtil.errToObj(message).message) !== null && _d !== void 0 ? _d : defaultError
2368
+ };
2369
+ return {
2370
+ message: defaultError
2371
+ };
2372
+ }
2373
+ } : {}
2374
+ });
2375
+ }
2376
+ strip() {
2377
+ return new ZodObject({
2378
+ ...this._def,
2379
+ unknownKeys: "strip"
2380
+ });
2381
+ }
2382
+ passthrough() {
2383
+ return new ZodObject({
2384
+ ...this._def,
2385
+ unknownKeys: "passthrough"
2386
+ });
2387
+ }
2388
+ // const AugmentFactory =
2389
+ // <Def extends ZodObjectDef>(def: Def) =>
2390
+ // <Augmentation extends ZodRawShape>(
2391
+ // augmentation: Augmentation
2392
+ // ): ZodObject<
2393
+ // extendShape<ReturnType<Def["shape"]>, Augmentation>,
2394
+ // Def["unknownKeys"],
2395
+ // Def["catchall"]
2396
+ // > => {
2397
+ // return new ZodObject({
2398
+ // ...def,
2399
+ // shape: () => ({
2400
+ // ...def.shape(),
2401
+ // ...augmentation,
2402
+ // }),
2403
+ // }) as any;
2404
+ // };
2405
+ extend(augmentation) {
2406
+ return new ZodObject({
2407
+ ...this._def,
2408
+ shape: () => ({
2409
+ ...this._def.shape(),
2410
+ ...augmentation
2411
+ })
2412
+ });
2413
+ }
2414
+ /**
2415
+ * Prior to zod@1.0.12 there was a bug in the
2416
+ * inferred type of merged objects. Please
2417
+ * upgrade if you are experiencing issues.
2418
+ */
2419
+ merge(merging) {
2420
+ const merged = new ZodObject({
2421
+ unknownKeys: merging._def.unknownKeys,
2422
+ catchall: merging._def.catchall,
2423
+ shape: () => ({
2424
+ ...this._def.shape(),
2425
+ ...merging._def.shape()
2426
+ }),
2427
+ typeName: ZodFirstPartyTypeKind.ZodObject
2428
+ });
2429
+ return merged;
2430
+ }
2431
+ // merge<
2432
+ // Incoming extends AnyZodObject,
2433
+ // Augmentation extends Incoming["shape"],
2434
+ // NewOutput extends {
2435
+ // [k in keyof Augmentation | keyof Output]: k extends keyof Augmentation
2436
+ // ? Augmentation[k]["_output"]
2437
+ // : k extends keyof Output
2438
+ // ? Output[k]
2439
+ // : never;
2440
+ // },
2441
+ // NewInput extends {
2442
+ // [k in keyof Augmentation | keyof Input]: k extends keyof Augmentation
2443
+ // ? Augmentation[k]["_input"]
2444
+ // : k extends keyof Input
2445
+ // ? Input[k]
2446
+ // : never;
2447
+ // }
2448
+ // >(
2449
+ // merging: Incoming
2450
+ // ): ZodObject<
2451
+ // extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
2452
+ // Incoming["_def"]["unknownKeys"],
2453
+ // Incoming["_def"]["catchall"],
2454
+ // NewOutput,
2455
+ // NewInput
2456
+ // > {
2457
+ // const merged: any = new ZodObject({
2458
+ // unknownKeys: merging._def.unknownKeys,
2459
+ // catchall: merging._def.catchall,
2460
+ // shape: () =>
2461
+ // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
2462
+ // typeName: ZodFirstPartyTypeKind.ZodObject,
2463
+ // }) as any;
2464
+ // return merged;
2465
+ // }
2466
+ setKey(key, schema) {
2467
+ return this.augment({ [key]: schema });
2468
+ }
2469
+ // merge<Incoming extends AnyZodObject>(
2470
+ // merging: Incoming
2471
+ // ): //ZodObject<T & Incoming["_shape"], UnknownKeys, Catchall> = (merging) => {
2472
+ // ZodObject<
2473
+ // extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
2474
+ // Incoming["_def"]["unknownKeys"],
2475
+ // Incoming["_def"]["catchall"]
2476
+ // > {
2477
+ // // const mergedShape = objectUtil.mergeShapes(
2478
+ // // this._def.shape(),
2479
+ // // merging._def.shape()
2480
+ // // );
2481
+ // const merged: any = new ZodObject({
2482
+ // unknownKeys: merging._def.unknownKeys,
2483
+ // catchall: merging._def.catchall,
2484
+ // shape: () =>
2485
+ // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
2486
+ // typeName: ZodFirstPartyTypeKind.ZodObject,
2487
+ // }) as any;
2488
+ // return merged;
2489
+ // }
2490
+ catchall(index) {
2491
+ return new ZodObject({
2492
+ ...this._def,
2493
+ catchall: index
2494
+ });
2495
+ }
2496
+ pick(mask) {
2497
+ const shape = {};
2498
+ util.objectKeys(mask).forEach((key) => {
2499
+ if (mask[key] && this.shape[key]) {
2500
+ shape[key] = this.shape[key];
2501
+ }
2502
+ });
2503
+ return new ZodObject({
2504
+ ...this._def,
2505
+ shape: () => shape
2506
+ });
2507
+ }
2508
+ omit(mask) {
2509
+ const shape = {};
2510
+ util.objectKeys(this.shape).forEach((key) => {
2511
+ if (!mask[key]) {
2512
+ shape[key] = this.shape[key];
2513
+ }
2514
+ });
2515
+ return new ZodObject({
2516
+ ...this._def,
2517
+ shape: () => shape
2518
+ });
2519
+ }
2520
+ /**
2521
+ * @deprecated
2522
+ */
2523
+ deepPartial() {
2524
+ return deepPartialify(this);
2525
+ }
2526
+ partial(mask) {
2527
+ const newShape = {};
2528
+ util.objectKeys(this.shape).forEach((key) => {
2529
+ const fieldSchema = this.shape[key];
2530
+ if (mask && !mask[key]) {
2531
+ newShape[key] = fieldSchema;
2532
+ } else {
2533
+ newShape[key] = fieldSchema.optional();
2534
+ }
2535
+ });
2536
+ return new ZodObject({
2537
+ ...this._def,
2538
+ shape: () => newShape
2539
+ });
2540
+ }
2541
+ required(mask) {
2542
+ const newShape = {};
2543
+ util.objectKeys(this.shape).forEach((key) => {
2544
+ if (mask && !mask[key]) {
2545
+ newShape[key] = this.shape[key];
2546
+ } else {
2547
+ const fieldSchema = this.shape[key];
2548
+ let newField = fieldSchema;
2549
+ while (newField instanceof ZodOptional) {
2550
+ newField = newField._def.innerType;
2551
+ }
2552
+ newShape[key] = newField;
2553
+ }
2554
+ });
2555
+ return new ZodObject({
2556
+ ...this._def,
2557
+ shape: () => newShape
2558
+ });
2559
+ }
2560
+ keyof() {
2561
+ return createZodEnum(util.objectKeys(this.shape));
2562
+ }
2563
+ }
2564
+ ZodObject.create = (shape, params) => {
2565
+ return new ZodObject({
2566
+ shape: () => shape,
2567
+ unknownKeys: "strip",
2568
+ catchall: ZodNever.create(),
2569
+ typeName: ZodFirstPartyTypeKind.ZodObject,
2570
+ ...processCreateParams(params)
2571
+ });
2572
+ };
2573
+ ZodObject.strictCreate = (shape, params) => {
2574
+ return new ZodObject({
2575
+ shape: () => shape,
2576
+ unknownKeys: "strict",
2577
+ catchall: ZodNever.create(),
2578
+ typeName: ZodFirstPartyTypeKind.ZodObject,
2579
+ ...processCreateParams(params)
2580
+ });
2581
+ };
2582
+ ZodObject.lazycreate = (shape, params) => {
2583
+ return new ZodObject({
2584
+ shape,
2585
+ unknownKeys: "strip",
2586
+ catchall: ZodNever.create(),
2587
+ typeName: ZodFirstPartyTypeKind.ZodObject,
2588
+ ...processCreateParams(params)
2589
+ });
2590
+ };
2591
+ class ZodUnion extends ZodType {
2592
+ _parse(input) {
2593
+ const { ctx } = this._processInputParams(input);
2594
+ const options = this._def.options;
2595
+ function handleResults(results) {
2596
+ for (const result of results) {
2597
+ if (result.result.status === "valid") {
2598
+ return result.result;
2599
+ }
2600
+ }
2601
+ for (const result of results) {
2602
+ if (result.result.status === "dirty") {
2603
+ ctx.common.issues.push(...result.ctx.common.issues);
2604
+ return result.result;
2605
+ }
2606
+ }
2607
+ const unionErrors = results.map((result) => new ZodError(result.ctx.common.issues));
2608
+ addIssueToContext(ctx, {
2609
+ code: ZodIssueCode.invalid_union,
2610
+ unionErrors
2611
+ });
2612
+ return INVALID;
2613
+ }
2614
+ if (ctx.common.async) {
2615
+ return Promise.all(options.map(async (option) => {
2616
+ const childCtx = {
2617
+ ...ctx,
2618
+ common: {
2619
+ ...ctx.common,
2620
+ issues: []
2621
+ },
2622
+ parent: null
2623
+ };
2624
+ return {
2625
+ result: await option._parseAsync({
2626
+ data: ctx.data,
2627
+ path: ctx.path,
2628
+ parent: childCtx
2629
+ }),
2630
+ ctx: childCtx
2631
+ };
2632
+ })).then(handleResults);
2633
+ } else {
2634
+ let dirty = void 0;
2635
+ const issues = [];
2636
+ for (const option of options) {
2637
+ const childCtx = {
2638
+ ...ctx,
2639
+ common: {
2640
+ ...ctx.common,
2641
+ issues: []
2642
+ },
2643
+ parent: null
2644
+ };
2645
+ const result = option._parseSync({
2646
+ data: ctx.data,
2647
+ path: ctx.path,
2648
+ parent: childCtx
2649
+ });
2650
+ if (result.status === "valid") {
2651
+ return result;
2652
+ } else if (result.status === "dirty" && !dirty) {
2653
+ dirty = { result, ctx: childCtx };
2654
+ }
2655
+ if (childCtx.common.issues.length) {
2656
+ issues.push(childCtx.common.issues);
2657
+ }
2658
+ }
2659
+ if (dirty) {
2660
+ ctx.common.issues.push(...dirty.ctx.common.issues);
2661
+ return dirty.result;
2662
+ }
2663
+ const unionErrors = issues.map((issues2) => new ZodError(issues2));
2664
+ addIssueToContext(ctx, {
2665
+ code: ZodIssueCode.invalid_union,
2666
+ unionErrors
2667
+ });
2668
+ return INVALID;
2669
+ }
2670
+ }
2671
+ get options() {
2672
+ return this._def.options;
2673
+ }
2674
+ }
2675
+ ZodUnion.create = (types, params) => {
2676
+ return new ZodUnion({
2677
+ options: types,
2678
+ typeName: ZodFirstPartyTypeKind.ZodUnion,
2679
+ ...processCreateParams(params)
2680
+ });
2681
+ };
2682
+ const getDiscriminator = (type) => {
2683
+ if (type instanceof ZodLazy) {
2684
+ return getDiscriminator(type.schema);
2685
+ } else if (type instanceof ZodEffects) {
2686
+ return getDiscriminator(type.innerType());
2687
+ } else if (type instanceof ZodLiteral) {
2688
+ return [type.value];
2689
+ } else if (type instanceof ZodEnum) {
2690
+ return type.options;
2691
+ } else if (type instanceof ZodNativeEnum) {
2692
+ return util.objectValues(type.enum);
2693
+ } else if (type instanceof ZodDefault) {
2694
+ return getDiscriminator(type._def.innerType);
2695
+ } else if (type instanceof ZodUndefined) {
2696
+ return [void 0];
2697
+ } else if (type instanceof ZodNull) {
2698
+ return [null];
2699
+ } else if (type instanceof ZodOptional) {
2700
+ return [void 0, ...getDiscriminator(type.unwrap())];
2701
+ } else if (type instanceof ZodNullable) {
2702
+ return [null, ...getDiscriminator(type.unwrap())];
2703
+ } else if (type instanceof ZodBranded) {
2704
+ return getDiscriminator(type.unwrap());
2705
+ } else if (type instanceof ZodReadonly) {
2706
+ return getDiscriminator(type.unwrap());
2707
+ } else if (type instanceof ZodCatch) {
2708
+ return getDiscriminator(type._def.innerType);
2709
+ } else {
2710
+ return [];
2711
+ }
2712
+ };
2713
+ class ZodDiscriminatedUnion extends ZodType {
2714
+ _parse(input) {
2715
+ const { ctx } = this._processInputParams(input);
2716
+ if (ctx.parsedType !== ZodParsedType.object) {
2717
+ addIssueToContext(ctx, {
2718
+ code: ZodIssueCode.invalid_type,
2719
+ expected: ZodParsedType.object,
2720
+ received: ctx.parsedType
2721
+ });
2722
+ return INVALID;
2723
+ }
2724
+ const discriminator = this.discriminator;
2725
+ const discriminatorValue = ctx.data[discriminator];
2726
+ const option = this.optionsMap.get(discriminatorValue);
2727
+ if (!option) {
2728
+ addIssueToContext(ctx, {
2729
+ code: ZodIssueCode.invalid_union_discriminator,
2730
+ options: Array.from(this.optionsMap.keys()),
2731
+ path: [discriminator]
2732
+ });
2733
+ return INVALID;
2734
+ }
2735
+ if (ctx.common.async) {
2736
+ return option._parseAsync({
2737
+ data: ctx.data,
2738
+ path: ctx.path,
2739
+ parent: ctx
2740
+ });
2741
+ } else {
2742
+ return option._parseSync({
2743
+ data: ctx.data,
2744
+ path: ctx.path,
2745
+ parent: ctx
2746
+ });
2747
+ }
2748
+ }
2749
+ get discriminator() {
2750
+ return this._def.discriminator;
2751
+ }
2752
+ get options() {
2753
+ return this._def.options;
2754
+ }
2755
+ get optionsMap() {
2756
+ return this._def.optionsMap;
2757
+ }
2758
+ /**
2759
+ * The constructor of the discriminated union schema. Its behaviour is very similar to that of the normal z.union() constructor.
2760
+ * However, it only allows a union of objects, all of which need to share a discriminator property. This property must
2761
+ * have a different value for each object in the union.
2762
+ * @param discriminator the name of the discriminator property
2763
+ * @param types an array of object schemas
2764
+ * @param params
2765
+ */
2766
+ static create(discriminator, options, params) {
2767
+ const optionsMap = /* @__PURE__ */ new Map();
2768
+ for (const type of options) {
2769
+ const discriminatorValues = getDiscriminator(type.shape[discriminator]);
2770
+ if (!discriminatorValues.length) {
2771
+ throw new Error(`A discriminator value for key \`${discriminator}\` could not be extracted from all schema options`);
2772
+ }
2773
+ for (const value of discriminatorValues) {
2774
+ if (optionsMap.has(value)) {
2775
+ throw new Error(`Discriminator property ${String(discriminator)} has duplicate value ${String(value)}`);
2776
+ }
2777
+ optionsMap.set(value, type);
2778
+ }
2779
+ }
2780
+ return new ZodDiscriminatedUnion({
2781
+ typeName: ZodFirstPartyTypeKind.ZodDiscriminatedUnion,
2782
+ discriminator,
2783
+ options,
2784
+ optionsMap,
2785
+ ...processCreateParams(params)
2786
+ });
2787
+ }
2788
+ }
2789
+ function mergeValues(a, b) {
2790
+ const aType = getParsedType(a);
2791
+ const bType = getParsedType(b);
2792
+ if (a === b) {
2793
+ return { valid: true, data: a };
2794
+ } else if (aType === ZodParsedType.object && bType === ZodParsedType.object) {
2795
+ const bKeys = util.objectKeys(b);
2796
+ const sharedKeys = util.objectKeys(a).filter((key) => bKeys.indexOf(key) !== -1);
2797
+ const newObj = { ...a, ...b };
2798
+ for (const key of sharedKeys) {
2799
+ const sharedValue = mergeValues(a[key], b[key]);
2800
+ if (!sharedValue.valid) {
2801
+ return { valid: false };
2802
+ }
2803
+ newObj[key] = sharedValue.data;
2804
+ }
2805
+ return { valid: true, data: newObj };
2806
+ } else if (aType === ZodParsedType.array && bType === ZodParsedType.array) {
2807
+ if (a.length !== b.length) {
2808
+ return { valid: false };
2809
+ }
2810
+ const newArray = [];
2811
+ for (let index = 0; index < a.length; index++) {
2812
+ const itemA = a[index];
2813
+ const itemB = b[index];
2814
+ const sharedValue = mergeValues(itemA, itemB);
2815
+ if (!sharedValue.valid) {
2816
+ return { valid: false };
2817
+ }
2818
+ newArray.push(sharedValue.data);
2819
+ }
2820
+ return { valid: true, data: newArray };
2821
+ } else if (aType === ZodParsedType.date && bType === ZodParsedType.date && +a === +b) {
2822
+ return { valid: true, data: a };
2823
+ } else {
2824
+ return { valid: false };
2825
+ }
2826
+ }
2827
+ class ZodIntersection extends ZodType {
2828
+ _parse(input) {
2829
+ const { status, ctx } = this._processInputParams(input);
2830
+ const handleParsed = (parsedLeft, parsedRight) => {
2831
+ if (isAborted(parsedLeft) || isAborted(parsedRight)) {
2832
+ return INVALID;
2833
+ }
2834
+ const merged = mergeValues(parsedLeft.value, parsedRight.value);
2835
+ if (!merged.valid) {
2836
+ addIssueToContext(ctx, {
2837
+ code: ZodIssueCode.invalid_intersection_types
2838
+ });
2839
+ return INVALID;
2840
+ }
2841
+ if (isDirty(parsedLeft) || isDirty(parsedRight)) {
2842
+ status.dirty();
2843
+ }
2844
+ return { status: status.value, value: merged.data };
2845
+ };
2846
+ if (ctx.common.async) {
2847
+ return Promise.all([
2848
+ this._def.left._parseAsync({
2849
+ data: ctx.data,
2850
+ path: ctx.path,
2851
+ parent: ctx
2852
+ }),
2853
+ this._def.right._parseAsync({
2854
+ data: ctx.data,
2855
+ path: ctx.path,
2856
+ parent: ctx
2857
+ })
2858
+ ]).then(([left, right]) => handleParsed(left, right));
2859
+ } else {
2860
+ return handleParsed(this._def.left._parseSync({
2861
+ data: ctx.data,
2862
+ path: ctx.path,
2863
+ parent: ctx
2864
+ }), this._def.right._parseSync({
2865
+ data: ctx.data,
2866
+ path: ctx.path,
2867
+ parent: ctx
2868
+ }));
2869
+ }
2870
+ }
2871
+ }
2872
+ ZodIntersection.create = (left, right, params) => {
2873
+ return new ZodIntersection({
2874
+ left,
2875
+ right,
2876
+ typeName: ZodFirstPartyTypeKind.ZodIntersection,
2877
+ ...processCreateParams(params)
2878
+ });
2879
+ };
2880
+ class ZodTuple extends ZodType {
2881
+ _parse(input) {
2882
+ const { status, ctx } = this._processInputParams(input);
2883
+ if (ctx.parsedType !== ZodParsedType.array) {
2884
+ addIssueToContext(ctx, {
2885
+ code: ZodIssueCode.invalid_type,
2886
+ expected: ZodParsedType.array,
2887
+ received: ctx.parsedType
2888
+ });
2889
+ return INVALID;
2890
+ }
2891
+ if (ctx.data.length < this._def.items.length) {
2892
+ addIssueToContext(ctx, {
2893
+ code: ZodIssueCode.too_small,
2894
+ minimum: this._def.items.length,
2895
+ inclusive: true,
2896
+ exact: false,
2897
+ type: "array"
2898
+ });
2899
+ return INVALID;
2900
+ }
2901
+ const rest = this._def.rest;
2902
+ if (!rest && ctx.data.length > this._def.items.length) {
2903
+ addIssueToContext(ctx, {
2904
+ code: ZodIssueCode.too_big,
2905
+ maximum: this._def.items.length,
2906
+ inclusive: true,
2907
+ exact: false,
2908
+ type: "array"
2909
+ });
2910
+ status.dirty();
2911
+ }
2912
+ const items = [...ctx.data].map((item, itemIndex) => {
2913
+ const schema = this._def.items[itemIndex] || this._def.rest;
2914
+ if (!schema)
2915
+ return null;
2916
+ return schema._parse(new ParseInputLazyPath(ctx, item, ctx.path, itemIndex));
2917
+ }).filter((x) => !!x);
2918
+ if (ctx.common.async) {
2919
+ return Promise.all(items).then((results) => {
2920
+ return ParseStatus.mergeArray(status, results);
2921
+ });
2922
+ } else {
2923
+ return ParseStatus.mergeArray(status, items);
2924
+ }
2925
+ }
2926
+ get items() {
2927
+ return this._def.items;
2928
+ }
2929
+ rest(rest) {
2930
+ return new ZodTuple({
2931
+ ...this._def,
2932
+ rest
2933
+ });
2934
+ }
2935
+ }
2936
+ ZodTuple.create = (schemas, params) => {
2937
+ if (!Array.isArray(schemas)) {
2938
+ throw new Error("You must pass an array of schemas to z.tuple([ ... ])");
2939
+ }
2940
+ return new ZodTuple({
2941
+ items: schemas,
2942
+ typeName: ZodFirstPartyTypeKind.ZodTuple,
2943
+ rest: null,
2944
+ ...processCreateParams(params)
2945
+ });
2946
+ };
2947
+ class ZodRecord extends ZodType {
2948
+ get keySchema() {
2949
+ return this._def.keyType;
2950
+ }
2951
+ get valueSchema() {
2952
+ return this._def.valueType;
2953
+ }
2954
+ _parse(input) {
2955
+ const { status, ctx } = this._processInputParams(input);
2956
+ if (ctx.parsedType !== ZodParsedType.object) {
2957
+ addIssueToContext(ctx, {
2958
+ code: ZodIssueCode.invalid_type,
2959
+ expected: ZodParsedType.object,
2960
+ received: ctx.parsedType
2961
+ });
2962
+ return INVALID;
2963
+ }
2964
+ const pairs = [];
2965
+ const keyType = this._def.keyType;
2966
+ const valueType = this._def.valueType;
2967
+ for (const key in ctx.data) {
2968
+ pairs.push({
2969
+ key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, key)),
2970
+ value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[key], ctx.path, key)),
2971
+ alwaysSet: key in ctx.data
2972
+ });
2973
+ }
2974
+ if (ctx.common.async) {
2975
+ return ParseStatus.mergeObjectAsync(status, pairs);
2976
+ } else {
2977
+ return ParseStatus.mergeObjectSync(status, pairs);
2978
+ }
2979
+ }
2980
+ get element() {
2981
+ return this._def.valueType;
2982
+ }
2983
+ static create(first, second, third) {
2984
+ if (second instanceof ZodType) {
2985
+ return new ZodRecord({
2986
+ keyType: first,
2987
+ valueType: second,
2988
+ typeName: ZodFirstPartyTypeKind.ZodRecord,
2989
+ ...processCreateParams(third)
2990
+ });
2991
+ }
2992
+ return new ZodRecord({
2993
+ keyType: ZodString.create(),
2994
+ valueType: first,
2995
+ typeName: ZodFirstPartyTypeKind.ZodRecord,
2996
+ ...processCreateParams(second)
2997
+ });
2998
+ }
2999
+ }
3000
+ class ZodMap extends ZodType {
3001
+ get keySchema() {
3002
+ return this._def.keyType;
3003
+ }
3004
+ get valueSchema() {
3005
+ return this._def.valueType;
3006
+ }
3007
+ _parse(input) {
3008
+ const { status, ctx } = this._processInputParams(input);
3009
+ if (ctx.parsedType !== ZodParsedType.map) {
3010
+ addIssueToContext(ctx, {
3011
+ code: ZodIssueCode.invalid_type,
3012
+ expected: ZodParsedType.map,
3013
+ received: ctx.parsedType
3014
+ });
3015
+ return INVALID;
3016
+ }
3017
+ const keyType = this._def.keyType;
3018
+ const valueType = this._def.valueType;
3019
+ const pairs = [...ctx.data.entries()].map(([key, value], index) => {
3020
+ return {
3021
+ key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, [index, "key"])),
3022
+ value: valueType._parse(new ParseInputLazyPath(ctx, value, ctx.path, [index, "value"]))
3023
+ };
3024
+ });
3025
+ if (ctx.common.async) {
3026
+ const finalMap = /* @__PURE__ */ new Map();
3027
+ return Promise.resolve().then(async () => {
3028
+ for (const pair of pairs) {
3029
+ const key = await pair.key;
3030
+ const value = await pair.value;
3031
+ if (key.status === "aborted" || value.status === "aborted") {
3032
+ return INVALID;
3033
+ }
3034
+ if (key.status === "dirty" || value.status === "dirty") {
3035
+ status.dirty();
3036
+ }
3037
+ finalMap.set(key.value, value.value);
3038
+ }
3039
+ return { status: status.value, value: finalMap };
3040
+ });
3041
+ } else {
3042
+ const finalMap = /* @__PURE__ */ new Map();
3043
+ for (const pair of pairs) {
3044
+ const key = pair.key;
3045
+ const value = pair.value;
3046
+ if (key.status === "aborted" || value.status === "aborted") {
3047
+ return INVALID;
3048
+ }
3049
+ if (key.status === "dirty" || value.status === "dirty") {
3050
+ status.dirty();
3051
+ }
3052
+ finalMap.set(key.value, value.value);
3053
+ }
3054
+ return { status: status.value, value: finalMap };
3055
+ }
3056
+ }
3057
+ }
3058
+ ZodMap.create = (keyType, valueType, params) => {
3059
+ return new ZodMap({
3060
+ valueType,
3061
+ keyType,
3062
+ typeName: ZodFirstPartyTypeKind.ZodMap,
3063
+ ...processCreateParams(params)
3064
+ });
3065
+ };
3066
+ class ZodSet extends ZodType {
3067
+ _parse(input) {
3068
+ const { status, ctx } = this._processInputParams(input);
3069
+ if (ctx.parsedType !== ZodParsedType.set) {
3070
+ addIssueToContext(ctx, {
3071
+ code: ZodIssueCode.invalid_type,
3072
+ expected: ZodParsedType.set,
3073
+ received: ctx.parsedType
3074
+ });
3075
+ return INVALID;
3076
+ }
3077
+ const def = this._def;
3078
+ if (def.minSize !== null) {
3079
+ if (ctx.data.size < def.minSize.value) {
3080
+ addIssueToContext(ctx, {
3081
+ code: ZodIssueCode.too_small,
3082
+ minimum: def.minSize.value,
3083
+ type: "set",
3084
+ inclusive: true,
3085
+ exact: false,
3086
+ message: def.minSize.message
3087
+ });
3088
+ status.dirty();
3089
+ }
3090
+ }
3091
+ if (def.maxSize !== null) {
3092
+ if (ctx.data.size > def.maxSize.value) {
3093
+ addIssueToContext(ctx, {
3094
+ code: ZodIssueCode.too_big,
3095
+ maximum: def.maxSize.value,
3096
+ type: "set",
3097
+ inclusive: true,
3098
+ exact: false,
3099
+ message: def.maxSize.message
3100
+ });
3101
+ status.dirty();
3102
+ }
3103
+ }
3104
+ const valueType = this._def.valueType;
3105
+ function finalizeSet(elements2) {
3106
+ const parsedSet = /* @__PURE__ */ new Set();
3107
+ for (const element of elements2) {
3108
+ if (element.status === "aborted")
3109
+ return INVALID;
3110
+ if (element.status === "dirty")
3111
+ status.dirty();
3112
+ parsedSet.add(element.value);
3113
+ }
3114
+ return { status: status.value, value: parsedSet };
3115
+ }
3116
+ const elements = [...ctx.data.values()].map((item, i) => valueType._parse(new ParseInputLazyPath(ctx, item, ctx.path, i)));
3117
+ if (ctx.common.async) {
3118
+ return Promise.all(elements).then((elements2) => finalizeSet(elements2));
3119
+ } else {
3120
+ return finalizeSet(elements);
3121
+ }
3122
+ }
3123
+ min(minSize, message) {
3124
+ return new ZodSet({
3125
+ ...this._def,
3126
+ minSize: { value: minSize, message: errorUtil.toString(message) }
3127
+ });
3128
+ }
3129
+ max(maxSize, message) {
3130
+ return new ZodSet({
3131
+ ...this._def,
3132
+ maxSize: { value: maxSize, message: errorUtil.toString(message) }
3133
+ });
3134
+ }
3135
+ size(size, message) {
3136
+ return this.min(size, message).max(size, message);
3137
+ }
3138
+ nonempty(message) {
3139
+ return this.min(1, message);
3140
+ }
3141
+ }
3142
+ ZodSet.create = (valueType, params) => {
3143
+ return new ZodSet({
3144
+ valueType,
3145
+ minSize: null,
3146
+ maxSize: null,
3147
+ typeName: ZodFirstPartyTypeKind.ZodSet,
3148
+ ...processCreateParams(params)
3149
+ });
3150
+ };
3151
+ class ZodFunction extends ZodType {
3152
+ constructor() {
3153
+ super(...arguments);
3154
+ this.validate = this.implement;
3155
+ }
3156
+ _parse(input) {
3157
+ const { ctx } = this._processInputParams(input);
3158
+ if (ctx.parsedType !== ZodParsedType.function) {
3159
+ addIssueToContext(ctx, {
3160
+ code: ZodIssueCode.invalid_type,
3161
+ expected: ZodParsedType.function,
3162
+ received: ctx.parsedType
3163
+ });
3164
+ return INVALID;
3165
+ }
3166
+ function makeArgsIssue(args, error) {
3167
+ return makeIssue({
3168
+ data: args,
3169
+ path: ctx.path,
3170
+ errorMaps: [
3171
+ ctx.common.contextualErrorMap,
3172
+ ctx.schemaErrorMap,
3173
+ getErrorMap(),
3174
+ errorMap
3175
+ ].filter((x) => !!x),
3176
+ issueData: {
3177
+ code: ZodIssueCode.invalid_arguments,
3178
+ argumentsError: error
3179
+ }
3180
+ });
3181
+ }
3182
+ function makeReturnsIssue(returns, error) {
3183
+ return makeIssue({
3184
+ data: returns,
3185
+ path: ctx.path,
3186
+ errorMaps: [
3187
+ ctx.common.contextualErrorMap,
3188
+ ctx.schemaErrorMap,
3189
+ getErrorMap(),
3190
+ errorMap
3191
+ ].filter((x) => !!x),
3192
+ issueData: {
3193
+ code: ZodIssueCode.invalid_return_type,
3194
+ returnTypeError: error
3195
+ }
3196
+ });
3197
+ }
3198
+ const params = { errorMap: ctx.common.contextualErrorMap };
3199
+ const fn = ctx.data;
3200
+ if (this._def.returns instanceof ZodPromise) {
3201
+ const me = this;
3202
+ return OK(async function(...args) {
3203
+ const error = new ZodError([]);
3204
+ const parsedArgs = await me._def.args.parseAsync(args, params).catch((e) => {
3205
+ error.addIssue(makeArgsIssue(args, e));
3206
+ throw error;
3207
+ });
3208
+ const result = await Reflect.apply(fn, this, parsedArgs);
3209
+ const parsedReturns = await me._def.returns._def.type.parseAsync(result, params).catch((e) => {
3210
+ error.addIssue(makeReturnsIssue(result, e));
3211
+ throw error;
3212
+ });
3213
+ return parsedReturns;
3214
+ });
3215
+ } else {
3216
+ const me = this;
3217
+ return OK(function(...args) {
3218
+ const parsedArgs = me._def.args.safeParse(args, params);
3219
+ if (!parsedArgs.success) {
3220
+ throw new ZodError([makeArgsIssue(args, parsedArgs.error)]);
3221
+ }
3222
+ const result = Reflect.apply(fn, this, parsedArgs.data);
3223
+ const parsedReturns = me._def.returns.safeParse(result, params);
3224
+ if (!parsedReturns.success) {
3225
+ throw new ZodError([makeReturnsIssue(result, parsedReturns.error)]);
3226
+ }
3227
+ return parsedReturns.data;
3228
+ });
3229
+ }
3230
+ }
3231
+ parameters() {
3232
+ return this._def.args;
3233
+ }
3234
+ returnType() {
3235
+ return this._def.returns;
3236
+ }
3237
+ args(...items) {
3238
+ return new ZodFunction({
3239
+ ...this._def,
3240
+ args: ZodTuple.create(items).rest(ZodUnknown.create())
3241
+ });
3242
+ }
3243
+ returns(returnType) {
3244
+ return new ZodFunction({
3245
+ ...this._def,
3246
+ returns: returnType
3247
+ });
3248
+ }
3249
+ implement(func) {
3250
+ const validatedFunc = this.parse(func);
3251
+ return validatedFunc;
3252
+ }
3253
+ strictImplement(func) {
3254
+ const validatedFunc = this.parse(func);
3255
+ return validatedFunc;
3256
+ }
3257
+ static create(args, returns, params) {
3258
+ return new ZodFunction({
3259
+ args: args ? args : ZodTuple.create([]).rest(ZodUnknown.create()),
3260
+ returns: returns || ZodUnknown.create(),
3261
+ typeName: ZodFirstPartyTypeKind.ZodFunction,
3262
+ ...processCreateParams(params)
3263
+ });
3264
+ }
3265
+ }
3266
+ class ZodLazy extends ZodType {
3267
+ get schema() {
3268
+ return this._def.getter();
3269
+ }
3270
+ _parse(input) {
3271
+ const { ctx } = this._processInputParams(input);
3272
+ const lazySchema = this._def.getter();
3273
+ return lazySchema._parse({ data: ctx.data, path: ctx.path, parent: ctx });
3274
+ }
3275
+ }
3276
+ ZodLazy.create = (getter, params) => {
3277
+ return new ZodLazy({
3278
+ getter,
3279
+ typeName: ZodFirstPartyTypeKind.ZodLazy,
3280
+ ...processCreateParams(params)
3281
+ });
3282
+ };
3283
+ class ZodLiteral extends ZodType {
3284
+ _parse(input) {
3285
+ if (input.data !== this._def.value) {
3286
+ const ctx = this._getOrReturnCtx(input);
3287
+ addIssueToContext(ctx, {
3288
+ received: ctx.data,
3289
+ code: ZodIssueCode.invalid_literal,
3290
+ expected: this._def.value
3291
+ });
3292
+ return INVALID;
3293
+ }
3294
+ return { status: "valid", value: input.data };
3295
+ }
3296
+ get value() {
3297
+ return this._def.value;
3298
+ }
3299
+ }
3300
+ ZodLiteral.create = (value, params) => {
3301
+ return new ZodLiteral({
3302
+ value,
3303
+ typeName: ZodFirstPartyTypeKind.ZodLiteral,
3304
+ ...processCreateParams(params)
3305
+ });
3306
+ };
3307
+ function createZodEnum(values, params) {
3308
+ return new ZodEnum({
3309
+ values,
3310
+ typeName: ZodFirstPartyTypeKind.ZodEnum,
3311
+ ...processCreateParams(params)
3312
+ });
3313
+ }
3314
+ class ZodEnum extends ZodType {
3315
+ constructor() {
3316
+ super(...arguments);
3317
+ _ZodEnum_cache.set(this, void 0);
3318
+ }
3319
+ _parse(input) {
3320
+ if (typeof input.data !== "string") {
3321
+ const ctx = this._getOrReturnCtx(input);
3322
+ const expectedValues = this._def.values;
3323
+ addIssueToContext(ctx, {
3324
+ expected: util.joinValues(expectedValues),
3325
+ received: ctx.parsedType,
3326
+ code: ZodIssueCode.invalid_type
3327
+ });
3328
+ return INVALID;
3329
+ }
3330
+ if (!__classPrivateFieldGet(this, _ZodEnum_cache)) {
3331
+ __classPrivateFieldSet(this, _ZodEnum_cache, new Set(this._def.values));
3332
+ }
3333
+ if (!__classPrivateFieldGet(this, _ZodEnum_cache).has(input.data)) {
3334
+ const ctx = this._getOrReturnCtx(input);
3335
+ const expectedValues = this._def.values;
3336
+ addIssueToContext(ctx, {
3337
+ received: ctx.data,
3338
+ code: ZodIssueCode.invalid_enum_value,
3339
+ options: expectedValues
3340
+ });
3341
+ return INVALID;
3342
+ }
3343
+ return OK(input.data);
3344
+ }
3345
+ get options() {
3346
+ return this._def.values;
3347
+ }
3348
+ get enum() {
3349
+ const enumValues = {};
3350
+ for (const val of this._def.values) {
3351
+ enumValues[val] = val;
3352
+ }
3353
+ return enumValues;
3354
+ }
3355
+ get Values() {
3356
+ const enumValues = {};
3357
+ for (const val of this._def.values) {
3358
+ enumValues[val] = val;
3359
+ }
3360
+ return enumValues;
3361
+ }
3362
+ get Enum() {
3363
+ const enumValues = {};
3364
+ for (const val of this._def.values) {
3365
+ enumValues[val] = val;
3366
+ }
3367
+ return enumValues;
3368
+ }
3369
+ extract(values, newDef = this._def) {
3370
+ return ZodEnum.create(values, {
3371
+ ...this._def,
3372
+ ...newDef
3373
+ });
3374
+ }
3375
+ exclude(values, newDef = this._def) {
3376
+ return ZodEnum.create(this.options.filter((opt) => !values.includes(opt)), {
3377
+ ...this._def,
3378
+ ...newDef
3379
+ });
3380
+ }
3381
+ }
3382
+ _ZodEnum_cache = /* @__PURE__ */ new WeakMap();
3383
+ ZodEnum.create = createZodEnum;
3384
+ class ZodNativeEnum extends ZodType {
3385
+ constructor() {
3386
+ super(...arguments);
3387
+ _ZodNativeEnum_cache.set(this, void 0);
3388
+ }
3389
+ _parse(input) {
3390
+ const nativeEnumValues = util.getValidEnumValues(this._def.values);
3391
+ const ctx = this._getOrReturnCtx(input);
3392
+ if (ctx.parsedType !== ZodParsedType.string && ctx.parsedType !== ZodParsedType.number) {
3393
+ const expectedValues = util.objectValues(nativeEnumValues);
3394
+ addIssueToContext(ctx, {
3395
+ expected: util.joinValues(expectedValues),
3396
+ received: ctx.parsedType,
3397
+ code: ZodIssueCode.invalid_type
3398
+ });
3399
+ return INVALID;
3400
+ }
3401
+ if (!__classPrivateFieldGet(this, _ZodNativeEnum_cache)) {
3402
+ __classPrivateFieldSet(this, _ZodNativeEnum_cache, new Set(util.getValidEnumValues(this._def.values)));
3403
+ }
3404
+ if (!__classPrivateFieldGet(this, _ZodNativeEnum_cache).has(input.data)) {
3405
+ const expectedValues = util.objectValues(nativeEnumValues);
3406
+ addIssueToContext(ctx, {
3407
+ received: ctx.data,
3408
+ code: ZodIssueCode.invalid_enum_value,
3409
+ options: expectedValues
3410
+ });
3411
+ return INVALID;
3412
+ }
3413
+ return OK(input.data);
3414
+ }
3415
+ get enum() {
3416
+ return this._def.values;
3417
+ }
3418
+ }
3419
+ _ZodNativeEnum_cache = /* @__PURE__ */ new WeakMap();
3420
+ ZodNativeEnum.create = (values, params) => {
3421
+ return new ZodNativeEnum({
3422
+ values,
3423
+ typeName: ZodFirstPartyTypeKind.ZodNativeEnum,
3424
+ ...processCreateParams(params)
3425
+ });
3426
+ };
3427
+ class ZodPromise extends ZodType {
3428
+ unwrap() {
3429
+ return this._def.type;
3430
+ }
3431
+ _parse(input) {
3432
+ const { ctx } = this._processInputParams(input);
3433
+ if (ctx.parsedType !== ZodParsedType.promise && ctx.common.async === false) {
3434
+ addIssueToContext(ctx, {
3435
+ code: ZodIssueCode.invalid_type,
3436
+ expected: ZodParsedType.promise,
3437
+ received: ctx.parsedType
3438
+ });
3439
+ return INVALID;
3440
+ }
3441
+ const promisified = ctx.parsedType === ZodParsedType.promise ? ctx.data : Promise.resolve(ctx.data);
3442
+ return OK(promisified.then((data) => {
3443
+ return this._def.type.parseAsync(data, {
3444
+ path: ctx.path,
3445
+ errorMap: ctx.common.contextualErrorMap
3446
+ });
3447
+ }));
3448
+ }
3449
+ }
3450
+ ZodPromise.create = (schema, params) => {
3451
+ return new ZodPromise({
3452
+ type: schema,
3453
+ typeName: ZodFirstPartyTypeKind.ZodPromise,
3454
+ ...processCreateParams(params)
3455
+ });
3456
+ };
3457
+ class ZodEffects extends ZodType {
3458
+ innerType() {
3459
+ return this._def.schema;
3460
+ }
3461
+ sourceType() {
3462
+ return this._def.schema._def.typeName === ZodFirstPartyTypeKind.ZodEffects ? this._def.schema.sourceType() : this._def.schema;
3463
+ }
3464
+ _parse(input) {
3465
+ const { status, ctx } = this._processInputParams(input);
3466
+ const effect = this._def.effect || null;
3467
+ const checkCtx = {
3468
+ addIssue: (arg) => {
3469
+ addIssueToContext(ctx, arg);
3470
+ if (arg.fatal) {
3471
+ status.abort();
3472
+ } else {
3473
+ status.dirty();
3474
+ }
3475
+ },
3476
+ get path() {
3477
+ return ctx.path;
3478
+ }
3479
+ };
3480
+ checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx);
3481
+ if (effect.type === "preprocess") {
3482
+ const processed = effect.transform(ctx.data, checkCtx);
3483
+ if (ctx.common.async) {
3484
+ return Promise.resolve(processed).then(async (processed2) => {
3485
+ if (status.value === "aborted")
3486
+ return INVALID;
3487
+ const result = await this._def.schema._parseAsync({
3488
+ data: processed2,
3489
+ path: ctx.path,
3490
+ parent: ctx
3491
+ });
3492
+ if (result.status === "aborted")
3493
+ return INVALID;
3494
+ if (result.status === "dirty")
3495
+ return DIRTY(result.value);
3496
+ if (status.value === "dirty")
3497
+ return DIRTY(result.value);
3498
+ return result;
3499
+ });
3500
+ } else {
3501
+ if (status.value === "aborted")
3502
+ return INVALID;
3503
+ const result = this._def.schema._parseSync({
3504
+ data: processed,
3505
+ path: ctx.path,
3506
+ parent: ctx
3507
+ });
3508
+ if (result.status === "aborted")
3509
+ return INVALID;
3510
+ if (result.status === "dirty")
3511
+ return DIRTY(result.value);
3512
+ if (status.value === "dirty")
3513
+ return DIRTY(result.value);
3514
+ return result;
3515
+ }
3516
+ }
3517
+ if (effect.type === "refinement") {
3518
+ const executeRefinement = (acc) => {
3519
+ const result = effect.refinement(acc, checkCtx);
3520
+ if (ctx.common.async) {
3521
+ return Promise.resolve(result);
3522
+ }
3523
+ if (result instanceof Promise) {
3524
+ throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");
3525
+ }
3526
+ return acc;
3527
+ };
3528
+ if (ctx.common.async === false) {
3529
+ const inner = this._def.schema._parseSync({
3530
+ data: ctx.data,
3531
+ path: ctx.path,
3532
+ parent: ctx
3533
+ });
3534
+ if (inner.status === "aborted")
3535
+ return INVALID;
3536
+ if (inner.status === "dirty")
3537
+ status.dirty();
3538
+ executeRefinement(inner.value);
3539
+ return { status: status.value, value: inner.value };
3540
+ } else {
3541
+ return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((inner) => {
3542
+ if (inner.status === "aborted")
3543
+ return INVALID;
3544
+ if (inner.status === "dirty")
3545
+ status.dirty();
3546
+ return executeRefinement(inner.value).then(() => {
3547
+ return { status: status.value, value: inner.value };
3548
+ });
3549
+ });
3550
+ }
3551
+ }
3552
+ if (effect.type === "transform") {
3553
+ if (ctx.common.async === false) {
3554
+ const base = this._def.schema._parseSync({
3555
+ data: ctx.data,
3556
+ path: ctx.path,
3557
+ parent: ctx
3558
+ });
3559
+ if (!isValid(base))
3560
+ return base;
3561
+ const result = effect.transform(base.value, checkCtx);
3562
+ if (result instanceof Promise) {
3563
+ throw new Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`);
3564
+ }
3565
+ return { status: status.value, value: result };
3566
+ } else {
3567
+ return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((base) => {
3568
+ if (!isValid(base))
3569
+ return base;
3570
+ return Promise.resolve(effect.transform(base.value, checkCtx)).then((result) => ({ status: status.value, value: result }));
3571
+ });
3572
+ }
3573
+ }
3574
+ util.assertNever(effect);
3575
+ }
3576
+ }
3577
+ ZodEffects.create = (schema, effect, params) => {
3578
+ return new ZodEffects({
3579
+ schema,
3580
+ typeName: ZodFirstPartyTypeKind.ZodEffects,
3581
+ effect,
3582
+ ...processCreateParams(params)
3583
+ });
3584
+ };
3585
+ ZodEffects.createWithPreprocess = (preprocess, schema, params) => {
3586
+ return new ZodEffects({
3587
+ schema,
3588
+ effect: { type: "preprocess", transform: preprocess },
3589
+ typeName: ZodFirstPartyTypeKind.ZodEffects,
3590
+ ...processCreateParams(params)
3591
+ });
3592
+ };
3593
+ class ZodOptional extends ZodType {
3594
+ _parse(input) {
3595
+ const parsedType = this._getType(input);
3596
+ if (parsedType === ZodParsedType.undefined) {
3597
+ return OK(void 0);
3598
+ }
3599
+ return this._def.innerType._parse(input);
3600
+ }
3601
+ unwrap() {
3602
+ return this._def.innerType;
3603
+ }
3604
+ }
3605
+ ZodOptional.create = (type, params) => {
3606
+ return new ZodOptional({
3607
+ innerType: type,
3608
+ typeName: ZodFirstPartyTypeKind.ZodOptional,
3609
+ ...processCreateParams(params)
3610
+ });
3611
+ };
3612
+ class ZodNullable extends ZodType {
3613
+ _parse(input) {
3614
+ const parsedType = this._getType(input);
3615
+ if (parsedType === ZodParsedType.null) {
3616
+ return OK(null);
3617
+ }
3618
+ return this._def.innerType._parse(input);
3619
+ }
3620
+ unwrap() {
3621
+ return this._def.innerType;
3622
+ }
3623
+ }
3624
+ ZodNullable.create = (type, params) => {
3625
+ return new ZodNullable({
3626
+ innerType: type,
3627
+ typeName: ZodFirstPartyTypeKind.ZodNullable,
3628
+ ...processCreateParams(params)
3629
+ });
3630
+ };
3631
+ class ZodDefault extends ZodType {
3632
+ _parse(input) {
3633
+ const { ctx } = this._processInputParams(input);
3634
+ let data = ctx.data;
3635
+ if (ctx.parsedType === ZodParsedType.undefined) {
3636
+ data = this._def.defaultValue();
3637
+ }
3638
+ return this._def.innerType._parse({
3639
+ data,
3640
+ path: ctx.path,
3641
+ parent: ctx
3642
+ });
3643
+ }
3644
+ removeDefault() {
3645
+ return this._def.innerType;
3646
+ }
3647
+ }
3648
+ ZodDefault.create = (type, params) => {
3649
+ return new ZodDefault({
3650
+ innerType: type,
3651
+ typeName: ZodFirstPartyTypeKind.ZodDefault,
3652
+ defaultValue: typeof params.default === "function" ? params.default : () => params.default,
3653
+ ...processCreateParams(params)
3654
+ });
3655
+ };
3656
+ class ZodCatch extends ZodType {
3657
+ _parse(input) {
3658
+ const { ctx } = this._processInputParams(input);
3659
+ const newCtx = {
3660
+ ...ctx,
3661
+ common: {
3662
+ ...ctx.common,
3663
+ issues: []
3664
+ }
3665
+ };
3666
+ const result = this._def.innerType._parse({
3667
+ data: newCtx.data,
3668
+ path: newCtx.path,
3669
+ parent: {
3670
+ ...newCtx
3671
+ }
3672
+ });
3673
+ if (isAsync(result)) {
3674
+ return result.then((result2) => {
3675
+ return {
3676
+ status: "valid",
3677
+ value: result2.status === "valid" ? result2.value : this._def.catchValue({
3678
+ get error() {
3679
+ return new ZodError(newCtx.common.issues);
3680
+ },
3681
+ input: newCtx.data
3682
+ })
3683
+ };
3684
+ });
3685
+ } else {
3686
+ return {
3687
+ status: "valid",
3688
+ value: result.status === "valid" ? result.value : this._def.catchValue({
3689
+ get error() {
3690
+ return new ZodError(newCtx.common.issues);
3691
+ },
3692
+ input: newCtx.data
3693
+ })
3694
+ };
3695
+ }
3696
+ }
3697
+ removeCatch() {
3698
+ return this._def.innerType;
3699
+ }
3700
+ }
3701
+ ZodCatch.create = (type, params) => {
3702
+ return new ZodCatch({
3703
+ innerType: type,
3704
+ typeName: ZodFirstPartyTypeKind.ZodCatch,
3705
+ catchValue: typeof params.catch === "function" ? params.catch : () => params.catch,
3706
+ ...processCreateParams(params)
3707
+ });
3708
+ };
3709
+ class ZodNaN extends ZodType {
3710
+ _parse(input) {
3711
+ const parsedType = this._getType(input);
3712
+ if (parsedType !== ZodParsedType.nan) {
3713
+ const ctx = this._getOrReturnCtx(input);
3714
+ addIssueToContext(ctx, {
3715
+ code: ZodIssueCode.invalid_type,
3716
+ expected: ZodParsedType.nan,
3717
+ received: ctx.parsedType
3718
+ });
3719
+ return INVALID;
3720
+ }
3721
+ return { status: "valid", value: input.data };
3722
+ }
3723
+ }
3724
+ ZodNaN.create = (params) => {
3725
+ return new ZodNaN({
3726
+ typeName: ZodFirstPartyTypeKind.ZodNaN,
3727
+ ...processCreateParams(params)
3728
+ });
3729
+ };
3730
+ const BRAND = Symbol("zod_brand");
3731
+ class ZodBranded extends ZodType {
3732
+ _parse(input) {
3733
+ const { ctx } = this._processInputParams(input);
3734
+ const data = ctx.data;
3735
+ return this._def.type._parse({
3736
+ data,
3737
+ path: ctx.path,
3738
+ parent: ctx
3739
+ });
3740
+ }
3741
+ unwrap() {
3742
+ return this._def.type;
3743
+ }
3744
+ }
3745
+ class ZodPipeline extends ZodType {
3746
+ _parse(input) {
3747
+ const { status, ctx } = this._processInputParams(input);
3748
+ if (ctx.common.async) {
3749
+ const handleAsync = async () => {
3750
+ const inResult = await this._def.in._parseAsync({
3751
+ data: ctx.data,
3752
+ path: ctx.path,
3753
+ parent: ctx
3754
+ });
3755
+ if (inResult.status === "aborted")
3756
+ return INVALID;
3757
+ if (inResult.status === "dirty") {
3758
+ status.dirty();
3759
+ return DIRTY(inResult.value);
3760
+ } else {
3761
+ return this._def.out._parseAsync({
3762
+ data: inResult.value,
3763
+ path: ctx.path,
3764
+ parent: ctx
3765
+ });
3766
+ }
3767
+ };
3768
+ return handleAsync();
3769
+ } else {
3770
+ const inResult = this._def.in._parseSync({
3771
+ data: ctx.data,
3772
+ path: ctx.path,
3773
+ parent: ctx
3774
+ });
3775
+ if (inResult.status === "aborted")
3776
+ return INVALID;
3777
+ if (inResult.status === "dirty") {
3778
+ status.dirty();
3779
+ return {
3780
+ status: "dirty",
3781
+ value: inResult.value
3782
+ };
3783
+ } else {
3784
+ return this._def.out._parseSync({
3785
+ data: inResult.value,
3786
+ path: ctx.path,
3787
+ parent: ctx
3788
+ });
3789
+ }
3790
+ }
3791
+ }
3792
+ static create(a, b) {
3793
+ return new ZodPipeline({
3794
+ in: a,
3795
+ out: b,
3796
+ typeName: ZodFirstPartyTypeKind.ZodPipeline
3797
+ });
3798
+ }
3799
+ }
3800
+ class ZodReadonly extends ZodType {
3801
+ _parse(input) {
3802
+ const result = this._def.innerType._parse(input);
3803
+ const freeze = (data) => {
3804
+ if (isValid(data)) {
3805
+ data.value = Object.freeze(data.value);
3806
+ }
3807
+ return data;
3808
+ };
3809
+ return isAsync(result) ? result.then((data) => freeze(data)) : freeze(result);
3810
+ }
3811
+ unwrap() {
3812
+ return this._def.innerType;
3813
+ }
3814
+ }
3815
+ ZodReadonly.create = (type, params) => {
3816
+ return new ZodReadonly({
3817
+ innerType: type,
3818
+ typeName: ZodFirstPartyTypeKind.ZodReadonly,
3819
+ ...processCreateParams(params)
3820
+ });
3821
+ };
3822
+ function cleanParams(params, data) {
3823
+ const p = typeof params === "function" ? params(data) : typeof params === "string" ? { message: params } : params;
3824
+ const p2 = typeof p === "string" ? { message: p } : p;
3825
+ return p2;
3826
+ }
3827
+ function custom(check, _params = {}, fatal) {
3828
+ if (check)
3829
+ return ZodAny.create().superRefine((data, ctx) => {
3830
+ var _a, _b;
3831
+ const r = check(data);
3832
+ if (r instanceof Promise) {
3833
+ return r.then((r2) => {
3834
+ var _a2, _b2;
3835
+ if (!r2) {
3836
+ const params = cleanParams(_params, data);
3837
+ const _fatal = (_b2 = (_a2 = params.fatal) !== null && _a2 !== void 0 ? _a2 : fatal) !== null && _b2 !== void 0 ? _b2 : true;
3838
+ ctx.addIssue({ code: "custom", ...params, fatal: _fatal });
3839
+ }
3840
+ });
3841
+ }
3842
+ if (!r) {
3843
+ const params = cleanParams(_params, data);
3844
+ const _fatal = (_b = (_a = params.fatal) !== null && _a !== void 0 ? _a : fatal) !== null && _b !== void 0 ? _b : true;
3845
+ ctx.addIssue({ code: "custom", ...params, fatal: _fatal });
3846
+ }
3847
+ return;
3848
+ });
3849
+ return ZodAny.create();
3850
+ }
3851
+ const late = {
3852
+ object: ZodObject.lazycreate
3853
+ };
3854
+ var ZodFirstPartyTypeKind;
3855
+ (function(ZodFirstPartyTypeKind2) {
3856
+ ZodFirstPartyTypeKind2["ZodString"] = "ZodString";
3857
+ ZodFirstPartyTypeKind2["ZodNumber"] = "ZodNumber";
3858
+ ZodFirstPartyTypeKind2["ZodNaN"] = "ZodNaN";
3859
+ ZodFirstPartyTypeKind2["ZodBigInt"] = "ZodBigInt";
3860
+ ZodFirstPartyTypeKind2["ZodBoolean"] = "ZodBoolean";
3861
+ ZodFirstPartyTypeKind2["ZodDate"] = "ZodDate";
3862
+ ZodFirstPartyTypeKind2["ZodSymbol"] = "ZodSymbol";
3863
+ ZodFirstPartyTypeKind2["ZodUndefined"] = "ZodUndefined";
3864
+ ZodFirstPartyTypeKind2["ZodNull"] = "ZodNull";
3865
+ ZodFirstPartyTypeKind2["ZodAny"] = "ZodAny";
3866
+ ZodFirstPartyTypeKind2["ZodUnknown"] = "ZodUnknown";
3867
+ ZodFirstPartyTypeKind2["ZodNever"] = "ZodNever";
3868
+ ZodFirstPartyTypeKind2["ZodVoid"] = "ZodVoid";
3869
+ ZodFirstPartyTypeKind2["ZodArray"] = "ZodArray";
3870
+ ZodFirstPartyTypeKind2["ZodObject"] = "ZodObject";
3871
+ ZodFirstPartyTypeKind2["ZodUnion"] = "ZodUnion";
3872
+ ZodFirstPartyTypeKind2["ZodDiscriminatedUnion"] = "ZodDiscriminatedUnion";
3873
+ ZodFirstPartyTypeKind2["ZodIntersection"] = "ZodIntersection";
3874
+ ZodFirstPartyTypeKind2["ZodTuple"] = "ZodTuple";
3875
+ ZodFirstPartyTypeKind2["ZodRecord"] = "ZodRecord";
3876
+ ZodFirstPartyTypeKind2["ZodMap"] = "ZodMap";
3877
+ ZodFirstPartyTypeKind2["ZodSet"] = "ZodSet";
3878
+ ZodFirstPartyTypeKind2["ZodFunction"] = "ZodFunction";
3879
+ ZodFirstPartyTypeKind2["ZodLazy"] = "ZodLazy";
3880
+ ZodFirstPartyTypeKind2["ZodLiteral"] = "ZodLiteral";
3881
+ ZodFirstPartyTypeKind2["ZodEnum"] = "ZodEnum";
3882
+ ZodFirstPartyTypeKind2["ZodEffects"] = "ZodEffects";
3883
+ ZodFirstPartyTypeKind2["ZodNativeEnum"] = "ZodNativeEnum";
3884
+ ZodFirstPartyTypeKind2["ZodOptional"] = "ZodOptional";
3885
+ ZodFirstPartyTypeKind2["ZodNullable"] = "ZodNullable";
3886
+ ZodFirstPartyTypeKind2["ZodDefault"] = "ZodDefault";
3887
+ ZodFirstPartyTypeKind2["ZodCatch"] = "ZodCatch";
3888
+ ZodFirstPartyTypeKind2["ZodPromise"] = "ZodPromise";
3889
+ ZodFirstPartyTypeKind2["ZodBranded"] = "ZodBranded";
3890
+ ZodFirstPartyTypeKind2["ZodPipeline"] = "ZodPipeline";
3891
+ ZodFirstPartyTypeKind2["ZodReadonly"] = "ZodReadonly";
3892
+ })(ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {}));
3893
+ const instanceOfType = (cls, params = {
3894
+ message: `Input not instance of ${cls.name}`
3895
+ }) => custom((data) => data instanceof cls, params);
3896
+ const stringType = ZodString.create;
3897
+ const numberType = ZodNumber.create;
3898
+ const nanType = ZodNaN.create;
3899
+ const bigIntType = ZodBigInt.create;
3900
+ const booleanType = ZodBoolean.create;
3901
+ const dateType = ZodDate.create;
3902
+ const symbolType = ZodSymbol.create;
3903
+ const undefinedType = ZodUndefined.create;
3904
+ const nullType = ZodNull.create;
3905
+ const anyType = ZodAny.create;
3906
+ const unknownType = ZodUnknown.create;
3907
+ const neverType = ZodNever.create;
3908
+ const voidType = ZodVoid.create;
3909
+ const arrayType = ZodArray.create;
3910
+ const objectType = ZodObject.create;
3911
+ const strictObjectType = ZodObject.strictCreate;
3912
+ const unionType = ZodUnion.create;
3913
+ const discriminatedUnionType = ZodDiscriminatedUnion.create;
3914
+ const intersectionType = ZodIntersection.create;
3915
+ const tupleType = ZodTuple.create;
3916
+ const recordType = ZodRecord.create;
3917
+ const mapType = ZodMap.create;
3918
+ const setType = ZodSet.create;
3919
+ const functionType = ZodFunction.create;
3920
+ const lazyType = ZodLazy.create;
3921
+ const literalType = ZodLiteral.create;
3922
+ const enumType = ZodEnum.create;
3923
+ const nativeEnumType = ZodNativeEnum.create;
3924
+ const promiseType = ZodPromise.create;
3925
+ const effectsType = ZodEffects.create;
3926
+ const optionalType = ZodOptional.create;
3927
+ const nullableType = ZodNullable.create;
3928
+ const preprocessType = ZodEffects.createWithPreprocess;
3929
+ const pipelineType = ZodPipeline.create;
3930
+ const ostring = () => stringType().optional();
3931
+ const onumber = () => numberType().optional();
3932
+ const oboolean = () => booleanType().optional();
3933
+ const coerce = {
3934
+ string: (arg) => ZodString.create({ ...arg, coerce: true }),
3935
+ number: (arg) => ZodNumber.create({ ...arg, coerce: true }),
3936
+ boolean: (arg) => ZodBoolean.create({
3937
+ ...arg,
3938
+ coerce: true
3939
+ }),
3940
+ bigint: (arg) => ZodBigInt.create({ ...arg, coerce: true }),
3941
+ date: (arg) => ZodDate.create({ ...arg, coerce: true })
3942
+ };
3943
+ const NEVER = INVALID;
3944
+ var z = /* @__PURE__ */ Object.freeze({
3945
+ __proto__: null,
3946
+ defaultErrorMap: errorMap,
3947
+ setErrorMap,
3948
+ getErrorMap,
3949
+ makeIssue,
3950
+ EMPTY_PATH,
3951
+ addIssueToContext,
3952
+ ParseStatus,
3953
+ INVALID,
3954
+ DIRTY,
3955
+ OK,
3956
+ isAborted,
3957
+ isDirty,
3958
+ isValid,
3959
+ isAsync,
3960
+ get util() {
3961
+ return util;
3962
+ },
3963
+ get objectUtil() {
3964
+ return objectUtil;
3965
+ },
3966
+ ZodParsedType,
3967
+ getParsedType,
3968
+ ZodType,
3969
+ datetimeRegex,
3970
+ ZodString,
3971
+ ZodNumber,
3972
+ ZodBigInt,
3973
+ ZodBoolean,
3974
+ ZodDate,
3975
+ ZodSymbol,
3976
+ ZodUndefined,
3977
+ ZodNull,
3978
+ ZodAny,
3979
+ ZodUnknown,
3980
+ ZodNever,
3981
+ ZodVoid,
3982
+ ZodArray,
3983
+ ZodObject,
3984
+ ZodUnion,
3985
+ ZodDiscriminatedUnion,
3986
+ ZodIntersection,
3987
+ ZodTuple,
3988
+ ZodRecord,
3989
+ ZodMap,
3990
+ ZodSet,
3991
+ ZodFunction,
3992
+ ZodLazy,
3993
+ ZodLiteral,
3994
+ ZodEnum,
3995
+ ZodNativeEnum,
3996
+ ZodPromise,
3997
+ ZodEffects,
3998
+ ZodTransformer: ZodEffects,
3999
+ ZodOptional,
4000
+ ZodNullable,
4001
+ ZodDefault,
4002
+ ZodCatch,
4003
+ ZodNaN,
4004
+ BRAND,
4005
+ ZodBranded,
4006
+ ZodPipeline,
4007
+ ZodReadonly,
4008
+ custom,
4009
+ Schema: ZodType,
4010
+ ZodSchema: ZodType,
4011
+ late,
4012
+ get ZodFirstPartyTypeKind() {
4013
+ return ZodFirstPartyTypeKind;
4014
+ },
4015
+ coerce,
4016
+ any: anyType,
4017
+ array: arrayType,
4018
+ bigint: bigIntType,
4019
+ boolean: booleanType,
4020
+ date: dateType,
4021
+ discriminatedUnion: discriminatedUnionType,
4022
+ effect: effectsType,
4023
+ "enum": enumType,
4024
+ "function": functionType,
4025
+ "instanceof": instanceOfType,
4026
+ intersection: intersectionType,
4027
+ lazy: lazyType,
4028
+ literal: literalType,
4029
+ map: mapType,
4030
+ nan: nanType,
4031
+ nativeEnum: nativeEnumType,
4032
+ never: neverType,
4033
+ "null": nullType,
4034
+ nullable: nullableType,
4035
+ number: numberType,
4036
+ object: objectType,
4037
+ oboolean,
4038
+ onumber,
4039
+ optional: optionalType,
4040
+ ostring,
4041
+ pipeline: pipelineType,
4042
+ preprocess: preprocessType,
4043
+ promise: promiseType,
4044
+ record: recordType,
4045
+ set: setType,
4046
+ strictObject: strictObjectType,
4047
+ string: stringType,
4048
+ symbol: symbolType,
4049
+ transformer: effectsType,
4050
+ tuple: tupleType,
4051
+ "undefined": undefinedType,
4052
+ union: unionType,
4053
+ unknown: unknownType,
4054
+ "void": voidType,
4055
+ NEVER,
4056
+ ZodIssueCode,
4057
+ quotelessJson,
4058
+ ZodError
4059
+ });
10
4060
  export {
11
- decodeBase64
4061
+ BRAND,
4062
+ DIRTY,
4063
+ EMPTY_PATH,
4064
+ INVALID,
4065
+ NEVER,
4066
+ OK,
4067
+ ParseStatus,
4068
+ ZodType as Schema,
4069
+ ZodAny,
4070
+ ZodArray,
4071
+ ZodBigInt,
4072
+ ZodBoolean,
4073
+ ZodBranded,
4074
+ ZodCatch,
4075
+ ZodDate,
4076
+ ZodDefault,
4077
+ ZodDiscriminatedUnion,
4078
+ ZodEffects,
4079
+ ZodEnum,
4080
+ ZodError,
4081
+ ZodFirstPartyTypeKind,
4082
+ ZodFunction,
4083
+ ZodIntersection,
4084
+ ZodIssueCode,
4085
+ ZodLazy,
4086
+ ZodLiteral,
4087
+ ZodMap,
4088
+ ZodNaN,
4089
+ ZodNativeEnum,
4090
+ ZodNever,
4091
+ ZodNull,
4092
+ ZodNullable,
4093
+ ZodNumber,
4094
+ ZodObject,
4095
+ ZodOptional,
4096
+ ZodParsedType,
4097
+ ZodPipeline,
4098
+ ZodPromise,
4099
+ ZodReadonly,
4100
+ ZodRecord,
4101
+ ZodType as ZodSchema,
4102
+ ZodSet,
4103
+ ZodString,
4104
+ ZodSymbol,
4105
+ ZodEffects as ZodTransformer,
4106
+ ZodTuple,
4107
+ ZodType,
4108
+ ZodUndefined,
4109
+ ZodUnion,
4110
+ ZodUnknown,
4111
+ ZodVoid,
4112
+ addIssueToContext,
4113
+ anyType as any,
4114
+ arrayType as array,
4115
+ bigIntType as bigint,
4116
+ booleanType as boolean,
4117
+ coerce,
4118
+ custom,
4119
+ dateType as date,
4120
+ datetimeRegex,
4121
+ z as default,
4122
+ errorMap as defaultErrorMap,
4123
+ discriminatedUnionType as discriminatedUnion,
4124
+ effectsType as effect,
4125
+ enumType as enum,
4126
+ functionType as function,
4127
+ getErrorMap,
4128
+ getParsedType,
4129
+ instanceOfType as instanceof,
4130
+ intersectionType as intersection,
4131
+ isAborted,
4132
+ isAsync,
4133
+ isDirty,
4134
+ isValid,
4135
+ late,
4136
+ lazyType as lazy,
4137
+ literalType as literal,
4138
+ makeIssue,
4139
+ mapType as map,
4140
+ nanType as nan,
4141
+ nativeEnumType as nativeEnum,
4142
+ neverType as never,
4143
+ nullType as null,
4144
+ nullableType as nullable,
4145
+ numberType as number,
4146
+ objectType as object,
4147
+ objectUtil,
4148
+ oboolean,
4149
+ onumber,
4150
+ optionalType as optional,
4151
+ ostring,
4152
+ pipelineType as pipeline,
4153
+ preprocessType as preprocess,
4154
+ promiseType as promise,
4155
+ quotelessJson,
4156
+ recordType as record,
4157
+ setType as set,
4158
+ setErrorMap,
4159
+ strictObjectType as strictObject,
4160
+ stringType as string,
4161
+ symbolType as symbol,
4162
+ effectsType as transformer,
4163
+ tupleType as tuple,
4164
+ undefinedType as undefined,
4165
+ unionType as union,
4166
+ unknownType as unknown,
4167
+ util,
4168
+ voidType as void,
4169
+ z
12
4170
  };
13
4171
  //# sourceMappingURL=standards-sdk.es34.js.map