@jsfsi-core/ts-crossplatform 1.0.5 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -0
- package/dist/index.mjs +2726 -0
- package/dist/src/configuration/configuration.d.ts +2 -0
- package/dist/src/configuration/configuration.test.d.ts +1 -0
- package/dist/src/datetime/datetime.d.ts +4 -0
- package/dist/src/datetime/datetime.test.d.ts +1 -0
- package/dist/src/failures/failure.d.ts +4 -0
- package/dist/src/failures/matchers.d.ts +3 -0
- package/dist/src/failures/matchers.unit.test.d.ts +1 -0
- package/dist/src/guid/Guid.d.ts +10 -0
- package/dist/src/guid/Guid.test.d.ts +1 -0
- package/dist/src/mocks/mock.d.ts +2 -0
- package/dist/src/mocks/mock.unit.test.d.ts +1 -0
- package/dist/src/paging/Page.d.ts +31 -0
- package/dist/src/paging/PageQuery.d.ts +12 -0
- package/dist/src/partials/RecursivePartial.d.ts +3 -0
- package/dist/src/result/result.d.ts +4 -0
- package/dist/src/result/result.unit.test.d.ts +1 -0
- package/dist/vite.config.d.ts +2 -0
- package/package.json +4 -1
- package/src/configuration/configuration.test.ts +0 -41
- package/src/configuration/configuration.ts +0 -14
- package/src/datetime/datetime.test.ts +0 -42
- package/src/datetime/datetime.ts +0 -24
- package/src/failures/failure.ts +0 -7
- package/src/failures/matchers.ts +0 -13
- package/src/failures/matchers.unit.test.ts +0 -61
- package/src/guid/Guid.test.ts +0 -44
- package/src/guid/Guid.ts +0 -34
- package/src/mocks/mock.ts +0 -3
- package/src/mocks/mock.unit.test.ts +0 -41
- package/src/paging/Page.ts +0 -20
- package/src/paging/PageQuery.ts +0 -8
- package/src/partials/RecursivePartial.ts +0 -3
- package/src/result/result.ts +0 -10
- package/src/result/result.unit.test.ts +0 -100
- package/tsconfig.json +0 -8
- package/vite.config.ts +0 -24
- package/vitest.config.ts +0 -28
- /package/{src/failures/index.ts → dist/src/failures/index.d.ts} +0 -0
- /package/{src/index.ts → dist/src/index.d.ts} +0 -0
- /package/{src/paging/index.ts → dist/src/paging/index.d.ts} +0 -0
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,2726 @@
|
|
|
1
|
+
const ct = (s = {}) => s, ut = (s) => [s, void 0], lt = (s) => [
|
|
2
|
+
void 0,
|
|
3
|
+
s
|
|
4
|
+
];
|
|
5
|
+
class ft {
|
|
6
|
+
name;
|
|
7
|
+
constructor() {
|
|
8
|
+
this.name = this.constructor.name;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
const ht = (
|
|
12
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
13
|
+
(s) => (e) => !(e instanceof s)
|
|
14
|
+
), mt = (
|
|
15
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
16
|
+
(s) => (e) => e instanceof s
|
|
17
|
+
), pt = (s, e = process.env) => {
|
|
18
|
+
const t = s.safeParse(e);
|
|
19
|
+
if (!t.success)
|
|
20
|
+
throw new Error(`Invalid environment variables: ${JSON.stringify(t.error.issues)}`);
|
|
21
|
+
return t.data;
|
|
22
|
+
};
|
|
23
|
+
function gt(s) {
|
|
24
|
+
return new Promise((e) => setTimeout(e, s));
|
|
25
|
+
}
|
|
26
|
+
function Se(s, e) {
|
|
27
|
+
return new Date(s).toLocaleDateString(e, {
|
|
28
|
+
year: "numeric",
|
|
29
|
+
month: "2-digit",
|
|
30
|
+
day: "2-digit"
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
function Oe(s, e) {
|
|
34
|
+
return new Date(s).toLocaleTimeString(e, {
|
|
35
|
+
hour12: !1,
|
|
36
|
+
hour: "2-digit",
|
|
37
|
+
minute: "2-digit",
|
|
38
|
+
second: "2-digit"
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
function yt(s, e) {
|
|
42
|
+
return `${Se(s, e)} ${Oe(s, e)}`;
|
|
43
|
+
}
|
|
44
|
+
const Ae = "00000000-0000-0000-0000-000000000000", Ne = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i;
|
|
45
|
+
function xe(s) {
|
|
46
|
+
return typeof s == "string" && Ne.test(s);
|
|
47
|
+
}
|
|
48
|
+
function Ze(s) {
|
|
49
|
+
if (!xe(s))
|
|
50
|
+
throw TypeError("Invalid UUID");
|
|
51
|
+
let e;
|
|
52
|
+
return Uint8Array.of((e = parseInt(s.slice(0, 8), 16)) >>> 24, e >>> 16 & 255, e >>> 8 & 255, e & 255, (e = parseInt(s.slice(9, 13), 16)) >>> 8, e & 255, (e = parseInt(s.slice(14, 18), 16)) >>> 8, e & 255, (e = parseInt(s.slice(19, 23), 16)) >>> 8, e & 255, (e = parseInt(s.slice(24, 36), 16)) / 1099511627776 & 255, e / 4294967296 & 255, e >>> 24 & 255, e >>> 16 & 255, e >>> 8 & 255, e & 255);
|
|
53
|
+
}
|
|
54
|
+
const k = [];
|
|
55
|
+
for (let s = 0; s < 256; ++s)
|
|
56
|
+
k.push((s + 256).toString(16).slice(1));
|
|
57
|
+
function Re(s, e = 0) {
|
|
58
|
+
return (k[s[e + 0]] + k[s[e + 1]] + k[s[e + 2]] + k[s[e + 3]] + "-" + k[s[e + 4]] + k[s[e + 5]] + "-" + k[s[e + 6]] + k[s[e + 7]] + "-" + k[s[e + 8]] + k[s[e + 9]] + "-" + k[s[e + 10]] + k[s[e + 11]] + k[s[e + 12]] + k[s[e + 13]] + k[s[e + 14]] + k[s[e + 15]]).toLowerCase();
|
|
59
|
+
}
|
|
60
|
+
let Y;
|
|
61
|
+
const Ie = new Uint8Array(16);
|
|
62
|
+
function Ee() {
|
|
63
|
+
if (!Y) {
|
|
64
|
+
if (typeof crypto > "u" || !crypto.getRandomValues)
|
|
65
|
+
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
66
|
+
Y = crypto.getRandomValues.bind(crypto);
|
|
67
|
+
}
|
|
68
|
+
return Y(Ie);
|
|
69
|
+
}
|
|
70
|
+
const je = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), re = { randomUUID: je };
|
|
71
|
+
function $e(s, e, t) {
|
|
72
|
+
if (re.randomUUID && !s)
|
|
73
|
+
return re.randomUUID();
|
|
74
|
+
s = s || {};
|
|
75
|
+
const r = s.random ?? s.rng?.() ?? Ee();
|
|
76
|
+
if (r.length < 16)
|
|
77
|
+
throw new Error("Random bytes length must be >= 16");
|
|
78
|
+
return r[6] = r[6] & 15 | 64, r[8] = r[8] & 63 | 128, Re(r);
|
|
79
|
+
}
|
|
80
|
+
class M {
|
|
81
|
+
uuid;
|
|
82
|
+
constructor(e) {
|
|
83
|
+
Ze(e), this.uuid = e;
|
|
84
|
+
}
|
|
85
|
+
toString() {
|
|
86
|
+
return this.uuid;
|
|
87
|
+
}
|
|
88
|
+
equals(e) {
|
|
89
|
+
return this.uuid === e.toString();
|
|
90
|
+
}
|
|
91
|
+
static new() {
|
|
92
|
+
return new M($e());
|
|
93
|
+
}
|
|
94
|
+
static empty() {
|
|
95
|
+
return new M(Ae);
|
|
96
|
+
}
|
|
97
|
+
static isValid(e) {
|
|
98
|
+
return !!(e && xe(e));
|
|
99
|
+
}
|
|
100
|
+
static parse(e) {
|
|
101
|
+
return e && M.isValid(e) ? new M(e) : void 0;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
var _;
|
|
105
|
+
(function(s) {
|
|
106
|
+
s.assertEqual = (a) => {
|
|
107
|
+
};
|
|
108
|
+
function e(a) {
|
|
109
|
+
}
|
|
110
|
+
s.assertIs = e;
|
|
111
|
+
function t(a) {
|
|
112
|
+
throw new Error();
|
|
113
|
+
}
|
|
114
|
+
s.assertNever = t, s.arrayToEnum = (a) => {
|
|
115
|
+
const n = {};
|
|
116
|
+
for (const i of a)
|
|
117
|
+
n[i] = i;
|
|
118
|
+
return n;
|
|
119
|
+
}, s.getValidEnumValues = (a) => {
|
|
120
|
+
const n = s.objectKeys(a).filter((o) => typeof a[a[o]] != "number"), i = {};
|
|
121
|
+
for (const o of n)
|
|
122
|
+
i[o] = a[o];
|
|
123
|
+
return s.objectValues(i);
|
|
124
|
+
}, s.objectValues = (a) => s.objectKeys(a).map(function(n) {
|
|
125
|
+
return a[n];
|
|
126
|
+
}), s.objectKeys = typeof Object.keys == "function" ? (a) => Object.keys(a) : (a) => {
|
|
127
|
+
const n = [];
|
|
128
|
+
for (const i in a)
|
|
129
|
+
Object.prototype.hasOwnProperty.call(a, i) && n.push(i);
|
|
130
|
+
return n;
|
|
131
|
+
}, s.find = (a, n) => {
|
|
132
|
+
for (const i of a)
|
|
133
|
+
if (n(i))
|
|
134
|
+
return i;
|
|
135
|
+
}, s.isInteger = typeof Number.isInteger == "function" ? (a) => Number.isInteger(a) : (a) => typeof a == "number" && Number.isFinite(a) && Math.floor(a) === a;
|
|
136
|
+
function r(a, n = " | ") {
|
|
137
|
+
return a.map((i) => typeof i == "string" ? `'${i}'` : i).join(n);
|
|
138
|
+
}
|
|
139
|
+
s.joinValues = r, s.jsonStringifyReplacer = (a, n) => typeof n == "bigint" ? n.toString() : n;
|
|
140
|
+
})(_ || (_ = {}));
|
|
141
|
+
var ae;
|
|
142
|
+
(function(s) {
|
|
143
|
+
s.mergeShapes = (e, t) => ({
|
|
144
|
+
...e,
|
|
145
|
+
...t
|
|
146
|
+
// second overwrites first
|
|
147
|
+
});
|
|
148
|
+
})(ae || (ae = {}));
|
|
149
|
+
const u = _.arrayToEnum([
|
|
150
|
+
"string",
|
|
151
|
+
"nan",
|
|
152
|
+
"number",
|
|
153
|
+
"integer",
|
|
154
|
+
"float",
|
|
155
|
+
"boolean",
|
|
156
|
+
"date",
|
|
157
|
+
"bigint",
|
|
158
|
+
"symbol",
|
|
159
|
+
"function",
|
|
160
|
+
"undefined",
|
|
161
|
+
"null",
|
|
162
|
+
"array",
|
|
163
|
+
"object",
|
|
164
|
+
"unknown",
|
|
165
|
+
"promise",
|
|
166
|
+
"void",
|
|
167
|
+
"never",
|
|
168
|
+
"map",
|
|
169
|
+
"set"
|
|
170
|
+
]), S = (s) => {
|
|
171
|
+
switch (typeof s) {
|
|
172
|
+
case "undefined":
|
|
173
|
+
return u.undefined;
|
|
174
|
+
case "string":
|
|
175
|
+
return u.string;
|
|
176
|
+
case "number":
|
|
177
|
+
return Number.isNaN(s) ? u.nan : u.number;
|
|
178
|
+
case "boolean":
|
|
179
|
+
return u.boolean;
|
|
180
|
+
case "function":
|
|
181
|
+
return u.function;
|
|
182
|
+
case "bigint":
|
|
183
|
+
return u.bigint;
|
|
184
|
+
case "symbol":
|
|
185
|
+
return u.symbol;
|
|
186
|
+
case "object":
|
|
187
|
+
return Array.isArray(s) ? u.array : s === null ? u.null : s.then && typeof s.then == "function" && s.catch && typeof s.catch == "function" ? u.promise : typeof Map < "u" && s instanceof Map ? u.map : typeof Set < "u" && s instanceof Set ? u.set : typeof Date < "u" && s instanceof Date ? u.date : u.object;
|
|
188
|
+
default:
|
|
189
|
+
return u.unknown;
|
|
190
|
+
}
|
|
191
|
+
}, d = _.arrayToEnum([
|
|
192
|
+
"invalid_type",
|
|
193
|
+
"invalid_literal",
|
|
194
|
+
"custom",
|
|
195
|
+
"invalid_union",
|
|
196
|
+
"invalid_union_discriminator",
|
|
197
|
+
"invalid_enum_value",
|
|
198
|
+
"unrecognized_keys",
|
|
199
|
+
"invalid_arguments",
|
|
200
|
+
"invalid_return_type",
|
|
201
|
+
"invalid_date",
|
|
202
|
+
"invalid_string",
|
|
203
|
+
"too_small",
|
|
204
|
+
"too_big",
|
|
205
|
+
"invalid_intersection_types",
|
|
206
|
+
"not_multiple_of",
|
|
207
|
+
"not_finite"
|
|
208
|
+
]);
|
|
209
|
+
class T extends Error {
|
|
210
|
+
get errors() {
|
|
211
|
+
return this.issues;
|
|
212
|
+
}
|
|
213
|
+
constructor(e) {
|
|
214
|
+
super(), this.issues = [], this.addIssue = (r) => {
|
|
215
|
+
this.issues = [...this.issues, r];
|
|
216
|
+
}, this.addIssues = (r = []) => {
|
|
217
|
+
this.issues = [...this.issues, ...r];
|
|
218
|
+
};
|
|
219
|
+
const t = new.target.prototype;
|
|
220
|
+
Object.setPrototypeOf ? Object.setPrototypeOf(this, t) : this.__proto__ = t, this.name = "ZodError", this.issues = e;
|
|
221
|
+
}
|
|
222
|
+
format(e) {
|
|
223
|
+
const t = e || function(n) {
|
|
224
|
+
return n.message;
|
|
225
|
+
}, r = { _errors: [] }, a = (n) => {
|
|
226
|
+
for (const i of n.issues)
|
|
227
|
+
if (i.code === "invalid_union")
|
|
228
|
+
i.unionErrors.map(a);
|
|
229
|
+
else if (i.code === "invalid_return_type")
|
|
230
|
+
a(i.returnTypeError);
|
|
231
|
+
else if (i.code === "invalid_arguments")
|
|
232
|
+
a(i.argumentsError);
|
|
233
|
+
else if (i.path.length === 0)
|
|
234
|
+
r._errors.push(t(i));
|
|
235
|
+
else {
|
|
236
|
+
let o = r, f = 0;
|
|
237
|
+
for (; f < i.path.length; ) {
|
|
238
|
+
const h = i.path[f];
|
|
239
|
+
f === i.path.length - 1 ? (o[h] = o[h] || { _errors: [] }, o[h]._errors.push(t(i))) : o[h] = o[h] || { _errors: [] }, o = o[h], f++;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
};
|
|
243
|
+
return a(this), r;
|
|
244
|
+
}
|
|
245
|
+
static assert(e) {
|
|
246
|
+
if (!(e instanceof T))
|
|
247
|
+
throw new Error(`Not a ZodError: ${e}`);
|
|
248
|
+
}
|
|
249
|
+
toString() {
|
|
250
|
+
return this.message;
|
|
251
|
+
}
|
|
252
|
+
get message() {
|
|
253
|
+
return JSON.stringify(this.issues, _.jsonStringifyReplacer, 2);
|
|
254
|
+
}
|
|
255
|
+
get isEmpty() {
|
|
256
|
+
return this.issues.length === 0;
|
|
257
|
+
}
|
|
258
|
+
flatten(e = (t) => t.message) {
|
|
259
|
+
const t = {}, r = [];
|
|
260
|
+
for (const a of this.issues)
|
|
261
|
+
a.path.length > 0 ? (t[a.path[0]] = t[a.path[0]] || [], t[a.path[0]].push(e(a))) : r.push(e(a));
|
|
262
|
+
return { formErrors: r, fieldErrors: t };
|
|
263
|
+
}
|
|
264
|
+
get formErrors() {
|
|
265
|
+
return this.flatten();
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
T.create = (s) => new T(s);
|
|
269
|
+
const X = (s, e) => {
|
|
270
|
+
let t;
|
|
271
|
+
switch (s.code) {
|
|
272
|
+
case d.invalid_type:
|
|
273
|
+
s.received === u.undefined ? t = "Required" : t = `Expected ${s.expected}, received ${s.received}`;
|
|
274
|
+
break;
|
|
275
|
+
case d.invalid_literal:
|
|
276
|
+
t = `Invalid literal value, expected ${JSON.stringify(s.expected, _.jsonStringifyReplacer)}`;
|
|
277
|
+
break;
|
|
278
|
+
case d.unrecognized_keys:
|
|
279
|
+
t = `Unrecognized key(s) in object: ${_.joinValues(s.keys, ", ")}`;
|
|
280
|
+
break;
|
|
281
|
+
case d.invalid_union:
|
|
282
|
+
t = "Invalid input";
|
|
283
|
+
break;
|
|
284
|
+
case d.invalid_union_discriminator:
|
|
285
|
+
t = `Invalid discriminator value. Expected ${_.joinValues(s.options)}`;
|
|
286
|
+
break;
|
|
287
|
+
case d.invalid_enum_value:
|
|
288
|
+
t = `Invalid enum value. Expected ${_.joinValues(s.options)}, received '${s.received}'`;
|
|
289
|
+
break;
|
|
290
|
+
case d.invalid_arguments:
|
|
291
|
+
t = "Invalid function arguments";
|
|
292
|
+
break;
|
|
293
|
+
case d.invalid_return_type:
|
|
294
|
+
t = "Invalid function return type";
|
|
295
|
+
break;
|
|
296
|
+
case d.invalid_date:
|
|
297
|
+
t = "Invalid date";
|
|
298
|
+
break;
|
|
299
|
+
case d.invalid_string:
|
|
300
|
+
typeof s.validation == "object" ? "includes" in s.validation ? (t = `Invalid input: must include "${s.validation.includes}"`, typeof s.validation.position == "number" && (t = `${t} at one or more positions greater than or equal to ${s.validation.position}`)) : "startsWith" in s.validation ? t = `Invalid input: must start with "${s.validation.startsWith}"` : "endsWith" in s.validation ? t = `Invalid input: must end with "${s.validation.endsWith}"` : _.assertNever(s.validation) : s.validation !== "regex" ? t = `Invalid ${s.validation}` : t = "Invalid";
|
|
301
|
+
break;
|
|
302
|
+
case d.too_small:
|
|
303
|
+
s.type === "array" ? t = `Array must contain ${s.exact ? "exactly" : s.inclusive ? "at least" : "more than"} ${s.minimum} element(s)` : s.type === "string" ? t = `String must contain ${s.exact ? "exactly" : s.inclusive ? "at least" : "over"} ${s.minimum} character(s)` : s.type === "number" ? t = `Number must be ${s.exact ? "exactly equal to " : s.inclusive ? "greater than or equal to " : "greater than "}${s.minimum}` : s.type === "date" ? t = `Date must be ${s.exact ? "exactly equal to " : s.inclusive ? "greater than or equal to " : "greater than "}${new Date(Number(s.minimum))}` : t = "Invalid input";
|
|
304
|
+
break;
|
|
305
|
+
case d.too_big:
|
|
306
|
+
s.type === "array" ? t = `Array must contain ${s.exact ? "exactly" : s.inclusive ? "at most" : "less than"} ${s.maximum} element(s)` : s.type === "string" ? t = `String must contain ${s.exact ? "exactly" : s.inclusive ? "at most" : "under"} ${s.maximum} character(s)` : s.type === "number" ? t = `Number must be ${s.exact ? "exactly" : s.inclusive ? "less than or equal to" : "less than"} ${s.maximum}` : s.type === "bigint" ? t = `BigInt must be ${s.exact ? "exactly" : s.inclusive ? "less than or equal to" : "less than"} ${s.maximum}` : s.type === "date" ? t = `Date must be ${s.exact ? "exactly" : s.inclusive ? "smaller than or equal to" : "smaller than"} ${new Date(Number(s.maximum))}` : t = "Invalid input";
|
|
307
|
+
break;
|
|
308
|
+
case d.custom:
|
|
309
|
+
t = "Invalid input";
|
|
310
|
+
break;
|
|
311
|
+
case d.invalid_intersection_types:
|
|
312
|
+
t = "Intersection results could not be merged";
|
|
313
|
+
break;
|
|
314
|
+
case d.not_multiple_of:
|
|
315
|
+
t = `Number must be a multiple of ${s.multipleOf}`;
|
|
316
|
+
break;
|
|
317
|
+
case d.not_finite:
|
|
318
|
+
t = "Number must be finite";
|
|
319
|
+
break;
|
|
320
|
+
default:
|
|
321
|
+
t = e.defaultError, _.assertNever(s);
|
|
322
|
+
}
|
|
323
|
+
return { message: t };
|
|
324
|
+
};
|
|
325
|
+
let Ve = X;
|
|
326
|
+
function Le() {
|
|
327
|
+
return Ve;
|
|
328
|
+
}
|
|
329
|
+
const Pe = (s) => {
|
|
330
|
+
const { data: e, path: t, errorMaps: r, issueData: a } = s, n = [...t, ...a.path || []], i = {
|
|
331
|
+
...a,
|
|
332
|
+
path: n
|
|
333
|
+
};
|
|
334
|
+
if (a.message !== void 0)
|
|
335
|
+
return {
|
|
336
|
+
...a,
|
|
337
|
+
path: n,
|
|
338
|
+
message: a.message
|
|
339
|
+
};
|
|
340
|
+
let o = "";
|
|
341
|
+
const f = r.filter((h) => !!h).slice().reverse();
|
|
342
|
+
for (const h of f)
|
|
343
|
+
o = h(i, { data: e, defaultError: o }).message;
|
|
344
|
+
return {
|
|
345
|
+
...a,
|
|
346
|
+
path: n,
|
|
347
|
+
message: o
|
|
348
|
+
};
|
|
349
|
+
};
|
|
350
|
+
function c(s, e) {
|
|
351
|
+
const t = Le(), r = Pe({
|
|
352
|
+
issueData: e,
|
|
353
|
+
data: s.data,
|
|
354
|
+
path: s.path,
|
|
355
|
+
errorMaps: [
|
|
356
|
+
s.common.contextualErrorMap,
|
|
357
|
+
// contextual error map is first priority
|
|
358
|
+
s.schemaErrorMap,
|
|
359
|
+
// then schema-bound map if available
|
|
360
|
+
t,
|
|
361
|
+
// then global override map
|
|
362
|
+
t === X ? void 0 : X
|
|
363
|
+
// then global default map
|
|
364
|
+
].filter((a) => !!a)
|
|
365
|
+
});
|
|
366
|
+
s.common.issues.push(r);
|
|
367
|
+
}
|
|
368
|
+
class b {
|
|
369
|
+
constructor() {
|
|
370
|
+
this.value = "valid";
|
|
371
|
+
}
|
|
372
|
+
dirty() {
|
|
373
|
+
this.value === "valid" && (this.value = "dirty");
|
|
374
|
+
}
|
|
375
|
+
abort() {
|
|
376
|
+
this.value !== "aborted" && (this.value = "aborted");
|
|
377
|
+
}
|
|
378
|
+
static mergeArray(e, t) {
|
|
379
|
+
const r = [];
|
|
380
|
+
for (const a of t) {
|
|
381
|
+
if (a.status === "aborted")
|
|
382
|
+
return m;
|
|
383
|
+
a.status === "dirty" && e.dirty(), r.push(a.value);
|
|
384
|
+
}
|
|
385
|
+
return { status: e.value, value: r };
|
|
386
|
+
}
|
|
387
|
+
static async mergeObjectAsync(e, t) {
|
|
388
|
+
const r = [];
|
|
389
|
+
for (const a of t) {
|
|
390
|
+
const n = await a.key, i = await a.value;
|
|
391
|
+
r.push({
|
|
392
|
+
key: n,
|
|
393
|
+
value: i
|
|
394
|
+
});
|
|
395
|
+
}
|
|
396
|
+
return b.mergeObjectSync(e, r);
|
|
397
|
+
}
|
|
398
|
+
static mergeObjectSync(e, t) {
|
|
399
|
+
const r = {};
|
|
400
|
+
for (const a of t) {
|
|
401
|
+
const { key: n, value: i } = a;
|
|
402
|
+
if (n.status === "aborted" || i.status === "aborted")
|
|
403
|
+
return m;
|
|
404
|
+
n.status === "dirty" && e.dirty(), i.status === "dirty" && e.dirty(), n.value !== "__proto__" && (typeof i.value < "u" || a.alwaysSet) && (r[n.value] = i.value);
|
|
405
|
+
}
|
|
406
|
+
return { status: e.value, value: r };
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
const m = Object.freeze({
|
|
410
|
+
status: "aborted"
|
|
411
|
+
}), z = (s) => ({ status: "dirty", value: s }), w = (s) => ({ status: "valid", value: s }), ne = (s) => s.status === "aborted", ie = (s) => s.status === "dirty", j = (s) => s.status === "valid", F = (s) => typeof Promise < "u" && s instanceof Promise;
|
|
412
|
+
var l;
|
|
413
|
+
(function(s) {
|
|
414
|
+
s.errToObj = (e) => typeof e == "string" ? { message: e } : e || {}, s.toString = (e) => typeof e == "string" ? e : e?.message;
|
|
415
|
+
})(l || (l = {}));
|
|
416
|
+
class A {
|
|
417
|
+
constructor(e, t, r, a) {
|
|
418
|
+
this._cachedPath = [], this.parent = e, this.data = t, this._path = r, this._key = a;
|
|
419
|
+
}
|
|
420
|
+
get path() {
|
|
421
|
+
return this._cachedPath.length || (Array.isArray(this._key) ? this._cachedPath.push(...this._path, ...this._key) : this._cachedPath.push(...this._path, this._key)), this._cachedPath;
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
const oe = (s, e) => {
|
|
425
|
+
if (j(e))
|
|
426
|
+
return { success: !0, data: e.value };
|
|
427
|
+
if (!s.common.issues.length)
|
|
428
|
+
throw new Error("Validation failed but no issues detected.");
|
|
429
|
+
return {
|
|
430
|
+
success: !1,
|
|
431
|
+
get error() {
|
|
432
|
+
if (this._error)
|
|
433
|
+
return this._error;
|
|
434
|
+
const t = new T(s.common.issues);
|
|
435
|
+
return this._error = t, this._error;
|
|
436
|
+
}
|
|
437
|
+
};
|
|
438
|
+
};
|
|
439
|
+
function g(s) {
|
|
440
|
+
if (!s)
|
|
441
|
+
return {};
|
|
442
|
+
const { errorMap: e, invalid_type_error: t, required_error: r, description: a } = s;
|
|
443
|
+
if (e && (t || r))
|
|
444
|
+
throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);
|
|
445
|
+
return e ? { errorMap: e, description: a } : { errorMap: (i, o) => {
|
|
446
|
+
const { message: f } = s;
|
|
447
|
+
return i.code === "invalid_enum_value" ? { message: f ?? o.defaultError } : typeof o.data > "u" ? { message: f ?? r ?? o.defaultError } : i.code !== "invalid_type" ? { message: o.defaultError } : { message: f ?? t ?? o.defaultError };
|
|
448
|
+
}, description: a };
|
|
449
|
+
}
|
|
450
|
+
class y {
|
|
451
|
+
get description() {
|
|
452
|
+
return this._def.description;
|
|
453
|
+
}
|
|
454
|
+
_getType(e) {
|
|
455
|
+
return S(e.data);
|
|
456
|
+
}
|
|
457
|
+
_getOrReturnCtx(e, t) {
|
|
458
|
+
return t || {
|
|
459
|
+
common: e.parent.common,
|
|
460
|
+
data: e.data,
|
|
461
|
+
parsedType: S(e.data),
|
|
462
|
+
schemaErrorMap: this._def.errorMap,
|
|
463
|
+
path: e.path,
|
|
464
|
+
parent: e.parent
|
|
465
|
+
};
|
|
466
|
+
}
|
|
467
|
+
_processInputParams(e) {
|
|
468
|
+
return {
|
|
469
|
+
status: new b(),
|
|
470
|
+
ctx: {
|
|
471
|
+
common: e.parent.common,
|
|
472
|
+
data: e.data,
|
|
473
|
+
parsedType: S(e.data),
|
|
474
|
+
schemaErrorMap: this._def.errorMap,
|
|
475
|
+
path: e.path,
|
|
476
|
+
parent: e.parent
|
|
477
|
+
}
|
|
478
|
+
};
|
|
479
|
+
}
|
|
480
|
+
_parseSync(e) {
|
|
481
|
+
const t = this._parse(e);
|
|
482
|
+
if (F(t))
|
|
483
|
+
throw new Error("Synchronous parse encountered promise.");
|
|
484
|
+
return t;
|
|
485
|
+
}
|
|
486
|
+
_parseAsync(e) {
|
|
487
|
+
const t = this._parse(e);
|
|
488
|
+
return Promise.resolve(t);
|
|
489
|
+
}
|
|
490
|
+
parse(e, t) {
|
|
491
|
+
const r = this.safeParse(e, t);
|
|
492
|
+
if (r.success)
|
|
493
|
+
return r.data;
|
|
494
|
+
throw r.error;
|
|
495
|
+
}
|
|
496
|
+
safeParse(e, t) {
|
|
497
|
+
const r = {
|
|
498
|
+
common: {
|
|
499
|
+
issues: [],
|
|
500
|
+
async: t?.async ?? !1,
|
|
501
|
+
contextualErrorMap: t?.errorMap
|
|
502
|
+
},
|
|
503
|
+
path: t?.path || [],
|
|
504
|
+
schemaErrorMap: this._def.errorMap,
|
|
505
|
+
parent: null,
|
|
506
|
+
data: e,
|
|
507
|
+
parsedType: S(e)
|
|
508
|
+
}, a = this._parseSync({ data: e, path: r.path, parent: r });
|
|
509
|
+
return oe(r, a);
|
|
510
|
+
}
|
|
511
|
+
"~validate"(e) {
|
|
512
|
+
const t = {
|
|
513
|
+
common: {
|
|
514
|
+
issues: [],
|
|
515
|
+
async: !!this["~standard"].async
|
|
516
|
+
},
|
|
517
|
+
path: [],
|
|
518
|
+
schemaErrorMap: this._def.errorMap,
|
|
519
|
+
parent: null,
|
|
520
|
+
data: e,
|
|
521
|
+
parsedType: S(e)
|
|
522
|
+
};
|
|
523
|
+
if (!this["~standard"].async)
|
|
524
|
+
try {
|
|
525
|
+
const r = this._parseSync({ data: e, path: [], parent: t });
|
|
526
|
+
return j(r) ? {
|
|
527
|
+
value: r.value
|
|
528
|
+
} : {
|
|
529
|
+
issues: t.common.issues
|
|
530
|
+
};
|
|
531
|
+
} catch (r) {
|
|
532
|
+
r?.message?.toLowerCase()?.includes("encountered") && (this["~standard"].async = !0), t.common = {
|
|
533
|
+
issues: [],
|
|
534
|
+
async: !0
|
|
535
|
+
};
|
|
536
|
+
}
|
|
537
|
+
return this._parseAsync({ data: e, path: [], parent: t }).then((r) => j(r) ? {
|
|
538
|
+
value: r.value
|
|
539
|
+
} : {
|
|
540
|
+
issues: t.common.issues
|
|
541
|
+
});
|
|
542
|
+
}
|
|
543
|
+
async parseAsync(e, t) {
|
|
544
|
+
const r = await this.safeParseAsync(e, t);
|
|
545
|
+
if (r.success)
|
|
546
|
+
return r.data;
|
|
547
|
+
throw r.error;
|
|
548
|
+
}
|
|
549
|
+
async safeParseAsync(e, t) {
|
|
550
|
+
const r = {
|
|
551
|
+
common: {
|
|
552
|
+
issues: [],
|
|
553
|
+
contextualErrorMap: t?.errorMap,
|
|
554
|
+
async: !0
|
|
555
|
+
},
|
|
556
|
+
path: t?.path || [],
|
|
557
|
+
schemaErrorMap: this._def.errorMap,
|
|
558
|
+
parent: null,
|
|
559
|
+
data: e,
|
|
560
|
+
parsedType: S(e)
|
|
561
|
+
}, a = this._parse({ data: e, path: r.path, parent: r }), n = await (F(a) ? a : Promise.resolve(a));
|
|
562
|
+
return oe(r, n);
|
|
563
|
+
}
|
|
564
|
+
refine(e, t) {
|
|
565
|
+
const r = (a) => typeof t == "string" || typeof t > "u" ? { message: t } : typeof t == "function" ? t(a) : t;
|
|
566
|
+
return this._refinement((a, n) => {
|
|
567
|
+
const i = e(a), o = () => n.addIssue({
|
|
568
|
+
code: d.custom,
|
|
569
|
+
...r(a)
|
|
570
|
+
});
|
|
571
|
+
return typeof Promise < "u" && i instanceof Promise ? i.then((f) => f ? !0 : (o(), !1)) : i ? !0 : (o(), !1);
|
|
572
|
+
});
|
|
573
|
+
}
|
|
574
|
+
refinement(e, t) {
|
|
575
|
+
return this._refinement((r, a) => e(r) ? !0 : (a.addIssue(typeof t == "function" ? t(r, a) : t), !1));
|
|
576
|
+
}
|
|
577
|
+
_refinement(e) {
|
|
578
|
+
return new L({
|
|
579
|
+
schema: this,
|
|
580
|
+
typeName: p.ZodEffects,
|
|
581
|
+
effect: { type: "refinement", refinement: e }
|
|
582
|
+
});
|
|
583
|
+
}
|
|
584
|
+
superRefine(e) {
|
|
585
|
+
return this._refinement(e);
|
|
586
|
+
}
|
|
587
|
+
constructor(e) {
|
|
588
|
+
this.spa = this.safeParseAsync, this._def = e, this.parse = this.parse.bind(this), this.safeParse = this.safeParse.bind(this), this.parseAsync = this.parseAsync.bind(this), this.safeParseAsync = this.safeParseAsync.bind(this), this.spa = this.spa.bind(this), this.refine = this.refine.bind(this), this.refinement = this.refinement.bind(this), this.superRefine = this.superRefine.bind(this), this.optional = this.optional.bind(this), this.nullable = this.nullable.bind(this), this.nullish = this.nullish.bind(this), this.array = this.array.bind(this), this.promise = this.promise.bind(this), this.or = this.or.bind(this), this.and = this.and.bind(this), this.transform = this.transform.bind(this), this.brand = this.brand.bind(this), this.default = this.default.bind(this), this.catch = this.catch.bind(this), this.describe = this.describe.bind(this), this.pipe = this.pipe.bind(this), this.readonly = this.readonly.bind(this), this.isNullable = this.isNullable.bind(this), this.isOptional = this.isOptional.bind(this), this["~standard"] = {
|
|
589
|
+
version: 1,
|
|
590
|
+
vendor: "zod",
|
|
591
|
+
validate: (t) => this["~validate"](t)
|
|
592
|
+
};
|
|
593
|
+
}
|
|
594
|
+
optional() {
|
|
595
|
+
return O.create(this, this._def);
|
|
596
|
+
}
|
|
597
|
+
nullable() {
|
|
598
|
+
return P.create(this, this._def);
|
|
599
|
+
}
|
|
600
|
+
nullish() {
|
|
601
|
+
return this.nullable().optional();
|
|
602
|
+
}
|
|
603
|
+
array() {
|
|
604
|
+
return C.create(this);
|
|
605
|
+
}
|
|
606
|
+
promise() {
|
|
607
|
+
return H.create(this, this._def);
|
|
608
|
+
}
|
|
609
|
+
or(e) {
|
|
610
|
+
return q.create([this, e], this._def);
|
|
611
|
+
}
|
|
612
|
+
and(e) {
|
|
613
|
+
return J.create(this, e, this._def);
|
|
614
|
+
}
|
|
615
|
+
transform(e) {
|
|
616
|
+
return new L({
|
|
617
|
+
...g(this._def),
|
|
618
|
+
schema: this,
|
|
619
|
+
typeName: p.ZodEffects,
|
|
620
|
+
effect: { type: "transform", transform: e }
|
|
621
|
+
});
|
|
622
|
+
}
|
|
623
|
+
default(e) {
|
|
624
|
+
const t = typeof e == "function" ? e : () => e;
|
|
625
|
+
return new K({
|
|
626
|
+
...g(this._def),
|
|
627
|
+
innerType: this,
|
|
628
|
+
defaultValue: t,
|
|
629
|
+
typeName: p.ZodDefault
|
|
630
|
+
});
|
|
631
|
+
}
|
|
632
|
+
brand() {
|
|
633
|
+
return new ot({
|
|
634
|
+
typeName: p.ZodBranded,
|
|
635
|
+
type: this,
|
|
636
|
+
...g(this._def)
|
|
637
|
+
});
|
|
638
|
+
}
|
|
639
|
+
catch(e) {
|
|
640
|
+
const t = typeof e == "function" ? e : () => e;
|
|
641
|
+
return new ee({
|
|
642
|
+
...g(this._def),
|
|
643
|
+
innerType: this,
|
|
644
|
+
catchValue: t,
|
|
645
|
+
typeName: p.ZodCatch
|
|
646
|
+
});
|
|
647
|
+
}
|
|
648
|
+
describe(e) {
|
|
649
|
+
const t = this.constructor;
|
|
650
|
+
return new t({
|
|
651
|
+
...this._def,
|
|
652
|
+
description: e
|
|
653
|
+
});
|
|
654
|
+
}
|
|
655
|
+
pipe(e) {
|
|
656
|
+
return se.create(this, e);
|
|
657
|
+
}
|
|
658
|
+
readonly() {
|
|
659
|
+
return te.create(this);
|
|
660
|
+
}
|
|
661
|
+
isOptional() {
|
|
662
|
+
return this.safeParse(void 0).success;
|
|
663
|
+
}
|
|
664
|
+
isNullable() {
|
|
665
|
+
return this.safeParse(null).success;
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
const De = /^c[^\s-]{8,}$/i, Me = /^[0-9a-z]+$/, ze = /^[0-9A-HJKMNP-TV-Z]{26}$/i, Ue = /^[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, Be = /^[a-z0-9_-]{21}$/i, Fe = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/, We = /^[-+]?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)?)??$/, qe = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i, Je = "^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";
|
|
669
|
+
let Q;
|
|
670
|
+
const He = /^(?:(?: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])$/, Ye = /^(?:(?: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])$/, Qe = /^(([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]))$/, Xe = /^(([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])$/, Ge = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/, Ke = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/, ke = "((\\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])))", et = new RegExp(`^${ke}$`);
|
|
671
|
+
function be(s) {
|
|
672
|
+
let e = "[0-5]\\d";
|
|
673
|
+
s.precision ? e = `${e}\\.\\d{${s.precision}}` : s.precision == null && (e = `${e}(\\.\\d+)?`);
|
|
674
|
+
const t = s.precision ? "+" : "?";
|
|
675
|
+
return `([01]\\d|2[0-3]):[0-5]\\d(:${e})${t}`;
|
|
676
|
+
}
|
|
677
|
+
function tt(s) {
|
|
678
|
+
return new RegExp(`^${be(s)}$`);
|
|
679
|
+
}
|
|
680
|
+
function st(s) {
|
|
681
|
+
let e = `${ke}T${be(s)}`;
|
|
682
|
+
const t = [];
|
|
683
|
+
return t.push(s.local ? "Z?" : "Z"), s.offset && t.push("([+-]\\d{2}:?\\d{2})"), e = `${e}(${t.join("|")})`, new RegExp(`^${e}$`);
|
|
684
|
+
}
|
|
685
|
+
function rt(s, e) {
|
|
686
|
+
return !!((e === "v4" || !e) && He.test(s) || (e === "v6" || !e) && Qe.test(s));
|
|
687
|
+
}
|
|
688
|
+
function at(s, e) {
|
|
689
|
+
if (!Fe.test(s))
|
|
690
|
+
return !1;
|
|
691
|
+
try {
|
|
692
|
+
const [t] = s.split("."), r = t.replace(/-/g, "+").replace(/_/g, "/").padEnd(t.length + (4 - t.length % 4) % 4, "="), a = JSON.parse(atob(r));
|
|
693
|
+
return !(typeof a != "object" || a === null || "typ" in a && a?.typ !== "JWT" || !a.alg || e && a.alg !== e);
|
|
694
|
+
} catch {
|
|
695
|
+
return !1;
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
function nt(s, e) {
|
|
699
|
+
return !!((e === "v4" || !e) && Ye.test(s) || (e === "v6" || !e) && Xe.test(s));
|
|
700
|
+
}
|
|
701
|
+
class R extends y {
|
|
702
|
+
_parse(e) {
|
|
703
|
+
if (this._def.coerce && (e.data = String(e.data)), this._getType(e) !== u.string) {
|
|
704
|
+
const n = this._getOrReturnCtx(e);
|
|
705
|
+
return c(n, {
|
|
706
|
+
code: d.invalid_type,
|
|
707
|
+
expected: u.string,
|
|
708
|
+
received: n.parsedType
|
|
709
|
+
}), m;
|
|
710
|
+
}
|
|
711
|
+
const r = new b();
|
|
712
|
+
let a;
|
|
713
|
+
for (const n of this._def.checks)
|
|
714
|
+
if (n.kind === "min")
|
|
715
|
+
e.data.length < n.value && (a = this._getOrReturnCtx(e, a), c(a, {
|
|
716
|
+
code: d.too_small,
|
|
717
|
+
minimum: n.value,
|
|
718
|
+
type: "string",
|
|
719
|
+
inclusive: !0,
|
|
720
|
+
exact: !1,
|
|
721
|
+
message: n.message
|
|
722
|
+
}), r.dirty());
|
|
723
|
+
else if (n.kind === "max")
|
|
724
|
+
e.data.length > n.value && (a = this._getOrReturnCtx(e, a), c(a, {
|
|
725
|
+
code: d.too_big,
|
|
726
|
+
maximum: n.value,
|
|
727
|
+
type: "string",
|
|
728
|
+
inclusive: !0,
|
|
729
|
+
exact: !1,
|
|
730
|
+
message: n.message
|
|
731
|
+
}), r.dirty());
|
|
732
|
+
else if (n.kind === "length") {
|
|
733
|
+
const i = e.data.length > n.value, o = e.data.length < n.value;
|
|
734
|
+
(i || o) && (a = this._getOrReturnCtx(e, a), i ? c(a, {
|
|
735
|
+
code: d.too_big,
|
|
736
|
+
maximum: n.value,
|
|
737
|
+
type: "string",
|
|
738
|
+
inclusive: !0,
|
|
739
|
+
exact: !0,
|
|
740
|
+
message: n.message
|
|
741
|
+
}) : o && c(a, {
|
|
742
|
+
code: d.too_small,
|
|
743
|
+
minimum: n.value,
|
|
744
|
+
type: "string",
|
|
745
|
+
inclusive: !0,
|
|
746
|
+
exact: !0,
|
|
747
|
+
message: n.message
|
|
748
|
+
}), r.dirty());
|
|
749
|
+
} else if (n.kind === "email")
|
|
750
|
+
qe.test(e.data) || (a = this._getOrReturnCtx(e, a), c(a, {
|
|
751
|
+
validation: "email",
|
|
752
|
+
code: d.invalid_string,
|
|
753
|
+
message: n.message
|
|
754
|
+
}), r.dirty());
|
|
755
|
+
else if (n.kind === "emoji")
|
|
756
|
+
Q || (Q = new RegExp(Je, "u")), Q.test(e.data) || (a = this._getOrReturnCtx(e, a), c(a, {
|
|
757
|
+
validation: "emoji",
|
|
758
|
+
code: d.invalid_string,
|
|
759
|
+
message: n.message
|
|
760
|
+
}), r.dirty());
|
|
761
|
+
else if (n.kind === "uuid")
|
|
762
|
+
Ue.test(e.data) || (a = this._getOrReturnCtx(e, a), c(a, {
|
|
763
|
+
validation: "uuid",
|
|
764
|
+
code: d.invalid_string,
|
|
765
|
+
message: n.message
|
|
766
|
+
}), r.dirty());
|
|
767
|
+
else if (n.kind === "nanoid")
|
|
768
|
+
Be.test(e.data) || (a = this._getOrReturnCtx(e, a), c(a, {
|
|
769
|
+
validation: "nanoid",
|
|
770
|
+
code: d.invalid_string,
|
|
771
|
+
message: n.message
|
|
772
|
+
}), r.dirty());
|
|
773
|
+
else if (n.kind === "cuid")
|
|
774
|
+
De.test(e.data) || (a = this._getOrReturnCtx(e, a), c(a, {
|
|
775
|
+
validation: "cuid",
|
|
776
|
+
code: d.invalid_string,
|
|
777
|
+
message: n.message
|
|
778
|
+
}), r.dirty());
|
|
779
|
+
else if (n.kind === "cuid2")
|
|
780
|
+
Me.test(e.data) || (a = this._getOrReturnCtx(e, a), c(a, {
|
|
781
|
+
validation: "cuid2",
|
|
782
|
+
code: d.invalid_string,
|
|
783
|
+
message: n.message
|
|
784
|
+
}), r.dirty());
|
|
785
|
+
else if (n.kind === "ulid")
|
|
786
|
+
ze.test(e.data) || (a = this._getOrReturnCtx(e, a), c(a, {
|
|
787
|
+
validation: "ulid",
|
|
788
|
+
code: d.invalid_string,
|
|
789
|
+
message: n.message
|
|
790
|
+
}), r.dirty());
|
|
791
|
+
else if (n.kind === "url")
|
|
792
|
+
try {
|
|
793
|
+
new URL(e.data);
|
|
794
|
+
} catch {
|
|
795
|
+
a = this._getOrReturnCtx(e, a), c(a, {
|
|
796
|
+
validation: "url",
|
|
797
|
+
code: d.invalid_string,
|
|
798
|
+
message: n.message
|
|
799
|
+
}), r.dirty();
|
|
800
|
+
}
|
|
801
|
+
else n.kind === "regex" ? (n.regex.lastIndex = 0, n.regex.test(e.data) || (a = this._getOrReturnCtx(e, a), c(a, {
|
|
802
|
+
validation: "regex",
|
|
803
|
+
code: d.invalid_string,
|
|
804
|
+
message: n.message
|
|
805
|
+
}), r.dirty())) : n.kind === "trim" ? e.data = e.data.trim() : n.kind === "includes" ? e.data.includes(n.value, n.position) || (a = this._getOrReturnCtx(e, a), c(a, {
|
|
806
|
+
code: d.invalid_string,
|
|
807
|
+
validation: { includes: n.value, position: n.position },
|
|
808
|
+
message: n.message
|
|
809
|
+
}), r.dirty()) : n.kind === "toLowerCase" ? e.data = e.data.toLowerCase() : n.kind === "toUpperCase" ? e.data = e.data.toUpperCase() : n.kind === "startsWith" ? e.data.startsWith(n.value) || (a = this._getOrReturnCtx(e, a), c(a, {
|
|
810
|
+
code: d.invalid_string,
|
|
811
|
+
validation: { startsWith: n.value },
|
|
812
|
+
message: n.message
|
|
813
|
+
}), r.dirty()) : n.kind === "endsWith" ? e.data.endsWith(n.value) || (a = this._getOrReturnCtx(e, a), c(a, {
|
|
814
|
+
code: d.invalid_string,
|
|
815
|
+
validation: { endsWith: n.value },
|
|
816
|
+
message: n.message
|
|
817
|
+
}), r.dirty()) : n.kind === "datetime" ? st(n).test(e.data) || (a = this._getOrReturnCtx(e, a), c(a, {
|
|
818
|
+
code: d.invalid_string,
|
|
819
|
+
validation: "datetime",
|
|
820
|
+
message: n.message
|
|
821
|
+
}), r.dirty()) : n.kind === "date" ? et.test(e.data) || (a = this._getOrReturnCtx(e, a), c(a, {
|
|
822
|
+
code: d.invalid_string,
|
|
823
|
+
validation: "date",
|
|
824
|
+
message: n.message
|
|
825
|
+
}), r.dirty()) : n.kind === "time" ? tt(n).test(e.data) || (a = this._getOrReturnCtx(e, a), c(a, {
|
|
826
|
+
code: d.invalid_string,
|
|
827
|
+
validation: "time",
|
|
828
|
+
message: n.message
|
|
829
|
+
}), r.dirty()) : n.kind === "duration" ? We.test(e.data) || (a = this._getOrReturnCtx(e, a), c(a, {
|
|
830
|
+
validation: "duration",
|
|
831
|
+
code: d.invalid_string,
|
|
832
|
+
message: n.message
|
|
833
|
+
}), r.dirty()) : n.kind === "ip" ? rt(e.data, n.version) || (a = this._getOrReturnCtx(e, a), c(a, {
|
|
834
|
+
validation: "ip",
|
|
835
|
+
code: d.invalid_string,
|
|
836
|
+
message: n.message
|
|
837
|
+
}), r.dirty()) : n.kind === "jwt" ? at(e.data, n.alg) || (a = this._getOrReturnCtx(e, a), c(a, {
|
|
838
|
+
validation: "jwt",
|
|
839
|
+
code: d.invalid_string,
|
|
840
|
+
message: n.message
|
|
841
|
+
}), r.dirty()) : n.kind === "cidr" ? nt(e.data, n.version) || (a = this._getOrReturnCtx(e, a), c(a, {
|
|
842
|
+
validation: "cidr",
|
|
843
|
+
code: d.invalid_string,
|
|
844
|
+
message: n.message
|
|
845
|
+
}), r.dirty()) : n.kind === "base64" ? Ge.test(e.data) || (a = this._getOrReturnCtx(e, a), c(a, {
|
|
846
|
+
validation: "base64",
|
|
847
|
+
code: d.invalid_string,
|
|
848
|
+
message: n.message
|
|
849
|
+
}), r.dirty()) : n.kind === "base64url" ? Ke.test(e.data) || (a = this._getOrReturnCtx(e, a), c(a, {
|
|
850
|
+
validation: "base64url",
|
|
851
|
+
code: d.invalid_string,
|
|
852
|
+
message: n.message
|
|
853
|
+
}), r.dirty()) : _.assertNever(n);
|
|
854
|
+
return { status: r.value, value: e.data };
|
|
855
|
+
}
|
|
856
|
+
_regex(e, t, r) {
|
|
857
|
+
return this.refinement((a) => e.test(a), {
|
|
858
|
+
validation: t,
|
|
859
|
+
code: d.invalid_string,
|
|
860
|
+
...l.errToObj(r)
|
|
861
|
+
});
|
|
862
|
+
}
|
|
863
|
+
_addCheck(e) {
|
|
864
|
+
return new R({
|
|
865
|
+
...this._def,
|
|
866
|
+
checks: [...this._def.checks, e]
|
|
867
|
+
});
|
|
868
|
+
}
|
|
869
|
+
email(e) {
|
|
870
|
+
return this._addCheck({ kind: "email", ...l.errToObj(e) });
|
|
871
|
+
}
|
|
872
|
+
url(e) {
|
|
873
|
+
return this._addCheck({ kind: "url", ...l.errToObj(e) });
|
|
874
|
+
}
|
|
875
|
+
emoji(e) {
|
|
876
|
+
return this._addCheck({ kind: "emoji", ...l.errToObj(e) });
|
|
877
|
+
}
|
|
878
|
+
uuid(e) {
|
|
879
|
+
return this._addCheck({ kind: "uuid", ...l.errToObj(e) });
|
|
880
|
+
}
|
|
881
|
+
nanoid(e) {
|
|
882
|
+
return this._addCheck({ kind: "nanoid", ...l.errToObj(e) });
|
|
883
|
+
}
|
|
884
|
+
cuid(e) {
|
|
885
|
+
return this._addCheck({ kind: "cuid", ...l.errToObj(e) });
|
|
886
|
+
}
|
|
887
|
+
cuid2(e) {
|
|
888
|
+
return this._addCheck({ kind: "cuid2", ...l.errToObj(e) });
|
|
889
|
+
}
|
|
890
|
+
ulid(e) {
|
|
891
|
+
return this._addCheck({ kind: "ulid", ...l.errToObj(e) });
|
|
892
|
+
}
|
|
893
|
+
base64(e) {
|
|
894
|
+
return this._addCheck({ kind: "base64", ...l.errToObj(e) });
|
|
895
|
+
}
|
|
896
|
+
base64url(e) {
|
|
897
|
+
return this._addCheck({
|
|
898
|
+
kind: "base64url",
|
|
899
|
+
...l.errToObj(e)
|
|
900
|
+
});
|
|
901
|
+
}
|
|
902
|
+
jwt(e) {
|
|
903
|
+
return this._addCheck({ kind: "jwt", ...l.errToObj(e) });
|
|
904
|
+
}
|
|
905
|
+
ip(e) {
|
|
906
|
+
return this._addCheck({ kind: "ip", ...l.errToObj(e) });
|
|
907
|
+
}
|
|
908
|
+
cidr(e) {
|
|
909
|
+
return this._addCheck({ kind: "cidr", ...l.errToObj(e) });
|
|
910
|
+
}
|
|
911
|
+
datetime(e) {
|
|
912
|
+
return typeof e == "string" ? this._addCheck({
|
|
913
|
+
kind: "datetime",
|
|
914
|
+
precision: null,
|
|
915
|
+
offset: !1,
|
|
916
|
+
local: !1,
|
|
917
|
+
message: e
|
|
918
|
+
}) : this._addCheck({
|
|
919
|
+
kind: "datetime",
|
|
920
|
+
precision: typeof e?.precision > "u" ? null : e?.precision,
|
|
921
|
+
offset: e?.offset ?? !1,
|
|
922
|
+
local: e?.local ?? !1,
|
|
923
|
+
...l.errToObj(e?.message)
|
|
924
|
+
});
|
|
925
|
+
}
|
|
926
|
+
date(e) {
|
|
927
|
+
return this._addCheck({ kind: "date", message: e });
|
|
928
|
+
}
|
|
929
|
+
time(e) {
|
|
930
|
+
return typeof e == "string" ? this._addCheck({
|
|
931
|
+
kind: "time",
|
|
932
|
+
precision: null,
|
|
933
|
+
message: e
|
|
934
|
+
}) : this._addCheck({
|
|
935
|
+
kind: "time",
|
|
936
|
+
precision: typeof e?.precision > "u" ? null : e?.precision,
|
|
937
|
+
...l.errToObj(e?.message)
|
|
938
|
+
});
|
|
939
|
+
}
|
|
940
|
+
duration(e) {
|
|
941
|
+
return this._addCheck({ kind: "duration", ...l.errToObj(e) });
|
|
942
|
+
}
|
|
943
|
+
regex(e, t) {
|
|
944
|
+
return this._addCheck({
|
|
945
|
+
kind: "regex",
|
|
946
|
+
regex: e,
|
|
947
|
+
...l.errToObj(t)
|
|
948
|
+
});
|
|
949
|
+
}
|
|
950
|
+
includes(e, t) {
|
|
951
|
+
return this._addCheck({
|
|
952
|
+
kind: "includes",
|
|
953
|
+
value: e,
|
|
954
|
+
position: t?.position,
|
|
955
|
+
...l.errToObj(t?.message)
|
|
956
|
+
});
|
|
957
|
+
}
|
|
958
|
+
startsWith(e, t) {
|
|
959
|
+
return this._addCheck({
|
|
960
|
+
kind: "startsWith",
|
|
961
|
+
value: e,
|
|
962
|
+
...l.errToObj(t)
|
|
963
|
+
});
|
|
964
|
+
}
|
|
965
|
+
endsWith(e, t) {
|
|
966
|
+
return this._addCheck({
|
|
967
|
+
kind: "endsWith",
|
|
968
|
+
value: e,
|
|
969
|
+
...l.errToObj(t)
|
|
970
|
+
});
|
|
971
|
+
}
|
|
972
|
+
min(e, t) {
|
|
973
|
+
return this._addCheck({
|
|
974
|
+
kind: "min",
|
|
975
|
+
value: e,
|
|
976
|
+
...l.errToObj(t)
|
|
977
|
+
});
|
|
978
|
+
}
|
|
979
|
+
max(e, t) {
|
|
980
|
+
return this._addCheck({
|
|
981
|
+
kind: "max",
|
|
982
|
+
value: e,
|
|
983
|
+
...l.errToObj(t)
|
|
984
|
+
});
|
|
985
|
+
}
|
|
986
|
+
length(e, t) {
|
|
987
|
+
return this._addCheck({
|
|
988
|
+
kind: "length",
|
|
989
|
+
value: e,
|
|
990
|
+
...l.errToObj(t)
|
|
991
|
+
});
|
|
992
|
+
}
|
|
993
|
+
/**
|
|
994
|
+
* Equivalent to `.min(1)`
|
|
995
|
+
*/
|
|
996
|
+
nonempty(e) {
|
|
997
|
+
return this.min(1, l.errToObj(e));
|
|
998
|
+
}
|
|
999
|
+
trim() {
|
|
1000
|
+
return new R({
|
|
1001
|
+
...this._def,
|
|
1002
|
+
checks: [...this._def.checks, { kind: "trim" }]
|
|
1003
|
+
});
|
|
1004
|
+
}
|
|
1005
|
+
toLowerCase() {
|
|
1006
|
+
return new R({
|
|
1007
|
+
...this._def,
|
|
1008
|
+
checks: [...this._def.checks, { kind: "toLowerCase" }]
|
|
1009
|
+
});
|
|
1010
|
+
}
|
|
1011
|
+
toUpperCase() {
|
|
1012
|
+
return new R({
|
|
1013
|
+
...this._def,
|
|
1014
|
+
checks: [...this._def.checks, { kind: "toUpperCase" }]
|
|
1015
|
+
});
|
|
1016
|
+
}
|
|
1017
|
+
get isDatetime() {
|
|
1018
|
+
return !!this._def.checks.find((e) => e.kind === "datetime");
|
|
1019
|
+
}
|
|
1020
|
+
get isDate() {
|
|
1021
|
+
return !!this._def.checks.find((e) => e.kind === "date");
|
|
1022
|
+
}
|
|
1023
|
+
get isTime() {
|
|
1024
|
+
return !!this._def.checks.find((e) => e.kind === "time");
|
|
1025
|
+
}
|
|
1026
|
+
get isDuration() {
|
|
1027
|
+
return !!this._def.checks.find((e) => e.kind === "duration");
|
|
1028
|
+
}
|
|
1029
|
+
get isEmail() {
|
|
1030
|
+
return !!this._def.checks.find((e) => e.kind === "email");
|
|
1031
|
+
}
|
|
1032
|
+
get isURL() {
|
|
1033
|
+
return !!this._def.checks.find((e) => e.kind === "url");
|
|
1034
|
+
}
|
|
1035
|
+
get isEmoji() {
|
|
1036
|
+
return !!this._def.checks.find((e) => e.kind === "emoji");
|
|
1037
|
+
}
|
|
1038
|
+
get isUUID() {
|
|
1039
|
+
return !!this._def.checks.find((e) => e.kind === "uuid");
|
|
1040
|
+
}
|
|
1041
|
+
get isNANOID() {
|
|
1042
|
+
return !!this._def.checks.find((e) => e.kind === "nanoid");
|
|
1043
|
+
}
|
|
1044
|
+
get isCUID() {
|
|
1045
|
+
return !!this._def.checks.find((e) => e.kind === "cuid");
|
|
1046
|
+
}
|
|
1047
|
+
get isCUID2() {
|
|
1048
|
+
return !!this._def.checks.find((e) => e.kind === "cuid2");
|
|
1049
|
+
}
|
|
1050
|
+
get isULID() {
|
|
1051
|
+
return !!this._def.checks.find((e) => e.kind === "ulid");
|
|
1052
|
+
}
|
|
1053
|
+
get isIP() {
|
|
1054
|
+
return !!this._def.checks.find((e) => e.kind === "ip");
|
|
1055
|
+
}
|
|
1056
|
+
get isCIDR() {
|
|
1057
|
+
return !!this._def.checks.find((e) => e.kind === "cidr");
|
|
1058
|
+
}
|
|
1059
|
+
get isBase64() {
|
|
1060
|
+
return !!this._def.checks.find((e) => e.kind === "base64");
|
|
1061
|
+
}
|
|
1062
|
+
get isBase64url() {
|
|
1063
|
+
return !!this._def.checks.find((e) => e.kind === "base64url");
|
|
1064
|
+
}
|
|
1065
|
+
get minLength() {
|
|
1066
|
+
let e = null;
|
|
1067
|
+
for (const t of this._def.checks)
|
|
1068
|
+
t.kind === "min" && (e === null || t.value > e) && (e = t.value);
|
|
1069
|
+
return e;
|
|
1070
|
+
}
|
|
1071
|
+
get maxLength() {
|
|
1072
|
+
let e = null;
|
|
1073
|
+
for (const t of this._def.checks)
|
|
1074
|
+
t.kind === "max" && (e === null || t.value < e) && (e = t.value);
|
|
1075
|
+
return e;
|
|
1076
|
+
}
|
|
1077
|
+
}
|
|
1078
|
+
R.create = (s) => new R({
|
|
1079
|
+
checks: [],
|
|
1080
|
+
typeName: p.ZodString,
|
|
1081
|
+
coerce: s?.coerce ?? !1,
|
|
1082
|
+
...g(s)
|
|
1083
|
+
});
|
|
1084
|
+
function it(s, e) {
|
|
1085
|
+
const t = (s.toString().split(".")[1] || "").length, r = (e.toString().split(".")[1] || "").length, a = t > r ? t : r, n = Number.parseInt(s.toFixed(a).replace(".", "")), i = Number.parseInt(e.toFixed(a).replace(".", ""));
|
|
1086
|
+
return n % i / 10 ** a;
|
|
1087
|
+
}
|
|
1088
|
+
class $ extends y {
|
|
1089
|
+
constructor() {
|
|
1090
|
+
super(...arguments), this.min = this.gte, this.max = this.lte, this.step = this.multipleOf;
|
|
1091
|
+
}
|
|
1092
|
+
_parse(e) {
|
|
1093
|
+
if (this._def.coerce && (e.data = Number(e.data)), this._getType(e) !== u.number) {
|
|
1094
|
+
const n = this._getOrReturnCtx(e);
|
|
1095
|
+
return c(n, {
|
|
1096
|
+
code: d.invalid_type,
|
|
1097
|
+
expected: u.number,
|
|
1098
|
+
received: n.parsedType
|
|
1099
|
+
}), m;
|
|
1100
|
+
}
|
|
1101
|
+
let r;
|
|
1102
|
+
const a = new b();
|
|
1103
|
+
for (const n of this._def.checks)
|
|
1104
|
+
n.kind === "int" ? _.isInteger(e.data) || (r = this._getOrReturnCtx(e, r), c(r, {
|
|
1105
|
+
code: d.invalid_type,
|
|
1106
|
+
expected: "integer",
|
|
1107
|
+
received: "float",
|
|
1108
|
+
message: n.message
|
|
1109
|
+
}), a.dirty()) : n.kind === "min" ? (n.inclusive ? e.data < n.value : e.data <= n.value) && (r = this._getOrReturnCtx(e, r), c(r, {
|
|
1110
|
+
code: d.too_small,
|
|
1111
|
+
minimum: n.value,
|
|
1112
|
+
type: "number",
|
|
1113
|
+
inclusive: n.inclusive,
|
|
1114
|
+
exact: !1,
|
|
1115
|
+
message: n.message
|
|
1116
|
+
}), a.dirty()) : n.kind === "max" ? (n.inclusive ? e.data > n.value : e.data >= n.value) && (r = this._getOrReturnCtx(e, r), c(r, {
|
|
1117
|
+
code: d.too_big,
|
|
1118
|
+
maximum: n.value,
|
|
1119
|
+
type: "number",
|
|
1120
|
+
inclusive: n.inclusive,
|
|
1121
|
+
exact: !1,
|
|
1122
|
+
message: n.message
|
|
1123
|
+
}), a.dirty()) : n.kind === "multipleOf" ? it(e.data, n.value) !== 0 && (r = this._getOrReturnCtx(e, r), c(r, {
|
|
1124
|
+
code: d.not_multiple_of,
|
|
1125
|
+
multipleOf: n.value,
|
|
1126
|
+
message: n.message
|
|
1127
|
+
}), a.dirty()) : n.kind === "finite" ? Number.isFinite(e.data) || (r = this._getOrReturnCtx(e, r), c(r, {
|
|
1128
|
+
code: d.not_finite,
|
|
1129
|
+
message: n.message
|
|
1130
|
+
}), a.dirty()) : _.assertNever(n);
|
|
1131
|
+
return { status: a.value, value: e.data };
|
|
1132
|
+
}
|
|
1133
|
+
gte(e, t) {
|
|
1134
|
+
return this.setLimit("min", e, !0, l.toString(t));
|
|
1135
|
+
}
|
|
1136
|
+
gt(e, t) {
|
|
1137
|
+
return this.setLimit("min", e, !1, l.toString(t));
|
|
1138
|
+
}
|
|
1139
|
+
lte(e, t) {
|
|
1140
|
+
return this.setLimit("max", e, !0, l.toString(t));
|
|
1141
|
+
}
|
|
1142
|
+
lt(e, t) {
|
|
1143
|
+
return this.setLimit("max", e, !1, l.toString(t));
|
|
1144
|
+
}
|
|
1145
|
+
setLimit(e, t, r, a) {
|
|
1146
|
+
return new $({
|
|
1147
|
+
...this._def,
|
|
1148
|
+
checks: [
|
|
1149
|
+
...this._def.checks,
|
|
1150
|
+
{
|
|
1151
|
+
kind: e,
|
|
1152
|
+
value: t,
|
|
1153
|
+
inclusive: r,
|
|
1154
|
+
message: l.toString(a)
|
|
1155
|
+
}
|
|
1156
|
+
]
|
|
1157
|
+
});
|
|
1158
|
+
}
|
|
1159
|
+
_addCheck(e) {
|
|
1160
|
+
return new $({
|
|
1161
|
+
...this._def,
|
|
1162
|
+
checks: [...this._def.checks, e]
|
|
1163
|
+
});
|
|
1164
|
+
}
|
|
1165
|
+
int(e) {
|
|
1166
|
+
return this._addCheck({
|
|
1167
|
+
kind: "int",
|
|
1168
|
+
message: l.toString(e)
|
|
1169
|
+
});
|
|
1170
|
+
}
|
|
1171
|
+
positive(e) {
|
|
1172
|
+
return this._addCheck({
|
|
1173
|
+
kind: "min",
|
|
1174
|
+
value: 0,
|
|
1175
|
+
inclusive: !1,
|
|
1176
|
+
message: l.toString(e)
|
|
1177
|
+
});
|
|
1178
|
+
}
|
|
1179
|
+
negative(e) {
|
|
1180
|
+
return this._addCheck({
|
|
1181
|
+
kind: "max",
|
|
1182
|
+
value: 0,
|
|
1183
|
+
inclusive: !1,
|
|
1184
|
+
message: l.toString(e)
|
|
1185
|
+
});
|
|
1186
|
+
}
|
|
1187
|
+
nonpositive(e) {
|
|
1188
|
+
return this._addCheck({
|
|
1189
|
+
kind: "max",
|
|
1190
|
+
value: 0,
|
|
1191
|
+
inclusive: !0,
|
|
1192
|
+
message: l.toString(e)
|
|
1193
|
+
});
|
|
1194
|
+
}
|
|
1195
|
+
nonnegative(e) {
|
|
1196
|
+
return this._addCheck({
|
|
1197
|
+
kind: "min",
|
|
1198
|
+
value: 0,
|
|
1199
|
+
inclusive: !0,
|
|
1200
|
+
message: l.toString(e)
|
|
1201
|
+
});
|
|
1202
|
+
}
|
|
1203
|
+
multipleOf(e, t) {
|
|
1204
|
+
return this._addCheck({
|
|
1205
|
+
kind: "multipleOf",
|
|
1206
|
+
value: e,
|
|
1207
|
+
message: l.toString(t)
|
|
1208
|
+
});
|
|
1209
|
+
}
|
|
1210
|
+
finite(e) {
|
|
1211
|
+
return this._addCheck({
|
|
1212
|
+
kind: "finite",
|
|
1213
|
+
message: l.toString(e)
|
|
1214
|
+
});
|
|
1215
|
+
}
|
|
1216
|
+
safe(e) {
|
|
1217
|
+
return this._addCheck({
|
|
1218
|
+
kind: "min",
|
|
1219
|
+
inclusive: !0,
|
|
1220
|
+
value: Number.MIN_SAFE_INTEGER,
|
|
1221
|
+
message: l.toString(e)
|
|
1222
|
+
})._addCheck({
|
|
1223
|
+
kind: "max",
|
|
1224
|
+
inclusive: !0,
|
|
1225
|
+
value: Number.MAX_SAFE_INTEGER,
|
|
1226
|
+
message: l.toString(e)
|
|
1227
|
+
});
|
|
1228
|
+
}
|
|
1229
|
+
get minValue() {
|
|
1230
|
+
let e = null;
|
|
1231
|
+
for (const t of this._def.checks)
|
|
1232
|
+
t.kind === "min" && (e === null || t.value > e) && (e = t.value);
|
|
1233
|
+
return e;
|
|
1234
|
+
}
|
|
1235
|
+
get maxValue() {
|
|
1236
|
+
let e = null;
|
|
1237
|
+
for (const t of this._def.checks)
|
|
1238
|
+
t.kind === "max" && (e === null || t.value < e) && (e = t.value);
|
|
1239
|
+
return e;
|
|
1240
|
+
}
|
|
1241
|
+
get isInt() {
|
|
1242
|
+
return !!this._def.checks.find((e) => e.kind === "int" || e.kind === "multipleOf" && _.isInteger(e.value));
|
|
1243
|
+
}
|
|
1244
|
+
get isFinite() {
|
|
1245
|
+
let e = null, t = null;
|
|
1246
|
+
for (const r of this._def.checks) {
|
|
1247
|
+
if (r.kind === "finite" || r.kind === "int" || r.kind === "multipleOf")
|
|
1248
|
+
return !0;
|
|
1249
|
+
r.kind === "min" ? (t === null || r.value > t) && (t = r.value) : r.kind === "max" && (e === null || r.value < e) && (e = r.value);
|
|
1250
|
+
}
|
|
1251
|
+
return Number.isFinite(t) && Number.isFinite(e);
|
|
1252
|
+
}
|
|
1253
|
+
}
|
|
1254
|
+
$.create = (s) => new $({
|
|
1255
|
+
checks: [],
|
|
1256
|
+
typeName: p.ZodNumber,
|
|
1257
|
+
coerce: s?.coerce || !1,
|
|
1258
|
+
...g(s)
|
|
1259
|
+
});
|
|
1260
|
+
class U extends y {
|
|
1261
|
+
constructor() {
|
|
1262
|
+
super(...arguments), this.min = this.gte, this.max = this.lte;
|
|
1263
|
+
}
|
|
1264
|
+
_parse(e) {
|
|
1265
|
+
if (this._def.coerce)
|
|
1266
|
+
try {
|
|
1267
|
+
e.data = BigInt(e.data);
|
|
1268
|
+
} catch {
|
|
1269
|
+
return this._getInvalidInput(e);
|
|
1270
|
+
}
|
|
1271
|
+
if (this._getType(e) !== u.bigint)
|
|
1272
|
+
return this._getInvalidInput(e);
|
|
1273
|
+
let r;
|
|
1274
|
+
const a = new b();
|
|
1275
|
+
for (const n of this._def.checks)
|
|
1276
|
+
n.kind === "min" ? (n.inclusive ? e.data < n.value : e.data <= n.value) && (r = this._getOrReturnCtx(e, r), c(r, {
|
|
1277
|
+
code: d.too_small,
|
|
1278
|
+
type: "bigint",
|
|
1279
|
+
minimum: n.value,
|
|
1280
|
+
inclusive: n.inclusive,
|
|
1281
|
+
message: n.message
|
|
1282
|
+
}), a.dirty()) : n.kind === "max" ? (n.inclusive ? e.data > n.value : e.data >= n.value) && (r = this._getOrReturnCtx(e, r), c(r, {
|
|
1283
|
+
code: d.too_big,
|
|
1284
|
+
type: "bigint",
|
|
1285
|
+
maximum: n.value,
|
|
1286
|
+
inclusive: n.inclusive,
|
|
1287
|
+
message: n.message
|
|
1288
|
+
}), a.dirty()) : n.kind === "multipleOf" ? e.data % n.value !== BigInt(0) && (r = this._getOrReturnCtx(e, r), c(r, {
|
|
1289
|
+
code: d.not_multiple_of,
|
|
1290
|
+
multipleOf: n.value,
|
|
1291
|
+
message: n.message
|
|
1292
|
+
}), a.dirty()) : _.assertNever(n);
|
|
1293
|
+
return { status: a.value, value: e.data };
|
|
1294
|
+
}
|
|
1295
|
+
_getInvalidInput(e) {
|
|
1296
|
+
const t = this._getOrReturnCtx(e);
|
|
1297
|
+
return c(t, {
|
|
1298
|
+
code: d.invalid_type,
|
|
1299
|
+
expected: u.bigint,
|
|
1300
|
+
received: t.parsedType
|
|
1301
|
+
}), m;
|
|
1302
|
+
}
|
|
1303
|
+
gte(e, t) {
|
|
1304
|
+
return this.setLimit("min", e, !0, l.toString(t));
|
|
1305
|
+
}
|
|
1306
|
+
gt(e, t) {
|
|
1307
|
+
return this.setLimit("min", e, !1, l.toString(t));
|
|
1308
|
+
}
|
|
1309
|
+
lte(e, t) {
|
|
1310
|
+
return this.setLimit("max", e, !0, l.toString(t));
|
|
1311
|
+
}
|
|
1312
|
+
lt(e, t) {
|
|
1313
|
+
return this.setLimit("max", e, !1, l.toString(t));
|
|
1314
|
+
}
|
|
1315
|
+
setLimit(e, t, r, a) {
|
|
1316
|
+
return new U({
|
|
1317
|
+
...this._def,
|
|
1318
|
+
checks: [
|
|
1319
|
+
...this._def.checks,
|
|
1320
|
+
{
|
|
1321
|
+
kind: e,
|
|
1322
|
+
value: t,
|
|
1323
|
+
inclusive: r,
|
|
1324
|
+
message: l.toString(a)
|
|
1325
|
+
}
|
|
1326
|
+
]
|
|
1327
|
+
});
|
|
1328
|
+
}
|
|
1329
|
+
_addCheck(e) {
|
|
1330
|
+
return new U({
|
|
1331
|
+
...this._def,
|
|
1332
|
+
checks: [...this._def.checks, e]
|
|
1333
|
+
});
|
|
1334
|
+
}
|
|
1335
|
+
positive(e) {
|
|
1336
|
+
return this._addCheck({
|
|
1337
|
+
kind: "min",
|
|
1338
|
+
value: BigInt(0),
|
|
1339
|
+
inclusive: !1,
|
|
1340
|
+
message: l.toString(e)
|
|
1341
|
+
});
|
|
1342
|
+
}
|
|
1343
|
+
negative(e) {
|
|
1344
|
+
return this._addCheck({
|
|
1345
|
+
kind: "max",
|
|
1346
|
+
value: BigInt(0),
|
|
1347
|
+
inclusive: !1,
|
|
1348
|
+
message: l.toString(e)
|
|
1349
|
+
});
|
|
1350
|
+
}
|
|
1351
|
+
nonpositive(e) {
|
|
1352
|
+
return this._addCheck({
|
|
1353
|
+
kind: "max",
|
|
1354
|
+
value: BigInt(0),
|
|
1355
|
+
inclusive: !0,
|
|
1356
|
+
message: l.toString(e)
|
|
1357
|
+
});
|
|
1358
|
+
}
|
|
1359
|
+
nonnegative(e) {
|
|
1360
|
+
return this._addCheck({
|
|
1361
|
+
kind: "min",
|
|
1362
|
+
value: BigInt(0),
|
|
1363
|
+
inclusive: !0,
|
|
1364
|
+
message: l.toString(e)
|
|
1365
|
+
});
|
|
1366
|
+
}
|
|
1367
|
+
multipleOf(e, t) {
|
|
1368
|
+
return this._addCheck({
|
|
1369
|
+
kind: "multipleOf",
|
|
1370
|
+
value: e,
|
|
1371
|
+
message: l.toString(t)
|
|
1372
|
+
});
|
|
1373
|
+
}
|
|
1374
|
+
get minValue() {
|
|
1375
|
+
let e = null;
|
|
1376
|
+
for (const t of this._def.checks)
|
|
1377
|
+
t.kind === "min" && (e === null || t.value > e) && (e = t.value);
|
|
1378
|
+
return e;
|
|
1379
|
+
}
|
|
1380
|
+
get maxValue() {
|
|
1381
|
+
let e = null;
|
|
1382
|
+
for (const t of this._def.checks)
|
|
1383
|
+
t.kind === "max" && (e === null || t.value < e) && (e = t.value);
|
|
1384
|
+
return e;
|
|
1385
|
+
}
|
|
1386
|
+
}
|
|
1387
|
+
U.create = (s) => new U({
|
|
1388
|
+
checks: [],
|
|
1389
|
+
typeName: p.ZodBigInt,
|
|
1390
|
+
coerce: s?.coerce ?? !1,
|
|
1391
|
+
...g(s)
|
|
1392
|
+
});
|
|
1393
|
+
class de extends y {
|
|
1394
|
+
_parse(e) {
|
|
1395
|
+
if (this._def.coerce && (e.data = !!e.data), this._getType(e) !== u.boolean) {
|
|
1396
|
+
const r = this._getOrReturnCtx(e);
|
|
1397
|
+
return c(r, {
|
|
1398
|
+
code: d.invalid_type,
|
|
1399
|
+
expected: u.boolean,
|
|
1400
|
+
received: r.parsedType
|
|
1401
|
+
}), m;
|
|
1402
|
+
}
|
|
1403
|
+
return w(e.data);
|
|
1404
|
+
}
|
|
1405
|
+
}
|
|
1406
|
+
de.create = (s) => new de({
|
|
1407
|
+
typeName: p.ZodBoolean,
|
|
1408
|
+
coerce: s?.coerce || !1,
|
|
1409
|
+
...g(s)
|
|
1410
|
+
});
|
|
1411
|
+
class W extends y {
|
|
1412
|
+
_parse(e) {
|
|
1413
|
+
if (this._def.coerce && (e.data = new Date(e.data)), this._getType(e) !== u.date) {
|
|
1414
|
+
const n = this._getOrReturnCtx(e);
|
|
1415
|
+
return c(n, {
|
|
1416
|
+
code: d.invalid_type,
|
|
1417
|
+
expected: u.date,
|
|
1418
|
+
received: n.parsedType
|
|
1419
|
+
}), m;
|
|
1420
|
+
}
|
|
1421
|
+
if (Number.isNaN(e.data.getTime())) {
|
|
1422
|
+
const n = this._getOrReturnCtx(e);
|
|
1423
|
+
return c(n, {
|
|
1424
|
+
code: d.invalid_date
|
|
1425
|
+
}), m;
|
|
1426
|
+
}
|
|
1427
|
+
const r = new b();
|
|
1428
|
+
let a;
|
|
1429
|
+
for (const n of this._def.checks)
|
|
1430
|
+
n.kind === "min" ? e.data.getTime() < n.value && (a = this._getOrReturnCtx(e, a), c(a, {
|
|
1431
|
+
code: d.too_small,
|
|
1432
|
+
message: n.message,
|
|
1433
|
+
inclusive: !0,
|
|
1434
|
+
exact: !1,
|
|
1435
|
+
minimum: n.value,
|
|
1436
|
+
type: "date"
|
|
1437
|
+
}), r.dirty()) : n.kind === "max" ? e.data.getTime() > n.value && (a = this._getOrReturnCtx(e, a), c(a, {
|
|
1438
|
+
code: d.too_big,
|
|
1439
|
+
message: n.message,
|
|
1440
|
+
inclusive: !0,
|
|
1441
|
+
exact: !1,
|
|
1442
|
+
maximum: n.value,
|
|
1443
|
+
type: "date"
|
|
1444
|
+
}), r.dirty()) : _.assertNever(n);
|
|
1445
|
+
return {
|
|
1446
|
+
status: r.value,
|
|
1447
|
+
value: new Date(e.data.getTime())
|
|
1448
|
+
};
|
|
1449
|
+
}
|
|
1450
|
+
_addCheck(e) {
|
|
1451
|
+
return new W({
|
|
1452
|
+
...this._def,
|
|
1453
|
+
checks: [...this._def.checks, e]
|
|
1454
|
+
});
|
|
1455
|
+
}
|
|
1456
|
+
min(e, t) {
|
|
1457
|
+
return this._addCheck({
|
|
1458
|
+
kind: "min",
|
|
1459
|
+
value: e.getTime(),
|
|
1460
|
+
message: l.toString(t)
|
|
1461
|
+
});
|
|
1462
|
+
}
|
|
1463
|
+
max(e, t) {
|
|
1464
|
+
return this._addCheck({
|
|
1465
|
+
kind: "max",
|
|
1466
|
+
value: e.getTime(),
|
|
1467
|
+
message: l.toString(t)
|
|
1468
|
+
});
|
|
1469
|
+
}
|
|
1470
|
+
get minDate() {
|
|
1471
|
+
let e = null;
|
|
1472
|
+
for (const t of this._def.checks)
|
|
1473
|
+
t.kind === "min" && (e === null || t.value > e) && (e = t.value);
|
|
1474
|
+
return e != null ? new Date(e) : null;
|
|
1475
|
+
}
|
|
1476
|
+
get maxDate() {
|
|
1477
|
+
let e = null;
|
|
1478
|
+
for (const t of this._def.checks)
|
|
1479
|
+
t.kind === "max" && (e === null || t.value < e) && (e = t.value);
|
|
1480
|
+
return e != null ? new Date(e) : null;
|
|
1481
|
+
}
|
|
1482
|
+
}
|
|
1483
|
+
W.create = (s) => new W({
|
|
1484
|
+
checks: [],
|
|
1485
|
+
coerce: s?.coerce || !1,
|
|
1486
|
+
typeName: p.ZodDate,
|
|
1487
|
+
...g(s)
|
|
1488
|
+
});
|
|
1489
|
+
class ce extends y {
|
|
1490
|
+
_parse(e) {
|
|
1491
|
+
if (this._getType(e) !== u.symbol) {
|
|
1492
|
+
const r = this._getOrReturnCtx(e);
|
|
1493
|
+
return c(r, {
|
|
1494
|
+
code: d.invalid_type,
|
|
1495
|
+
expected: u.symbol,
|
|
1496
|
+
received: r.parsedType
|
|
1497
|
+
}), m;
|
|
1498
|
+
}
|
|
1499
|
+
return w(e.data);
|
|
1500
|
+
}
|
|
1501
|
+
}
|
|
1502
|
+
ce.create = (s) => new ce({
|
|
1503
|
+
typeName: p.ZodSymbol,
|
|
1504
|
+
...g(s)
|
|
1505
|
+
});
|
|
1506
|
+
class ue extends y {
|
|
1507
|
+
_parse(e) {
|
|
1508
|
+
if (this._getType(e) !== u.undefined) {
|
|
1509
|
+
const r = this._getOrReturnCtx(e);
|
|
1510
|
+
return c(r, {
|
|
1511
|
+
code: d.invalid_type,
|
|
1512
|
+
expected: u.undefined,
|
|
1513
|
+
received: r.parsedType
|
|
1514
|
+
}), m;
|
|
1515
|
+
}
|
|
1516
|
+
return w(e.data);
|
|
1517
|
+
}
|
|
1518
|
+
}
|
|
1519
|
+
ue.create = (s) => new ue({
|
|
1520
|
+
typeName: p.ZodUndefined,
|
|
1521
|
+
...g(s)
|
|
1522
|
+
});
|
|
1523
|
+
class le extends y {
|
|
1524
|
+
_parse(e) {
|
|
1525
|
+
if (this._getType(e) !== u.null) {
|
|
1526
|
+
const r = this._getOrReturnCtx(e);
|
|
1527
|
+
return c(r, {
|
|
1528
|
+
code: d.invalid_type,
|
|
1529
|
+
expected: u.null,
|
|
1530
|
+
received: r.parsedType
|
|
1531
|
+
}), m;
|
|
1532
|
+
}
|
|
1533
|
+
return w(e.data);
|
|
1534
|
+
}
|
|
1535
|
+
}
|
|
1536
|
+
le.create = (s) => new le({
|
|
1537
|
+
typeName: p.ZodNull,
|
|
1538
|
+
...g(s)
|
|
1539
|
+
});
|
|
1540
|
+
class fe extends y {
|
|
1541
|
+
constructor() {
|
|
1542
|
+
super(...arguments), this._any = !0;
|
|
1543
|
+
}
|
|
1544
|
+
_parse(e) {
|
|
1545
|
+
return w(e.data);
|
|
1546
|
+
}
|
|
1547
|
+
}
|
|
1548
|
+
fe.create = (s) => new fe({
|
|
1549
|
+
typeName: p.ZodAny,
|
|
1550
|
+
...g(s)
|
|
1551
|
+
});
|
|
1552
|
+
class he extends y {
|
|
1553
|
+
constructor() {
|
|
1554
|
+
super(...arguments), this._unknown = !0;
|
|
1555
|
+
}
|
|
1556
|
+
_parse(e) {
|
|
1557
|
+
return w(e.data);
|
|
1558
|
+
}
|
|
1559
|
+
}
|
|
1560
|
+
he.create = (s) => new he({
|
|
1561
|
+
typeName: p.ZodUnknown,
|
|
1562
|
+
...g(s)
|
|
1563
|
+
});
|
|
1564
|
+
class N extends y {
|
|
1565
|
+
_parse(e) {
|
|
1566
|
+
const t = this._getOrReturnCtx(e);
|
|
1567
|
+
return c(t, {
|
|
1568
|
+
code: d.invalid_type,
|
|
1569
|
+
expected: u.never,
|
|
1570
|
+
received: t.parsedType
|
|
1571
|
+
}), m;
|
|
1572
|
+
}
|
|
1573
|
+
}
|
|
1574
|
+
N.create = (s) => new N({
|
|
1575
|
+
typeName: p.ZodNever,
|
|
1576
|
+
...g(s)
|
|
1577
|
+
});
|
|
1578
|
+
class me extends y {
|
|
1579
|
+
_parse(e) {
|
|
1580
|
+
if (this._getType(e) !== u.undefined) {
|
|
1581
|
+
const r = this._getOrReturnCtx(e);
|
|
1582
|
+
return c(r, {
|
|
1583
|
+
code: d.invalid_type,
|
|
1584
|
+
expected: u.void,
|
|
1585
|
+
received: r.parsedType
|
|
1586
|
+
}), m;
|
|
1587
|
+
}
|
|
1588
|
+
return w(e.data);
|
|
1589
|
+
}
|
|
1590
|
+
}
|
|
1591
|
+
me.create = (s) => new me({
|
|
1592
|
+
typeName: p.ZodVoid,
|
|
1593
|
+
...g(s)
|
|
1594
|
+
});
|
|
1595
|
+
class C extends y {
|
|
1596
|
+
_parse(e) {
|
|
1597
|
+
const { ctx: t, status: r } = this._processInputParams(e), a = this._def;
|
|
1598
|
+
if (t.parsedType !== u.array)
|
|
1599
|
+
return c(t, {
|
|
1600
|
+
code: d.invalid_type,
|
|
1601
|
+
expected: u.array,
|
|
1602
|
+
received: t.parsedType
|
|
1603
|
+
}), m;
|
|
1604
|
+
if (a.exactLength !== null) {
|
|
1605
|
+
const i = t.data.length > a.exactLength.value, o = t.data.length < a.exactLength.value;
|
|
1606
|
+
(i || o) && (c(t, {
|
|
1607
|
+
code: i ? d.too_big : d.too_small,
|
|
1608
|
+
minimum: o ? a.exactLength.value : void 0,
|
|
1609
|
+
maximum: i ? a.exactLength.value : void 0,
|
|
1610
|
+
type: "array",
|
|
1611
|
+
inclusive: !0,
|
|
1612
|
+
exact: !0,
|
|
1613
|
+
message: a.exactLength.message
|
|
1614
|
+
}), r.dirty());
|
|
1615
|
+
}
|
|
1616
|
+
if (a.minLength !== null && t.data.length < a.minLength.value && (c(t, {
|
|
1617
|
+
code: d.too_small,
|
|
1618
|
+
minimum: a.minLength.value,
|
|
1619
|
+
type: "array",
|
|
1620
|
+
inclusive: !0,
|
|
1621
|
+
exact: !1,
|
|
1622
|
+
message: a.minLength.message
|
|
1623
|
+
}), r.dirty()), a.maxLength !== null && t.data.length > a.maxLength.value && (c(t, {
|
|
1624
|
+
code: d.too_big,
|
|
1625
|
+
maximum: a.maxLength.value,
|
|
1626
|
+
type: "array",
|
|
1627
|
+
inclusive: !0,
|
|
1628
|
+
exact: !1,
|
|
1629
|
+
message: a.maxLength.message
|
|
1630
|
+
}), r.dirty()), t.common.async)
|
|
1631
|
+
return Promise.all([...t.data].map((i, o) => a.type._parseAsync(new A(t, i, t.path, o)))).then((i) => b.mergeArray(r, i));
|
|
1632
|
+
const n = [...t.data].map((i, o) => a.type._parseSync(new A(t, i, t.path, o)));
|
|
1633
|
+
return b.mergeArray(r, n);
|
|
1634
|
+
}
|
|
1635
|
+
get element() {
|
|
1636
|
+
return this._def.type;
|
|
1637
|
+
}
|
|
1638
|
+
min(e, t) {
|
|
1639
|
+
return new C({
|
|
1640
|
+
...this._def,
|
|
1641
|
+
minLength: { value: e, message: l.toString(t) }
|
|
1642
|
+
});
|
|
1643
|
+
}
|
|
1644
|
+
max(e, t) {
|
|
1645
|
+
return new C({
|
|
1646
|
+
...this._def,
|
|
1647
|
+
maxLength: { value: e, message: l.toString(t) }
|
|
1648
|
+
});
|
|
1649
|
+
}
|
|
1650
|
+
length(e, t) {
|
|
1651
|
+
return new C({
|
|
1652
|
+
...this._def,
|
|
1653
|
+
exactLength: { value: e, message: l.toString(t) }
|
|
1654
|
+
});
|
|
1655
|
+
}
|
|
1656
|
+
nonempty(e) {
|
|
1657
|
+
return this.min(1, e);
|
|
1658
|
+
}
|
|
1659
|
+
}
|
|
1660
|
+
C.create = (s, e) => new C({
|
|
1661
|
+
type: s,
|
|
1662
|
+
minLength: null,
|
|
1663
|
+
maxLength: null,
|
|
1664
|
+
exactLength: null,
|
|
1665
|
+
typeName: p.ZodArray,
|
|
1666
|
+
...g(e)
|
|
1667
|
+
});
|
|
1668
|
+
function E(s) {
|
|
1669
|
+
if (s instanceof x) {
|
|
1670
|
+
const e = {};
|
|
1671
|
+
for (const t in s.shape) {
|
|
1672
|
+
const r = s.shape[t];
|
|
1673
|
+
e[t] = O.create(E(r));
|
|
1674
|
+
}
|
|
1675
|
+
return new x({
|
|
1676
|
+
...s._def,
|
|
1677
|
+
shape: () => e
|
|
1678
|
+
});
|
|
1679
|
+
} else return s instanceof C ? new C({
|
|
1680
|
+
...s._def,
|
|
1681
|
+
type: E(s.element)
|
|
1682
|
+
}) : s instanceof O ? O.create(E(s.unwrap())) : s instanceof P ? P.create(E(s.unwrap())) : s instanceof I ? I.create(s.items.map((e) => E(e))) : s;
|
|
1683
|
+
}
|
|
1684
|
+
class x extends y {
|
|
1685
|
+
constructor() {
|
|
1686
|
+
super(...arguments), this._cached = null, this.nonstrict = this.passthrough, this.augment = this.extend;
|
|
1687
|
+
}
|
|
1688
|
+
_getCached() {
|
|
1689
|
+
if (this._cached !== null)
|
|
1690
|
+
return this._cached;
|
|
1691
|
+
const e = this._def.shape(), t = _.objectKeys(e);
|
|
1692
|
+
return this._cached = { shape: e, keys: t }, this._cached;
|
|
1693
|
+
}
|
|
1694
|
+
_parse(e) {
|
|
1695
|
+
if (this._getType(e) !== u.object) {
|
|
1696
|
+
const h = this._getOrReturnCtx(e);
|
|
1697
|
+
return c(h, {
|
|
1698
|
+
code: d.invalid_type,
|
|
1699
|
+
expected: u.object,
|
|
1700
|
+
received: h.parsedType
|
|
1701
|
+
}), m;
|
|
1702
|
+
}
|
|
1703
|
+
const { status: r, ctx: a } = this._processInputParams(e), { shape: n, keys: i } = this._getCached(), o = [];
|
|
1704
|
+
if (!(this._def.catchall instanceof N && this._def.unknownKeys === "strip"))
|
|
1705
|
+
for (const h in a.data)
|
|
1706
|
+
i.includes(h) || o.push(h);
|
|
1707
|
+
const f = [];
|
|
1708
|
+
for (const h of i) {
|
|
1709
|
+
const v = n[h], D = a.data[h];
|
|
1710
|
+
f.push({
|
|
1711
|
+
key: { status: "valid", value: h },
|
|
1712
|
+
value: v._parse(new A(a, D, a.path, h)),
|
|
1713
|
+
alwaysSet: h in a.data
|
|
1714
|
+
});
|
|
1715
|
+
}
|
|
1716
|
+
if (this._def.catchall instanceof N) {
|
|
1717
|
+
const h = this._def.unknownKeys;
|
|
1718
|
+
if (h === "passthrough")
|
|
1719
|
+
for (const v of o)
|
|
1720
|
+
f.push({
|
|
1721
|
+
key: { status: "valid", value: v },
|
|
1722
|
+
value: { status: "valid", value: a.data[v] }
|
|
1723
|
+
});
|
|
1724
|
+
else if (h === "strict")
|
|
1725
|
+
o.length > 0 && (c(a, {
|
|
1726
|
+
code: d.unrecognized_keys,
|
|
1727
|
+
keys: o
|
|
1728
|
+
}), r.dirty());
|
|
1729
|
+
else if (h !== "strip") throw new Error("Internal ZodObject error: invalid unknownKeys value.");
|
|
1730
|
+
} else {
|
|
1731
|
+
const h = this._def.catchall;
|
|
1732
|
+
for (const v of o) {
|
|
1733
|
+
const D = a.data[v];
|
|
1734
|
+
f.push({
|
|
1735
|
+
key: { status: "valid", value: v },
|
|
1736
|
+
value: h._parse(
|
|
1737
|
+
new A(a, D, a.path, v)
|
|
1738
|
+
//, ctx.child(key), value, getParsedType(value)
|
|
1739
|
+
),
|
|
1740
|
+
alwaysSet: v in a.data
|
|
1741
|
+
});
|
|
1742
|
+
}
|
|
1743
|
+
}
|
|
1744
|
+
return a.common.async ? Promise.resolve().then(async () => {
|
|
1745
|
+
const h = [];
|
|
1746
|
+
for (const v of f) {
|
|
1747
|
+
const D = await v.key, Te = await v.value;
|
|
1748
|
+
h.push({
|
|
1749
|
+
key: D,
|
|
1750
|
+
value: Te,
|
|
1751
|
+
alwaysSet: v.alwaysSet
|
|
1752
|
+
});
|
|
1753
|
+
}
|
|
1754
|
+
return h;
|
|
1755
|
+
}).then((h) => b.mergeObjectSync(r, h)) : b.mergeObjectSync(r, f);
|
|
1756
|
+
}
|
|
1757
|
+
get shape() {
|
|
1758
|
+
return this._def.shape();
|
|
1759
|
+
}
|
|
1760
|
+
strict(e) {
|
|
1761
|
+
return l.errToObj, new x({
|
|
1762
|
+
...this._def,
|
|
1763
|
+
unknownKeys: "strict",
|
|
1764
|
+
...e !== void 0 ? {
|
|
1765
|
+
errorMap: (t, r) => {
|
|
1766
|
+
const a = this._def.errorMap?.(t, r).message ?? r.defaultError;
|
|
1767
|
+
return t.code === "unrecognized_keys" ? {
|
|
1768
|
+
message: l.errToObj(e).message ?? a
|
|
1769
|
+
} : {
|
|
1770
|
+
message: a
|
|
1771
|
+
};
|
|
1772
|
+
}
|
|
1773
|
+
} : {}
|
|
1774
|
+
});
|
|
1775
|
+
}
|
|
1776
|
+
strip() {
|
|
1777
|
+
return new x({
|
|
1778
|
+
...this._def,
|
|
1779
|
+
unknownKeys: "strip"
|
|
1780
|
+
});
|
|
1781
|
+
}
|
|
1782
|
+
passthrough() {
|
|
1783
|
+
return new x({
|
|
1784
|
+
...this._def,
|
|
1785
|
+
unknownKeys: "passthrough"
|
|
1786
|
+
});
|
|
1787
|
+
}
|
|
1788
|
+
// const AugmentFactory =
|
|
1789
|
+
// <Def extends ZodObjectDef>(def: Def) =>
|
|
1790
|
+
// <Augmentation extends ZodRawShape>(
|
|
1791
|
+
// augmentation: Augmentation
|
|
1792
|
+
// ): ZodObject<
|
|
1793
|
+
// extendShape<ReturnType<Def["shape"]>, Augmentation>,
|
|
1794
|
+
// Def["unknownKeys"],
|
|
1795
|
+
// Def["catchall"]
|
|
1796
|
+
// > => {
|
|
1797
|
+
// return new ZodObject({
|
|
1798
|
+
// ...def,
|
|
1799
|
+
// shape: () => ({
|
|
1800
|
+
// ...def.shape(),
|
|
1801
|
+
// ...augmentation,
|
|
1802
|
+
// }),
|
|
1803
|
+
// }) as any;
|
|
1804
|
+
// };
|
|
1805
|
+
extend(e) {
|
|
1806
|
+
return new x({
|
|
1807
|
+
...this._def,
|
|
1808
|
+
shape: () => ({
|
|
1809
|
+
...this._def.shape(),
|
|
1810
|
+
...e
|
|
1811
|
+
})
|
|
1812
|
+
});
|
|
1813
|
+
}
|
|
1814
|
+
/**
|
|
1815
|
+
* Prior to zod@1.0.12 there was a bug in the
|
|
1816
|
+
* inferred type of merged objects. Please
|
|
1817
|
+
* upgrade if you are experiencing issues.
|
|
1818
|
+
*/
|
|
1819
|
+
merge(e) {
|
|
1820
|
+
return new x({
|
|
1821
|
+
unknownKeys: e._def.unknownKeys,
|
|
1822
|
+
catchall: e._def.catchall,
|
|
1823
|
+
shape: () => ({
|
|
1824
|
+
...this._def.shape(),
|
|
1825
|
+
...e._def.shape()
|
|
1826
|
+
}),
|
|
1827
|
+
typeName: p.ZodObject
|
|
1828
|
+
});
|
|
1829
|
+
}
|
|
1830
|
+
// merge<
|
|
1831
|
+
// Incoming extends AnyZodObject,
|
|
1832
|
+
// Augmentation extends Incoming["shape"],
|
|
1833
|
+
// NewOutput extends {
|
|
1834
|
+
// [k in keyof Augmentation | keyof Output]: k extends keyof Augmentation
|
|
1835
|
+
// ? Augmentation[k]["_output"]
|
|
1836
|
+
// : k extends keyof Output
|
|
1837
|
+
// ? Output[k]
|
|
1838
|
+
// : never;
|
|
1839
|
+
// },
|
|
1840
|
+
// NewInput extends {
|
|
1841
|
+
// [k in keyof Augmentation | keyof Input]: k extends keyof Augmentation
|
|
1842
|
+
// ? Augmentation[k]["_input"]
|
|
1843
|
+
// : k extends keyof Input
|
|
1844
|
+
// ? Input[k]
|
|
1845
|
+
// : never;
|
|
1846
|
+
// }
|
|
1847
|
+
// >(
|
|
1848
|
+
// merging: Incoming
|
|
1849
|
+
// ): ZodObject<
|
|
1850
|
+
// extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
|
|
1851
|
+
// Incoming["_def"]["unknownKeys"],
|
|
1852
|
+
// Incoming["_def"]["catchall"],
|
|
1853
|
+
// NewOutput,
|
|
1854
|
+
// NewInput
|
|
1855
|
+
// > {
|
|
1856
|
+
// const merged: any = new ZodObject({
|
|
1857
|
+
// unknownKeys: merging._def.unknownKeys,
|
|
1858
|
+
// catchall: merging._def.catchall,
|
|
1859
|
+
// shape: () =>
|
|
1860
|
+
// objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
|
|
1861
|
+
// typeName: ZodFirstPartyTypeKind.ZodObject,
|
|
1862
|
+
// }) as any;
|
|
1863
|
+
// return merged;
|
|
1864
|
+
// }
|
|
1865
|
+
setKey(e, t) {
|
|
1866
|
+
return this.augment({ [e]: t });
|
|
1867
|
+
}
|
|
1868
|
+
// merge<Incoming extends AnyZodObject>(
|
|
1869
|
+
// merging: Incoming
|
|
1870
|
+
// ): //ZodObject<T & Incoming["_shape"], UnknownKeys, Catchall> = (merging) => {
|
|
1871
|
+
// ZodObject<
|
|
1872
|
+
// extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
|
|
1873
|
+
// Incoming["_def"]["unknownKeys"],
|
|
1874
|
+
// Incoming["_def"]["catchall"]
|
|
1875
|
+
// > {
|
|
1876
|
+
// // const mergedShape = objectUtil.mergeShapes(
|
|
1877
|
+
// // this._def.shape(),
|
|
1878
|
+
// // merging._def.shape()
|
|
1879
|
+
// // );
|
|
1880
|
+
// const merged: any = new ZodObject({
|
|
1881
|
+
// unknownKeys: merging._def.unknownKeys,
|
|
1882
|
+
// catchall: merging._def.catchall,
|
|
1883
|
+
// shape: () =>
|
|
1884
|
+
// objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
|
|
1885
|
+
// typeName: ZodFirstPartyTypeKind.ZodObject,
|
|
1886
|
+
// }) as any;
|
|
1887
|
+
// return merged;
|
|
1888
|
+
// }
|
|
1889
|
+
catchall(e) {
|
|
1890
|
+
return new x({
|
|
1891
|
+
...this._def,
|
|
1892
|
+
catchall: e
|
|
1893
|
+
});
|
|
1894
|
+
}
|
|
1895
|
+
pick(e) {
|
|
1896
|
+
const t = {};
|
|
1897
|
+
for (const r of _.objectKeys(e))
|
|
1898
|
+
e[r] && this.shape[r] && (t[r] = this.shape[r]);
|
|
1899
|
+
return new x({
|
|
1900
|
+
...this._def,
|
|
1901
|
+
shape: () => t
|
|
1902
|
+
});
|
|
1903
|
+
}
|
|
1904
|
+
omit(e) {
|
|
1905
|
+
const t = {};
|
|
1906
|
+
for (const r of _.objectKeys(this.shape))
|
|
1907
|
+
e[r] || (t[r] = this.shape[r]);
|
|
1908
|
+
return new x({
|
|
1909
|
+
...this._def,
|
|
1910
|
+
shape: () => t
|
|
1911
|
+
});
|
|
1912
|
+
}
|
|
1913
|
+
/**
|
|
1914
|
+
* @deprecated
|
|
1915
|
+
*/
|
|
1916
|
+
deepPartial() {
|
|
1917
|
+
return E(this);
|
|
1918
|
+
}
|
|
1919
|
+
partial(e) {
|
|
1920
|
+
const t = {};
|
|
1921
|
+
for (const r of _.objectKeys(this.shape)) {
|
|
1922
|
+
const a = this.shape[r];
|
|
1923
|
+
e && !e[r] ? t[r] = a : t[r] = a.optional();
|
|
1924
|
+
}
|
|
1925
|
+
return new x({
|
|
1926
|
+
...this._def,
|
|
1927
|
+
shape: () => t
|
|
1928
|
+
});
|
|
1929
|
+
}
|
|
1930
|
+
required(e) {
|
|
1931
|
+
const t = {};
|
|
1932
|
+
for (const r of _.objectKeys(this.shape))
|
|
1933
|
+
if (e && !e[r])
|
|
1934
|
+
t[r] = this.shape[r];
|
|
1935
|
+
else {
|
|
1936
|
+
let n = this.shape[r];
|
|
1937
|
+
for (; n instanceof O; )
|
|
1938
|
+
n = n._def.innerType;
|
|
1939
|
+
t[r] = n;
|
|
1940
|
+
}
|
|
1941
|
+
return new x({
|
|
1942
|
+
...this._def,
|
|
1943
|
+
shape: () => t
|
|
1944
|
+
});
|
|
1945
|
+
}
|
|
1946
|
+
keyof() {
|
|
1947
|
+
return we(_.objectKeys(this.shape));
|
|
1948
|
+
}
|
|
1949
|
+
}
|
|
1950
|
+
x.create = (s, e) => new x({
|
|
1951
|
+
shape: () => s,
|
|
1952
|
+
unknownKeys: "strip",
|
|
1953
|
+
catchall: N.create(),
|
|
1954
|
+
typeName: p.ZodObject,
|
|
1955
|
+
...g(e)
|
|
1956
|
+
});
|
|
1957
|
+
x.strictCreate = (s, e) => new x({
|
|
1958
|
+
shape: () => s,
|
|
1959
|
+
unknownKeys: "strict",
|
|
1960
|
+
catchall: N.create(),
|
|
1961
|
+
typeName: p.ZodObject,
|
|
1962
|
+
...g(e)
|
|
1963
|
+
});
|
|
1964
|
+
x.lazycreate = (s, e) => new x({
|
|
1965
|
+
shape: s,
|
|
1966
|
+
unknownKeys: "strip",
|
|
1967
|
+
catchall: N.create(),
|
|
1968
|
+
typeName: p.ZodObject,
|
|
1969
|
+
...g(e)
|
|
1970
|
+
});
|
|
1971
|
+
class q extends y {
|
|
1972
|
+
_parse(e) {
|
|
1973
|
+
const { ctx: t } = this._processInputParams(e), r = this._def.options;
|
|
1974
|
+
function a(n) {
|
|
1975
|
+
for (const o of n)
|
|
1976
|
+
if (o.result.status === "valid")
|
|
1977
|
+
return o.result;
|
|
1978
|
+
for (const o of n)
|
|
1979
|
+
if (o.result.status === "dirty")
|
|
1980
|
+
return t.common.issues.push(...o.ctx.common.issues), o.result;
|
|
1981
|
+
const i = n.map((o) => new T(o.ctx.common.issues));
|
|
1982
|
+
return c(t, {
|
|
1983
|
+
code: d.invalid_union,
|
|
1984
|
+
unionErrors: i
|
|
1985
|
+
}), m;
|
|
1986
|
+
}
|
|
1987
|
+
if (t.common.async)
|
|
1988
|
+
return Promise.all(r.map(async (n) => {
|
|
1989
|
+
const i = {
|
|
1990
|
+
...t,
|
|
1991
|
+
common: {
|
|
1992
|
+
...t.common,
|
|
1993
|
+
issues: []
|
|
1994
|
+
},
|
|
1995
|
+
parent: null
|
|
1996
|
+
};
|
|
1997
|
+
return {
|
|
1998
|
+
result: await n._parseAsync({
|
|
1999
|
+
data: t.data,
|
|
2000
|
+
path: t.path,
|
|
2001
|
+
parent: i
|
|
2002
|
+
}),
|
|
2003
|
+
ctx: i
|
|
2004
|
+
};
|
|
2005
|
+
})).then(a);
|
|
2006
|
+
{
|
|
2007
|
+
let n;
|
|
2008
|
+
const i = [];
|
|
2009
|
+
for (const f of r) {
|
|
2010
|
+
const h = {
|
|
2011
|
+
...t,
|
|
2012
|
+
common: {
|
|
2013
|
+
...t.common,
|
|
2014
|
+
issues: []
|
|
2015
|
+
},
|
|
2016
|
+
parent: null
|
|
2017
|
+
}, v = f._parseSync({
|
|
2018
|
+
data: t.data,
|
|
2019
|
+
path: t.path,
|
|
2020
|
+
parent: h
|
|
2021
|
+
});
|
|
2022
|
+
if (v.status === "valid")
|
|
2023
|
+
return v;
|
|
2024
|
+
v.status === "dirty" && !n && (n = { result: v, ctx: h }), h.common.issues.length && i.push(h.common.issues);
|
|
2025
|
+
}
|
|
2026
|
+
if (n)
|
|
2027
|
+
return t.common.issues.push(...n.ctx.common.issues), n.result;
|
|
2028
|
+
const o = i.map((f) => new T(f));
|
|
2029
|
+
return c(t, {
|
|
2030
|
+
code: d.invalid_union,
|
|
2031
|
+
unionErrors: o
|
|
2032
|
+
}), m;
|
|
2033
|
+
}
|
|
2034
|
+
}
|
|
2035
|
+
get options() {
|
|
2036
|
+
return this._def.options;
|
|
2037
|
+
}
|
|
2038
|
+
}
|
|
2039
|
+
q.create = (s, e) => new q({
|
|
2040
|
+
options: s,
|
|
2041
|
+
typeName: p.ZodUnion,
|
|
2042
|
+
...g(e)
|
|
2043
|
+
});
|
|
2044
|
+
function G(s, e) {
|
|
2045
|
+
const t = S(s), r = S(e);
|
|
2046
|
+
if (s === e)
|
|
2047
|
+
return { valid: !0, data: s };
|
|
2048
|
+
if (t === u.object && r === u.object) {
|
|
2049
|
+
const a = _.objectKeys(e), n = _.objectKeys(s).filter((o) => a.indexOf(o) !== -1), i = { ...s, ...e };
|
|
2050
|
+
for (const o of n) {
|
|
2051
|
+
const f = G(s[o], e[o]);
|
|
2052
|
+
if (!f.valid)
|
|
2053
|
+
return { valid: !1 };
|
|
2054
|
+
i[o] = f.data;
|
|
2055
|
+
}
|
|
2056
|
+
return { valid: !0, data: i };
|
|
2057
|
+
} else if (t === u.array && r === u.array) {
|
|
2058
|
+
if (s.length !== e.length)
|
|
2059
|
+
return { valid: !1 };
|
|
2060
|
+
const a = [];
|
|
2061
|
+
for (let n = 0; n < s.length; n++) {
|
|
2062
|
+
const i = s[n], o = e[n], f = G(i, o);
|
|
2063
|
+
if (!f.valid)
|
|
2064
|
+
return { valid: !1 };
|
|
2065
|
+
a.push(f.data);
|
|
2066
|
+
}
|
|
2067
|
+
return { valid: !0, data: a };
|
|
2068
|
+
} else return t === u.date && r === u.date && +s == +e ? { valid: !0, data: s } : { valid: !1 };
|
|
2069
|
+
}
|
|
2070
|
+
class J extends y {
|
|
2071
|
+
_parse(e) {
|
|
2072
|
+
const { status: t, ctx: r } = this._processInputParams(e), a = (n, i) => {
|
|
2073
|
+
if (ne(n) || ne(i))
|
|
2074
|
+
return m;
|
|
2075
|
+
const o = G(n.value, i.value);
|
|
2076
|
+
return o.valid ? ((ie(n) || ie(i)) && t.dirty(), { status: t.value, value: o.data }) : (c(r, {
|
|
2077
|
+
code: d.invalid_intersection_types
|
|
2078
|
+
}), m);
|
|
2079
|
+
};
|
|
2080
|
+
return r.common.async ? Promise.all([
|
|
2081
|
+
this._def.left._parseAsync({
|
|
2082
|
+
data: r.data,
|
|
2083
|
+
path: r.path,
|
|
2084
|
+
parent: r
|
|
2085
|
+
}),
|
|
2086
|
+
this._def.right._parseAsync({
|
|
2087
|
+
data: r.data,
|
|
2088
|
+
path: r.path,
|
|
2089
|
+
parent: r
|
|
2090
|
+
})
|
|
2091
|
+
]).then(([n, i]) => a(n, i)) : a(this._def.left._parseSync({
|
|
2092
|
+
data: r.data,
|
|
2093
|
+
path: r.path,
|
|
2094
|
+
parent: r
|
|
2095
|
+
}), this._def.right._parseSync({
|
|
2096
|
+
data: r.data,
|
|
2097
|
+
path: r.path,
|
|
2098
|
+
parent: r
|
|
2099
|
+
}));
|
|
2100
|
+
}
|
|
2101
|
+
}
|
|
2102
|
+
J.create = (s, e, t) => new J({
|
|
2103
|
+
left: s,
|
|
2104
|
+
right: e,
|
|
2105
|
+
typeName: p.ZodIntersection,
|
|
2106
|
+
...g(t)
|
|
2107
|
+
});
|
|
2108
|
+
class I extends y {
|
|
2109
|
+
_parse(e) {
|
|
2110
|
+
const { status: t, ctx: r } = this._processInputParams(e);
|
|
2111
|
+
if (r.parsedType !== u.array)
|
|
2112
|
+
return c(r, {
|
|
2113
|
+
code: d.invalid_type,
|
|
2114
|
+
expected: u.array,
|
|
2115
|
+
received: r.parsedType
|
|
2116
|
+
}), m;
|
|
2117
|
+
if (r.data.length < this._def.items.length)
|
|
2118
|
+
return c(r, {
|
|
2119
|
+
code: d.too_small,
|
|
2120
|
+
minimum: this._def.items.length,
|
|
2121
|
+
inclusive: !0,
|
|
2122
|
+
exact: !1,
|
|
2123
|
+
type: "array"
|
|
2124
|
+
}), m;
|
|
2125
|
+
!this._def.rest && r.data.length > this._def.items.length && (c(r, {
|
|
2126
|
+
code: d.too_big,
|
|
2127
|
+
maximum: this._def.items.length,
|
|
2128
|
+
inclusive: !0,
|
|
2129
|
+
exact: !1,
|
|
2130
|
+
type: "array"
|
|
2131
|
+
}), t.dirty());
|
|
2132
|
+
const n = [...r.data].map((i, o) => {
|
|
2133
|
+
const f = this._def.items[o] || this._def.rest;
|
|
2134
|
+
return f ? f._parse(new A(r, i, r.path, o)) : null;
|
|
2135
|
+
}).filter((i) => !!i);
|
|
2136
|
+
return r.common.async ? Promise.all(n).then((i) => b.mergeArray(t, i)) : b.mergeArray(t, n);
|
|
2137
|
+
}
|
|
2138
|
+
get items() {
|
|
2139
|
+
return this._def.items;
|
|
2140
|
+
}
|
|
2141
|
+
rest(e) {
|
|
2142
|
+
return new I({
|
|
2143
|
+
...this._def,
|
|
2144
|
+
rest: e
|
|
2145
|
+
});
|
|
2146
|
+
}
|
|
2147
|
+
}
|
|
2148
|
+
I.create = (s, e) => {
|
|
2149
|
+
if (!Array.isArray(s))
|
|
2150
|
+
throw new Error("You must pass an array of schemas to z.tuple([ ... ])");
|
|
2151
|
+
return new I({
|
|
2152
|
+
items: s,
|
|
2153
|
+
typeName: p.ZodTuple,
|
|
2154
|
+
rest: null,
|
|
2155
|
+
...g(e)
|
|
2156
|
+
});
|
|
2157
|
+
};
|
|
2158
|
+
class pe extends y {
|
|
2159
|
+
get keySchema() {
|
|
2160
|
+
return this._def.keyType;
|
|
2161
|
+
}
|
|
2162
|
+
get valueSchema() {
|
|
2163
|
+
return this._def.valueType;
|
|
2164
|
+
}
|
|
2165
|
+
_parse(e) {
|
|
2166
|
+
const { status: t, ctx: r } = this._processInputParams(e);
|
|
2167
|
+
if (r.parsedType !== u.map)
|
|
2168
|
+
return c(r, {
|
|
2169
|
+
code: d.invalid_type,
|
|
2170
|
+
expected: u.map,
|
|
2171
|
+
received: r.parsedType
|
|
2172
|
+
}), m;
|
|
2173
|
+
const a = this._def.keyType, n = this._def.valueType, i = [...r.data.entries()].map(([o, f], h) => ({
|
|
2174
|
+
key: a._parse(new A(r, o, r.path, [h, "key"])),
|
|
2175
|
+
value: n._parse(new A(r, f, r.path, [h, "value"]))
|
|
2176
|
+
}));
|
|
2177
|
+
if (r.common.async) {
|
|
2178
|
+
const o = /* @__PURE__ */ new Map();
|
|
2179
|
+
return Promise.resolve().then(async () => {
|
|
2180
|
+
for (const f of i) {
|
|
2181
|
+
const h = await f.key, v = await f.value;
|
|
2182
|
+
if (h.status === "aborted" || v.status === "aborted")
|
|
2183
|
+
return m;
|
|
2184
|
+
(h.status === "dirty" || v.status === "dirty") && t.dirty(), o.set(h.value, v.value);
|
|
2185
|
+
}
|
|
2186
|
+
return { status: t.value, value: o };
|
|
2187
|
+
});
|
|
2188
|
+
} else {
|
|
2189
|
+
const o = /* @__PURE__ */ new Map();
|
|
2190
|
+
for (const f of i) {
|
|
2191
|
+
const h = f.key, v = f.value;
|
|
2192
|
+
if (h.status === "aborted" || v.status === "aborted")
|
|
2193
|
+
return m;
|
|
2194
|
+
(h.status === "dirty" || v.status === "dirty") && t.dirty(), o.set(h.value, v.value);
|
|
2195
|
+
}
|
|
2196
|
+
return { status: t.value, value: o };
|
|
2197
|
+
}
|
|
2198
|
+
}
|
|
2199
|
+
}
|
|
2200
|
+
pe.create = (s, e, t) => new pe({
|
|
2201
|
+
valueType: e,
|
|
2202
|
+
keyType: s,
|
|
2203
|
+
typeName: p.ZodMap,
|
|
2204
|
+
...g(t)
|
|
2205
|
+
});
|
|
2206
|
+
class B extends y {
|
|
2207
|
+
_parse(e) {
|
|
2208
|
+
const { status: t, ctx: r } = this._processInputParams(e);
|
|
2209
|
+
if (r.parsedType !== u.set)
|
|
2210
|
+
return c(r, {
|
|
2211
|
+
code: d.invalid_type,
|
|
2212
|
+
expected: u.set,
|
|
2213
|
+
received: r.parsedType
|
|
2214
|
+
}), m;
|
|
2215
|
+
const a = this._def;
|
|
2216
|
+
a.minSize !== null && r.data.size < a.minSize.value && (c(r, {
|
|
2217
|
+
code: d.too_small,
|
|
2218
|
+
minimum: a.minSize.value,
|
|
2219
|
+
type: "set",
|
|
2220
|
+
inclusive: !0,
|
|
2221
|
+
exact: !1,
|
|
2222
|
+
message: a.minSize.message
|
|
2223
|
+
}), t.dirty()), a.maxSize !== null && r.data.size > a.maxSize.value && (c(r, {
|
|
2224
|
+
code: d.too_big,
|
|
2225
|
+
maximum: a.maxSize.value,
|
|
2226
|
+
type: "set",
|
|
2227
|
+
inclusive: !0,
|
|
2228
|
+
exact: !1,
|
|
2229
|
+
message: a.maxSize.message
|
|
2230
|
+
}), t.dirty());
|
|
2231
|
+
const n = this._def.valueType;
|
|
2232
|
+
function i(f) {
|
|
2233
|
+
const h = /* @__PURE__ */ new Set();
|
|
2234
|
+
for (const v of f) {
|
|
2235
|
+
if (v.status === "aborted")
|
|
2236
|
+
return m;
|
|
2237
|
+
v.status === "dirty" && t.dirty(), h.add(v.value);
|
|
2238
|
+
}
|
|
2239
|
+
return { status: t.value, value: h };
|
|
2240
|
+
}
|
|
2241
|
+
const o = [...r.data.values()].map((f, h) => n._parse(new A(r, f, r.path, h)));
|
|
2242
|
+
return r.common.async ? Promise.all(o).then((f) => i(f)) : i(o);
|
|
2243
|
+
}
|
|
2244
|
+
min(e, t) {
|
|
2245
|
+
return new B({
|
|
2246
|
+
...this._def,
|
|
2247
|
+
minSize: { value: e, message: l.toString(t) }
|
|
2248
|
+
});
|
|
2249
|
+
}
|
|
2250
|
+
max(e, t) {
|
|
2251
|
+
return new B({
|
|
2252
|
+
...this._def,
|
|
2253
|
+
maxSize: { value: e, message: l.toString(t) }
|
|
2254
|
+
});
|
|
2255
|
+
}
|
|
2256
|
+
size(e, t) {
|
|
2257
|
+
return this.min(e, t).max(e, t);
|
|
2258
|
+
}
|
|
2259
|
+
nonempty(e) {
|
|
2260
|
+
return this.min(1, e);
|
|
2261
|
+
}
|
|
2262
|
+
}
|
|
2263
|
+
B.create = (s, e) => new B({
|
|
2264
|
+
valueType: s,
|
|
2265
|
+
minSize: null,
|
|
2266
|
+
maxSize: null,
|
|
2267
|
+
typeName: p.ZodSet,
|
|
2268
|
+
...g(e)
|
|
2269
|
+
});
|
|
2270
|
+
class ge extends y {
|
|
2271
|
+
get schema() {
|
|
2272
|
+
return this._def.getter();
|
|
2273
|
+
}
|
|
2274
|
+
_parse(e) {
|
|
2275
|
+
const { ctx: t } = this._processInputParams(e);
|
|
2276
|
+
return this._def.getter()._parse({ data: t.data, path: t.path, parent: t });
|
|
2277
|
+
}
|
|
2278
|
+
}
|
|
2279
|
+
ge.create = (s, e) => new ge({
|
|
2280
|
+
getter: s,
|
|
2281
|
+
typeName: p.ZodLazy,
|
|
2282
|
+
...g(e)
|
|
2283
|
+
});
|
|
2284
|
+
class ye extends y {
|
|
2285
|
+
_parse(e) {
|
|
2286
|
+
if (e.data !== this._def.value) {
|
|
2287
|
+
const t = this._getOrReturnCtx(e);
|
|
2288
|
+
return c(t, {
|
|
2289
|
+
received: t.data,
|
|
2290
|
+
code: d.invalid_literal,
|
|
2291
|
+
expected: this._def.value
|
|
2292
|
+
}), m;
|
|
2293
|
+
}
|
|
2294
|
+
return { status: "valid", value: e.data };
|
|
2295
|
+
}
|
|
2296
|
+
get value() {
|
|
2297
|
+
return this._def.value;
|
|
2298
|
+
}
|
|
2299
|
+
}
|
|
2300
|
+
ye.create = (s, e) => new ye({
|
|
2301
|
+
value: s,
|
|
2302
|
+
typeName: p.ZodLiteral,
|
|
2303
|
+
...g(e)
|
|
2304
|
+
});
|
|
2305
|
+
function we(s, e) {
|
|
2306
|
+
return new V({
|
|
2307
|
+
values: s,
|
|
2308
|
+
typeName: p.ZodEnum,
|
|
2309
|
+
...g(e)
|
|
2310
|
+
});
|
|
2311
|
+
}
|
|
2312
|
+
class V extends y {
|
|
2313
|
+
_parse(e) {
|
|
2314
|
+
if (typeof e.data != "string") {
|
|
2315
|
+
const t = this._getOrReturnCtx(e), r = this._def.values;
|
|
2316
|
+
return c(t, {
|
|
2317
|
+
expected: _.joinValues(r),
|
|
2318
|
+
received: t.parsedType,
|
|
2319
|
+
code: d.invalid_type
|
|
2320
|
+
}), m;
|
|
2321
|
+
}
|
|
2322
|
+
if (this._cache || (this._cache = new Set(this._def.values)), !this._cache.has(e.data)) {
|
|
2323
|
+
const t = this._getOrReturnCtx(e), r = this._def.values;
|
|
2324
|
+
return c(t, {
|
|
2325
|
+
received: t.data,
|
|
2326
|
+
code: d.invalid_enum_value,
|
|
2327
|
+
options: r
|
|
2328
|
+
}), m;
|
|
2329
|
+
}
|
|
2330
|
+
return w(e.data);
|
|
2331
|
+
}
|
|
2332
|
+
get options() {
|
|
2333
|
+
return this._def.values;
|
|
2334
|
+
}
|
|
2335
|
+
get enum() {
|
|
2336
|
+
const e = {};
|
|
2337
|
+
for (const t of this._def.values)
|
|
2338
|
+
e[t] = t;
|
|
2339
|
+
return e;
|
|
2340
|
+
}
|
|
2341
|
+
get Values() {
|
|
2342
|
+
const e = {};
|
|
2343
|
+
for (const t of this._def.values)
|
|
2344
|
+
e[t] = t;
|
|
2345
|
+
return e;
|
|
2346
|
+
}
|
|
2347
|
+
get Enum() {
|
|
2348
|
+
const e = {};
|
|
2349
|
+
for (const t of this._def.values)
|
|
2350
|
+
e[t] = t;
|
|
2351
|
+
return e;
|
|
2352
|
+
}
|
|
2353
|
+
extract(e, t = this._def) {
|
|
2354
|
+
return V.create(e, {
|
|
2355
|
+
...this._def,
|
|
2356
|
+
...t
|
|
2357
|
+
});
|
|
2358
|
+
}
|
|
2359
|
+
exclude(e, t = this._def) {
|
|
2360
|
+
return V.create(this.options.filter((r) => !e.includes(r)), {
|
|
2361
|
+
...this._def,
|
|
2362
|
+
...t
|
|
2363
|
+
});
|
|
2364
|
+
}
|
|
2365
|
+
}
|
|
2366
|
+
V.create = we;
|
|
2367
|
+
class _e extends y {
|
|
2368
|
+
_parse(e) {
|
|
2369
|
+
const t = _.getValidEnumValues(this._def.values), r = this._getOrReturnCtx(e);
|
|
2370
|
+
if (r.parsedType !== u.string && r.parsedType !== u.number) {
|
|
2371
|
+
const a = _.objectValues(t);
|
|
2372
|
+
return c(r, {
|
|
2373
|
+
expected: _.joinValues(a),
|
|
2374
|
+
received: r.parsedType,
|
|
2375
|
+
code: d.invalid_type
|
|
2376
|
+
}), m;
|
|
2377
|
+
}
|
|
2378
|
+
if (this._cache || (this._cache = new Set(_.getValidEnumValues(this._def.values))), !this._cache.has(e.data)) {
|
|
2379
|
+
const a = _.objectValues(t);
|
|
2380
|
+
return c(r, {
|
|
2381
|
+
received: r.data,
|
|
2382
|
+
code: d.invalid_enum_value,
|
|
2383
|
+
options: a
|
|
2384
|
+
}), m;
|
|
2385
|
+
}
|
|
2386
|
+
return w(e.data);
|
|
2387
|
+
}
|
|
2388
|
+
get enum() {
|
|
2389
|
+
return this._def.values;
|
|
2390
|
+
}
|
|
2391
|
+
}
|
|
2392
|
+
_e.create = (s, e) => new _e({
|
|
2393
|
+
values: s,
|
|
2394
|
+
typeName: p.ZodNativeEnum,
|
|
2395
|
+
...g(e)
|
|
2396
|
+
});
|
|
2397
|
+
class H extends y {
|
|
2398
|
+
unwrap() {
|
|
2399
|
+
return this._def.type;
|
|
2400
|
+
}
|
|
2401
|
+
_parse(e) {
|
|
2402
|
+
const { ctx: t } = this._processInputParams(e);
|
|
2403
|
+
if (t.parsedType !== u.promise && t.common.async === !1)
|
|
2404
|
+
return c(t, {
|
|
2405
|
+
code: d.invalid_type,
|
|
2406
|
+
expected: u.promise,
|
|
2407
|
+
received: t.parsedType
|
|
2408
|
+
}), m;
|
|
2409
|
+
const r = t.parsedType === u.promise ? t.data : Promise.resolve(t.data);
|
|
2410
|
+
return w(r.then((a) => this._def.type.parseAsync(a, {
|
|
2411
|
+
path: t.path,
|
|
2412
|
+
errorMap: t.common.contextualErrorMap
|
|
2413
|
+
})));
|
|
2414
|
+
}
|
|
2415
|
+
}
|
|
2416
|
+
H.create = (s, e) => new H({
|
|
2417
|
+
type: s,
|
|
2418
|
+
typeName: p.ZodPromise,
|
|
2419
|
+
...g(e)
|
|
2420
|
+
});
|
|
2421
|
+
class L extends y {
|
|
2422
|
+
innerType() {
|
|
2423
|
+
return this._def.schema;
|
|
2424
|
+
}
|
|
2425
|
+
sourceType() {
|
|
2426
|
+
return this._def.schema._def.typeName === p.ZodEffects ? this._def.schema.sourceType() : this._def.schema;
|
|
2427
|
+
}
|
|
2428
|
+
_parse(e) {
|
|
2429
|
+
const { status: t, ctx: r } = this._processInputParams(e), a = this._def.effect || null, n = {
|
|
2430
|
+
addIssue: (i) => {
|
|
2431
|
+
c(r, i), i.fatal ? t.abort() : t.dirty();
|
|
2432
|
+
},
|
|
2433
|
+
get path() {
|
|
2434
|
+
return r.path;
|
|
2435
|
+
}
|
|
2436
|
+
};
|
|
2437
|
+
if (n.addIssue = n.addIssue.bind(n), a.type === "preprocess") {
|
|
2438
|
+
const i = a.transform(r.data, n);
|
|
2439
|
+
if (r.common.async)
|
|
2440
|
+
return Promise.resolve(i).then(async (o) => {
|
|
2441
|
+
if (t.value === "aborted")
|
|
2442
|
+
return m;
|
|
2443
|
+
const f = await this._def.schema._parseAsync({
|
|
2444
|
+
data: o,
|
|
2445
|
+
path: r.path,
|
|
2446
|
+
parent: r
|
|
2447
|
+
});
|
|
2448
|
+
return f.status === "aborted" ? m : f.status === "dirty" || t.value === "dirty" ? z(f.value) : f;
|
|
2449
|
+
});
|
|
2450
|
+
{
|
|
2451
|
+
if (t.value === "aborted")
|
|
2452
|
+
return m;
|
|
2453
|
+
const o = this._def.schema._parseSync({
|
|
2454
|
+
data: i,
|
|
2455
|
+
path: r.path,
|
|
2456
|
+
parent: r
|
|
2457
|
+
});
|
|
2458
|
+
return o.status === "aborted" ? m : o.status === "dirty" || t.value === "dirty" ? z(o.value) : o;
|
|
2459
|
+
}
|
|
2460
|
+
}
|
|
2461
|
+
if (a.type === "refinement") {
|
|
2462
|
+
const i = (o) => {
|
|
2463
|
+
const f = a.refinement(o, n);
|
|
2464
|
+
if (r.common.async)
|
|
2465
|
+
return Promise.resolve(f);
|
|
2466
|
+
if (f instanceof Promise)
|
|
2467
|
+
throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");
|
|
2468
|
+
return o;
|
|
2469
|
+
};
|
|
2470
|
+
if (r.common.async === !1) {
|
|
2471
|
+
const o = this._def.schema._parseSync({
|
|
2472
|
+
data: r.data,
|
|
2473
|
+
path: r.path,
|
|
2474
|
+
parent: r
|
|
2475
|
+
});
|
|
2476
|
+
return o.status === "aborted" ? m : (o.status === "dirty" && t.dirty(), i(o.value), { status: t.value, value: o.value });
|
|
2477
|
+
} else
|
|
2478
|
+
return this._def.schema._parseAsync({ data: r.data, path: r.path, parent: r }).then((o) => o.status === "aborted" ? m : (o.status === "dirty" && t.dirty(), i(o.value).then(() => ({ status: t.value, value: o.value }))));
|
|
2479
|
+
}
|
|
2480
|
+
if (a.type === "transform")
|
|
2481
|
+
if (r.common.async === !1) {
|
|
2482
|
+
const i = this._def.schema._parseSync({
|
|
2483
|
+
data: r.data,
|
|
2484
|
+
path: r.path,
|
|
2485
|
+
parent: r
|
|
2486
|
+
});
|
|
2487
|
+
if (!j(i))
|
|
2488
|
+
return m;
|
|
2489
|
+
const o = a.transform(i.value, n);
|
|
2490
|
+
if (o instanceof Promise)
|
|
2491
|
+
throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");
|
|
2492
|
+
return { status: t.value, value: o };
|
|
2493
|
+
} else
|
|
2494
|
+
return this._def.schema._parseAsync({ data: r.data, path: r.path, parent: r }).then((i) => j(i) ? Promise.resolve(a.transform(i.value, n)).then((o) => ({
|
|
2495
|
+
status: t.value,
|
|
2496
|
+
value: o
|
|
2497
|
+
})) : m);
|
|
2498
|
+
_.assertNever(a);
|
|
2499
|
+
}
|
|
2500
|
+
}
|
|
2501
|
+
L.create = (s, e, t) => new L({
|
|
2502
|
+
schema: s,
|
|
2503
|
+
typeName: p.ZodEffects,
|
|
2504
|
+
effect: e,
|
|
2505
|
+
...g(t)
|
|
2506
|
+
});
|
|
2507
|
+
L.createWithPreprocess = (s, e, t) => new L({
|
|
2508
|
+
schema: e,
|
|
2509
|
+
effect: { type: "preprocess", transform: s },
|
|
2510
|
+
typeName: p.ZodEffects,
|
|
2511
|
+
...g(t)
|
|
2512
|
+
});
|
|
2513
|
+
class O extends y {
|
|
2514
|
+
_parse(e) {
|
|
2515
|
+
return this._getType(e) === u.undefined ? w(void 0) : this._def.innerType._parse(e);
|
|
2516
|
+
}
|
|
2517
|
+
unwrap() {
|
|
2518
|
+
return this._def.innerType;
|
|
2519
|
+
}
|
|
2520
|
+
}
|
|
2521
|
+
O.create = (s, e) => new O({
|
|
2522
|
+
innerType: s,
|
|
2523
|
+
typeName: p.ZodOptional,
|
|
2524
|
+
...g(e)
|
|
2525
|
+
});
|
|
2526
|
+
class P extends y {
|
|
2527
|
+
_parse(e) {
|
|
2528
|
+
return this._getType(e) === u.null ? w(null) : this._def.innerType._parse(e);
|
|
2529
|
+
}
|
|
2530
|
+
unwrap() {
|
|
2531
|
+
return this._def.innerType;
|
|
2532
|
+
}
|
|
2533
|
+
}
|
|
2534
|
+
P.create = (s, e) => new P({
|
|
2535
|
+
innerType: s,
|
|
2536
|
+
typeName: p.ZodNullable,
|
|
2537
|
+
...g(e)
|
|
2538
|
+
});
|
|
2539
|
+
class K extends y {
|
|
2540
|
+
_parse(e) {
|
|
2541
|
+
const { ctx: t } = this._processInputParams(e);
|
|
2542
|
+
let r = t.data;
|
|
2543
|
+
return t.parsedType === u.undefined && (r = this._def.defaultValue()), this._def.innerType._parse({
|
|
2544
|
+
data: r,
|
|
2545
|
+
path: t.path,
|
|
2546
|
+
parent: t
|
|
2547
|
+
});
|
|
2548
|
+
}
|
|
2549
|
+
removeDefault() {
|
|
2550
|
+
return this._def.innerType;
|
|
2551
|
+
}
|
|
2552
|
+
}
|
|
2553
|
+
K.create = (s, e) => new K({
|
|
2554
|
+
innerType: s,
|
|
2555
|
+
typeName: p.ZodDefault,
|
|
2556
|
+
defaultValue: typeof e.default == "function" ? e.default : () => e.default,
|
|
2557
|
+
...g(e)
|
|
2558
|
+
});
|
|
2559
|
+
class ee extends y {
|
|
2560
|
+
_parse(e) {
|
|
2561
|
+
const { ctx: t } = this._processInputParams(e), r = {
|
|
2562
|
+
...t,
|
|
2563
|
+
common: {
|
|
2564
|
+
...t.common,
|
|
2565
|
+
issues: []
|
|
2566
|
+
}
|
|
2567
|
+
}, a = this._def.innerType._parse({
|
|
2568
|
+
data: r.data,
|
|
2569
|
+
path: r.path,
|
|
2570
|
+
parent: {
|
|
2571
|
+
...r
|
|
2572
|
+
}
|
|
2573
|
+
});
|
|
2574
|
+
return F(a) ? a.then((n) => ({
|
|
2575
|
+
status: "valid",
|
|
2576
|
+
value: n.status === "valid" ? n.value : this._def.catchValue({
|
|
2577
|
+
get error() {
|
|
2578
|
+
return new T(r.common.issues);
|
|
2579
|
+
},
|
|
2580
|
+
input: r.data
|
|
2581
|
+
})
|
|
2582
|
+
})) : {
|
|
2583
|
+
status: "valid",
|
|
2584
|
+
value: a.status === "valid" ? a.value : this._def.catchValue({
|
|
2585
|
+
get error() {
|
|
2586
|
+
return new T(r.common.issues);
|
|
2587
|
+
},
|
|
2588
|
+
input: r.data
|
|
2589
|
+
})
|
|
2590
|
+
};
|
|
2591
|
+
}
|
|
2592
|
+
removeCatch() {
|
|
2593
|
+
return this._def.innerType;
|
|
2594
|
+
}
|
|
2595
|
+
}
|
|
2596
|
+
ee.create = (s, e) => new ee({
|
|
2597
|
+
innerType: s,
|
|
2598
|
+
typeName: p.ZodCatch,
|
|
2599
|
+
catchValue: typeof e.catch == "function" ? e.catch : () => e.catch,
|
|
2600
|
+
...g(e)
|
|
2601
|
+
});
|
|
2602
|
+
class ve extends y {
|
|
2603
|
+
_parse(e) {
|
|
2604
|
+
if (this._getType(e) !== u.nan) {
|
|
2605
|
+
const r = this._getOrReturnCtx(e);
|
|
2606
|
+
return c(r, {
|
|
2607
|
+
code: d.invalid_type,
|
|
2608
|
+
expected: u.nan,
|
|
2609
|
+
received: r.parsedType
|
|
2610
|
+
}), m;
|
|
2611
|
+
}
|
|
2612
|
+
return { status: "valid", value: e.data };
|
|
2613
|
+
}
|
|
2614
|
+
}
|
|
2615
|
+
ve.create = (s) => new ve({
|
|
2616
|
+
typeName: p.ZodNaN,
|
|
2617
|
+
...g(s)
|
|
2618
|
+
});
|
|
2619
|
+
class ot extends y {
|
|
2620
|
+
_parse(e) {
|
|
2621
|
+
const { ctx: t } = this._processInputParams(e), r = t.data;
|
|
2622
|
+
return this._def.type._parse({
|
|
2623
|
+
data: r,
|
|
2624
|
+
path: t.path,
|
|
2625
|
+
parent: t
|
|
2626
|
+
});
|
|
2627
|
+
}
|
|
2628
|
+
unwrap() {
|
|
2629
|
+
return this._def.type;
|
|
2630
|
+
}
|
|
2631
|
+
}
|
|
2632
|
+
class se extends y {
|
|
2633
|
+
_parse(e) {
|
|
2634
|
+
const { status: t, ctx: r } = this._processInputParams(e);
|
|
2635
|
+
if (r.common.async)
|
|
2636
|
+
return (async () => {
|
|
2637
|
+
const n = await this._def.in._parseAsync({
|
|
2638
|
+
data: r.data,
|
|
2639
|
+
path: r.path,
|
|
2640
|
+
parent: r
|
|
2641
|
+
});
|
|
2642
|
+
return n.status === "aborted" ? m : n.status === "dirty" ? (t.dirty(), z(n.value)) : this._def.out._parseAsync({
|
|
2643
|
+
data: n.value,
|
|
2644
|
+
path: r.path,
|
|
2645
|
+
parent: r
|
|
2646
|
+
});
|
|
2647
|
+
})();
|
|
2648
|
+
{
|
|
2649
|
+
const a = this._def.in._parseSync({
|
|
2650
|
+
data: r.data,
|
|
2651
|
+
path: r.path,
|
|
2652
|
+
parent: r
|
|
2653
|
+
});
|
|
2654
|
+
return a.status === "aborted" ? m : a.status === "dirty" ? (t.dirty(), {
|
|
2655
|
+
status: "dirty",
|
|
2656
|
+
value: a.value
|
|
2657
|
+
}) : this._def.out._parseSync({
|
|
2658
|
+
data: a.value,
|
|
2659
|
+
path: r.path,
|
|
2660
|
+
parent: r
|
|
2661
|
+
});
|
|
2662
|
+
}
|
|
2663
|
+
}
|
|
2664
|
+
static create(e, t) {
|
|
2665
|
+
return new se({
|
|
2666
|
+
in: e,
|
|
2667
|
+
out: t,
|
|
2668
|
+
typeName: p.ZodPipeline
|
|
2669
|
+
});
|
|
2670
|
+
}
|
|
2671
|
+
}
|
|
2672
|
+
class te extends y {
|
|
2673
|
+
_parse(e) {
|
|
2674
|
+
const t = this._def.innerType._parse(e), r = (a) => (j(a) && (a.value = Object.freeze(a.value)), a);
|
|
2675
|
+
return F(t) ? t.then((a) => r(a)) : r(t);
|
|
2676
|
+
}
|
|
2677
|
+
unwrap() {
|
|
2678
|
+
return this._def.innerType;
|
|
2679
|
+
}
|
|
2680
|
+
}
|
|
2681
|
+
te.create = (s, e) => new te({
|
|
2682
|
+
innerType: s,
|
|
2683
|
+
typeName: p.ZodReadonly,
|
|
2684
|
+
...g(e)
|
|
2685
|
+
});
|
|
2686
|
+
var p;
|
|
2687
|
+
(function(s) {
|
|
2688
|
+
s.ZodString = "ZodString", s.ZodNumber = "ZodNumber", s.ZodNaN = "ZodNaN", s.ZodBigInt = "ZodBigInt", s.ZodBoolean = "ZodBoolean", s.ZodDate = "ZodDate", s.ZodSymbol = "ZodSymbol", s.ZodUndefined = "ZodUndefined", s.ZodNull = "ZodNull", s.ZodAny = "ZodAny", s.ZodUnknown = "ZodUnknown", s.ZodNever = "ZodNever", s.ZodVoid = "ZodVoid", s.ZodArray = "ZodArray", s.ZodObject = "ZodObject", s.ZodUnion = "ZodUnion", s.ZodDiscriminatedUnion = "ZodDiscriminatedUnion", s.ZodIntersection = "ZodIntersection", s.ZodTuple = "ZodTuple", s.ZodRecord = "ZodRecord", s.ZodMap = "ZodMap", s.ZodSet = "ZodSet", s.ZodFunction = "ZodFunction", s.ZodLazy = "ZodLazy", s.ZodLiteral = "ZodLiteral", s.ZodEnum = "ZodEnum", s.ZodEffects = "ZodEffects", s.ZodNativeEnum = "ZodNativeEnum", s.ZodOptional = "ZodOptional", s.ZodNullable = "ZodNullable", s.ZodDefault = "ZodDefault", s.ZodCatch = "ZodCatch", s.ZodPromise = "ZodPromise", s.ZodBranded = "ZodBranded", s.ZodPipeline = "ZodPipeline", s.ZodReadonly = "ZodReadonly";
|
|
2689
|
+
})(p || (p = {}));
|
|
2690
|
+
const Z = $.create;
|
|
2691
|
+
N.create;
|
|
2692
|
+
const dt = C.create, Ce = x.create;
|
|
2693
|
+
q.create;
|
|
2694
|
+
J.create;
|
|
2695
|
+
I.create;
|
|
2696
|
+
V.create;
|
|
2697
|
+
H.create;
|
|
2698
|
+
O.create;
|
|
2699
|
+
P.create;
|
|
2700
|
+
const _t = (s) => Ce({
|
|
2701
|
+
pages: Z(),
|
|
2702
|
+
nextPage: Z().optional(),
|
|
2703
|
+
totalElements: Z(),
|
|
2704
|
+
currentPage: Z(),
|
|
2705
|
+
pageSize: Z(),
|
|
2706
|
+
elements: dt(s)
|
|
2707
|
+
}), vt = Ce({
|
|
2708
|
+
page: Z(),
|
|
2709
|
+
pageSize: Z()
|
|
2710
|
+
});
|
|
2711
|
+
export {
|
|
2712
|
+
lt as Fail,
|
|
2713
|
+
ft as Failure,
|
|
2714
|
+
M as Guid,
|
|
2715
|
+
ut as Ok,
|
|
2716
|
+
vt as PageQuery,
|
|
2717
|
+
_t as createPageSchema,
|
|
2718
|
+
Se as formatDate,
|
|
2719
|
+
yt as formatDateTime,
|
|
2720
|
+
Oe as formatTime,
|
|
2721
|
+
mt as isFailure,
|
|
2722
|
+
ct as mock,
|
|
2723
|
+
ht as notFailure,
|
|
2724
|
+
pt as parseConfig,
|
|
2725
|
+
gt as sleep
|
|
2726
|
+
};
|