@volverjs/form-vue 1.1.0-beta.2 → 1.1.0-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.es.js +631 -3986
- package/dist/index.umd.js +1 -3
- package/dist/utils.d.ts +7 -0
- package/package.json +9 -9
- package/src/utils.ts +45 -32
package/dist/index.es.js
CHANGED
|
@@ -1,3456 +1,164 @@
|
|
|
1
|
-
import { ref as
|
|
2
|
-
import { watchIgnorable as
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}, r.getValidEnumValues = (n) => {
|
|
19
|
-
const a = r.objectKeys(n).filter((o) => typeof n[n[o]] != "number"), i = {};
|
|
20
|
-
for (const o of a)
|
|
21
|
-
i[o] = n[o];
|
|
22
|
-
return r.objectValues(i);
|
|
23
|
-
}, r.objectValues = (n) => r.objectKeys(n).map(function(a) {
|
|
24
|
-
return n[a];
|
|
25
|
-
}), r.objectKeys = typeof Object.keys == "function" ? (n) => Object.keys(n) : (n) => {
|
|
26
|
-
const a = [];
|
|
27
|
-
for (const i in n)
|
|
28
|
-
Object.prototype.hasOwnProperty.call(n, i) && a.push(i);
|
|
29
|
-
return a;
|
|
30
|
-
}, r.find = (n, a) => {
|
|
31
|
-
for (const i of n)
|
|
32
|
-
if (a(i))
|
|
33
|
-
return i;
|
|
34
|
-
}, r.isInteger = typeof Number.isInteger == "function" ? (n) => Number.isInteger(n) : (n) => typeof n == "number" && Number.isFinite(n) && Math.floor(n) === n;
|
|
35
|
-
function s(n, a = " | ") {
|
|
36
|
-
return n.map((i) => typeof i == "string" ? `'${i}'` : i).join(a);
|
|
37
|
-
}
|
|
38
|
-
r.joinValues = s, r.jsonStringifyReplacer = (n, a) => typeof a == "bigint" ? a.toString() : a;
|
|
39
|
-
})(V || (V = {}));
|
|
40
|
-
var qe;
|
|
41
|
-
(function(r) {
|
|
42
|
-
r.mergeShapes = (e, t) => ({
|
|
43
|
-
...e,
|
|
44
|
-
...t
|
|
45
|
-
// second overwrites first
|
|
46
|
-
});
|
|
47
|
-
})(qe || (qe = {}));
|
|
48
|
-
const y = V.arrayToEnum([
|
|
49
|
-
"string",
|
|
50
|
-
"nan",
|
|
51
|
-
"number",
|
|
52
|
-
"integer",
|
|
53
|
-
"float",
|
|
54
|
-
"boolean",
|
|
55
|
-
"date",
|
|
56
|
-
"bigint",
|
|
57
|
-
"symbol",
|
|
58
|
-
"function",
|
|
59
|
-
"undefined",
|
|
60
|
-
"null",
|
|
61
|
-
"array",
|
|
62
|
-
"object",
|
|
63
|
-
"unknown",
|
|
64
|
-
"promise",
|
|
65
|
-
"void",
|
|
66
|
-
"never",
|
|
67
|
-
"map",
|
|
68
|
-
"set"
|
|
69
|
-
]), te = (r) => {
|
|
70
|
-
switch (typeof r) {
|
|
71
|
-
case "undefined":
|
|
72
|
-
return y.undefined;
|
|
73
|
-
case "string":
|
|
74
|
-
return y.string;
|
|
75
|
-
case "number":
|
|
76
|
-
return Number.isNaN(r) ? y.nan : y.number;
|
|
77
|
-
case "boolean":
|
|
78
|
-
return y.boolean;
|
|
79
|
-
case "function":
|
|
80
|
-
return y.function;
|
|
81
|
-
case "bigint":
|
|
82
|
-
return y.bigint;
|
|
83
|
-
case "symbol":
|
|
84
|
-
return y.symbol;
|
|
85
|
-
case "object":
|
|
86
|
-
return Array.isArray(r) ? y.array : r === null ? y.null : r.then && typeof r.then == "function" && r.catch && typeof r.catch == "function" ? y.promise : typeof Map < "u" && r instanceof Map ? y.map : typeof Set < "u" && r instanceof Set ? y.set : typeof Date < "u" && r instanceof Date ? y.date : y.object;
|
|
87
|
-
default:
|
|
88
|
-
return y.unknown;
|
|
89
|
-
}
|
|
90
|
-
}, p = V.arrayToEnum([
|
|
91
|
-
"invalid_type",
|
|
92
|
-
"invalid_literal",
|
|
93
|
-
"custom",
|
|
94
|
-
"invalid_union",
|
|
95
|
-
"invalid_union_discriminator",
|
|
96
|
-
"invalid_enum_value",
|
|
97
|
-
"unrecognized_keys",
|
|
98
|
-
"invalid_arguments",
|
|
99
|
-
"invalid_return_type",
|
|
100
|
-
"invalid_date",
|
|
101
|
-
"invalid_string",
|
|
102
|
-
"too_small",
|
|
103
|
-
"too_big",
|
|
104
|
-
"invalid_intersection_types",
|
|
105
|
-
"not_multiple_of",
|
|
106
|
-
"not_finite"
|
|
107
|
-
]);
|
|
108
|
-
class q extends Error {
|
|
109
|
-
get errors() {
|
|
110
|
-
return this.issues;
|
|
111
|
-
}
|
|
112
|
-
constructor(e) {
|
|
113
|
-
super(), this.issues = [], this.addIssue = (s) => {
|
|
114
|
-
this.issues = [...this.issues, s];
|
|
115
|
-
}, this.addIssues = (s = []) => {
|
|
116
|
-
this.issues = [...this.issues, ...s];
|
|
117
|
-
};
|
|
118
|
-
const t = new.target.prototype;
|
|
119
|
-
Object.setPrototypeOf ? Object.setPrototypeOf(this, t) : this.__proto__ = t, this.name = "ZodError", this.issues = e;
|
|
120
|
-
}
|
|
121
|
-
format(e) {
|
|
122
|
-
const t = e || function(a) {
|
|
123
|
-
return a.message;
|
|
124
|
-
}, s = { _errors: [] }, n = (a) => {
|
|
125
|
-
for (const i of a.issues)
|
|
126
|
-
if (i.code === "invalid_union")
|
|
127
|
-
i.unionErrors.map(n);
|
|
128
|
-
else if (i.code === "invalid_return_type")
|
|
129
|
-
n(i.returnTypeError);
|
|
130
|
-
else if (i.code === "invalid_arguments")
|
|
131
|
-
n(i.argumentsError);
|
|
132
|
-
else if (i.path.length === 0)
|
|
133
|
-
s._errors.push(t(i));
|
|
134
|
-
else {
|
|
135
|
-
let o = s, u = 0;
|
|
136
|
-
for (; u < i.path.length; ) {
|
|
137
|
-
const l = i.path[u];
|
|
138
|
-
u === i.path.length - 1 ? (o[l] = o[l] || { _errors: [] }, o[l]._errors.push(t(i))) : o[l] = o[l] || { _errors: [] }, o = o[l], u++;
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
};
|
|
142
|
-
return n(this), s;
|
|
143
|
-
}
|
|
144
|
-
static assert(e) {
|
|
145
|
-
if (!(e instanceof q))
|
|
146
|
-
throw new Error(`Not a ZodError: ${e}`);
|
|
147
|
-
}
|
|
148
|
-
toString() {
|
|
149
|
-
return this.message;
|
|
150
|
-
}
|
|
151
|
-
get message() {
|
|
152
|
-
return JSON.stringify(this.issues, V.jsonStringifyReplacer, 2);
|
|
153
|
-
}
|
|
154
|
-
get isEmpty() {
|
|
155
|
-
return this.issues.length === 0;
|
|
156
|
-
}
|
|
157
|
-
flatten(e = (t) => t.message) {
|
|
158
|
-
const t = {}, s = [];
|
|
159
|
-
for (const n of this.issues)
|
|
160
|
-
if (n.path.length > 0) {
|
|
161
|
-
const a = n.path[0];
|
|
162
|
-
t[a] = t[a] || [], t[a].push(e(n));
|
|
163
|
-
} else
|
|
164
|
-
s.push(e(n));
|
|
165
|
-
return { formErrors: s, fieldErrors: t };
|
|
166
|
-
}
|
|
167
|
-
get formErrors() {
|
|
168
|
-
return this.flatten();
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
q.create = (r) => new q(r);
|
|
172
|
-
const Pe = (r, e) => {
|
|
173
|
-
let t;
|
|
174
|
-
switch (r.code) {
|
|
175
|
-
case p.invalid_type:
|
|
176
|
-
r.received === y.undefined ? t = "Required" : t = `Expected ${r.expected}, received ${r.received}`;
|
|
177
|
-
break;
|
|
178
|
-
case p.invalid_literal:
|
|
179
|
-
t = `Invalid literal value, expected ${JSON.stringify(r.expected, V.jsonStringifyReplacer)}`;
|
|
180
|
-
break;
|
|
181
|
-
case p.unrecognized_keys:
|
|
182
|
-
t = `Unrecognized key(s) in object: ${V.joinValues(r.keys, ", ")}`;
|
|
183
|
-
break;
|
|
184
|
-
case p.invalid_union:
|
|
185
|
-
t = "Invalid input";
|
|
186
|
-
break;
|
|
187
|
-
case p.invalid_union_discriminator:
|
|
188
|
-
t = `Invalid discriminator value. Expected ${V.joinValues(r.options)}`;
|
|
189
|
-
break;
|
|
190
|
-
case p.invalid_enum_value:
|
|
191
|
-
t = `Invalid enum value. Expected ${V.joinValues(r.options)}, received '${r.received}'`;
|
|
192
|
-
break;
|
|
193
|
-
case p.invalid_arguments:
|
|
194
|
-
t = "Invalid function arguments";
|
|
195
|
-
break;
|
|
196
|
-
case p.invalid_return_type:
|
|
197
|
-
t = "Invalid function return type";
|
|
198
|
-
break;
|
|
199
|
-
case p.invalid_date:
|
|
200
|
-
t = "Invalid date";
|
|
201
|
-
break;
|
|
202
|
-
case p.invalid_string:
|
|
203
|
-
typeof r.validation == "object" ? "includes" in r.validation ? (t = `Invalid input: must include "${r.validation.includes}"`, typeof r.validation.position == "number" && (t = `${t} at one or more positions greater than or equal to ${r.validation.position}`)) : "startsWith" in r.validation ? t = `Invalid input: must start with "${r.validation.startsWith}"` : "endsWith" in r.validation ? t = `Invalid input: must end with "${r.validation.endsWith}"` : V.assertNever(r.validation) : r.validation !== "regex" ? t = `Invalid ${r.validation}` : t = "Invalid";
|
|
204
|
-
break;
|
|
205
|
-
case p.too_small:
|
|
206
|
-
r.type === "array" ? t = `Array must contain ${r.exact ? "exactly" : r.inclusive ? "at least" : "more than"} ${r.minimum} element(s)` : r.type === "string" ? t = `String must contain ${r.exact ? "exactly" : r.inclusive ? "at least" : "over"} ${r.minimum} character(s)` : r.type === "number" ? t = `Number must be ${r.exact ? "exactly equal to " : r.inclusive ? "greater than or equal to " : "greater than "}${r.minimum}` : r.type === "bigint" ? t = `Number must be ${r.exact ? "exactly equal to " : r.inclusive ? "greater than or equal to " : "greater than "}${r.minimum}` : r.type === "date" ? t = `Date must be ${r.exact ? "exactly equal to " : r.inclusive ? "greater than or equal to " : "greater than "}${new Date(Number(r.minimum))}` : t = "Invalid input";
|
|
207
|
-
break;
|
|
208
|
-
case p.too_big:
|
|
209
|
-
r.type === "array" ? t = `Array must contain ${r.exact ? "exactly" : r.inclusive ? "at most" : "less than"} ${r.maximum} element(s)` : r.type === "string" ? t = `String must contain ${r.exact ? "exactly" : r.inclusive ? "at most" : "under"} ${r.maximum} character(s)` : r.type === "number" ? t = `Number must be ${r.exact ? "exactly" : r.inclusive ? "less than or equal to" : "less than"} ${r.maximum}` : r.type === "bigint" ? t = `BigInt must be ${r.exact ? "exactly" : r.inclusive ? "less than or equal to" : "less than"} ${r.maximum}` : r.type === "date" ? t = `Date must be ${r.exact ? "exactly" : r.inclusive ? "smaller than or equal to" : "smaller than"} ${new Date(Number(r.maximum))}` : t = "Invalid input";
|
|
210
|
-
break;
|
|
211
|
-
case p.custom:
|
|
212
|
-
t = "Invalid input";
|
|
213
|
-
break;
|
|
214
|
-
case p.invalid_intersection_types:
|
|
215
|
-
t = "Intersection results could not be merged";
|
|
216
|
-
break;
|
|
217
|
-
case p.not_multiple_of:
|
|
218
|
-
t = `Number must be a multiple of ${r.multipleOf}`;
|
|
219
|
-
break;
|
|
220
|
-
case p.not_finite:
|
|
221
|
-
t = "Number must be finite";
|
|
222
|
-
break;
|
|
223
|
-
default:
|
|
224
|
-
t = e.defaultError, V.assertNever(r);
|
|
225
|
-
}
|
|
226
|
-
return { message: t };
|
|
227
|
-
};
|
|
228
|
-
let Zt = Pe;
|
|
229
|
-
function $t() {
|
|
230
|
-
return Zt;
|
|
231
|
-
}
|
|
232
|
-
const Pt = (r) => {
|
|
233
|
-
const { data: e, path: t, errorMaps: s, issueData: n } = r, a = [...t, ...n.path || []], i = {
|
|
234
|
-
...n,
|
|
235
|
-
path: a
|
|
236
|
-
};
|
|
237
|
-
if (n.message !== void 0)
|
|
238
|
-
return {
|
|
239
|
-
...n,
|
|
240
|
-
path: a,
|
|
241
|
-
message: n.message
|
|
242
|
-
};
|
|
243
|
-
let o = "";
|
|
244
|
-
const u = s.filter((l) => !!l).slice().reverse();
|
|
245
|
-
for (const l of u)
|
|
246
|
-
o = l(i, { data: e, defaultError: o }).message;
|
|
247
|
-
return {
|
|
248
|
-
...n,
|
|
249
|
-
path: a,
|
|
250
|
-
message: o
|
|
251
|
-
};
|
|
252
|
-
};
|
|
253
|
-
function v(r, e) {
|
|
254
|
-
const t = $t(), s = Pt({
|
|
255
|
-
issueData: e,
|
|
256
|
-
data: r.data,
|
|
257
|
-
path: r.path,
|
|
258
|
-
errorMaps: [
|
|
259
|
-
r.common.contextualErrorMap,
|
|
260
|
-
// contextual error map is first priority
|
|
261
|
-
r.schemaErrorMap,
|
|
262
|
-
// then schema-bound map if available
|
|
263
|
-
t,
|
|
264
|
-
// then global override map
|
|
265
|
-
t === Pe ? void 0 : Pe
|
|
266
|
-
// then global default map
|
|
267
|
-
].filter((n) => !!n)
|
|
268
|
-
});
|
|
269
|
-
r.common.issues.push(s);
|
|
270
|
-
}
|
|
271
|
-
class M {
|
|
272
|
-
constructor() {
|
|
273
|
-
this.value = "valid";
|
|
274
|
-
}
|
|
275
|
-
dirty() {
|
|
276
|
-
this.value === "valid" && (this.value = "dirty");
|
|
277
|
-
}
|
|
278
|
-
abort() {
|
|
279
|
-
this.value !== "aborted" && (this.value = "aborted");
|
|
280
|
-
}
|
|
281
|
-
static mergeArray(e, t) {
|
|
282
|
-
const s = [];
|
|
283
|
-
for (const n of t) {
|
|
284
|
-
if (n.status === "aborted")
|
|
285
|
-
return S;
|
|
286
|
-
n.status === "dirty" && e.dirty(), s.push(n.value);
|
|
287
|
-
}
|
|
288
|
-
return { status: e.value, value: s };
|
|
289
|
-
}
|
|
290
|
-
static async mergeObjectAsync(e, t) {
|
|
291
|
-
const s = [];
|
|
292
|
-
for (const n of t) {
|
|
293
|
-
const a = await n.key, i = await n.value;
|
|
294
|
-
s.push({
|
|
295
|
-
key: a,
|
|
296
|
-
value: i
|
|
297
|
-
});
|
|
298
|
-
}
|
|
299
|
-
return M.mergeObjectSync(e, s);
|
|
300
|
-
}
|
|
301
|
-
static mergeObjectSync(e, t) {
|
|
302
|
-
const s = {};
|
|
303
|
-
for (const n of t) {
|
|
304
|
-
const { key: a, value: i } = n;
|
|
305
|
-
if (a.status === "aborted" || i.status === "aborted")
|
|
306
|
-
return S;
|
|
307
|
-
a.status === "dirty" && e.dirty(), i.status === "dirty" && e.dirty(), a.value !== "__proto__" && (typeof i.value < "u" || n.alwaysSet) && (s[a.value] = i.value);
|
|
308
|
-
}
|
|
309
|
-
return { status: e.value, value: s };
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
const S = Object.freeze({
|
|
313
|
-
status: "aborted"
|
|
314
|
-
}), pe = (r) => ({ status: "dirty", value: r }), U = (r) => ({ status: "valid", value: r }), Ke = (r) => r.status === "aborted", Ye = (r) => r.status === "dirty", de = (r) => r.status === "valid", Se = (r) => typeof Promise < "u" && r instanceof Promise;
|
|
315
|
-
var _;
|
|
316
|
-
(function(r) {
|
|
317
|
-
r.errToObj = (e) => typeof e == "string" ? { message: e } : e || {}, r.toString = (e) => typeof e == "string" ? e : e?.message;
|
|
318
|
-
})(_ || (_ = {}));
|
|
319
|
-
class K {
|
|
320
|
-
constructor(e, t, s, n) {
|
|
321
|
-
this._cachedPath = [], this.parent = e, this.data = t, this._path = s, this._key = n;
|
|
322
|
-
}
|
|
323
|
-
get path() {
|
|
324
|
-
return this._cachedPath.length || (Array.isArray(this._key) ? this._cachedPath.push(...this._path, ...this._key) : this._cachedPath.push(...this._path, this._key)), this._cachedPath;
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
const He = (r, e) => {
|
|
328
|
-
if (de(e))
|
|
329
|
-
return { success: !0, data: e.value };
|
|
330
|
-
if (!r.common.issues.length)
|
|
331
|
-
throw new Error("Validation failed but no issues detected.");
|
|
332
|
-
return {
|
|
333
|
-
success: !1,
|
|
334
|
-
get error() {
|
|
335
|
-
if (this._error)
|
|
336
|
-
return this._error;
|
|
337
|
-
const t = new q(r.common.issues);
|
|
338
|
-
return this._error = t, this._error;
|
|
339
|
-
}
|
|
340
|
-
};
|
|
341
|
-
};
|
|
342
|
-
function T(r) {
|
|
343
|
-
if (!r)
|
|
344
|
-
return {};
|
|
345
|
-
const { errorMap: e, invalid_type_error: t, required_error: s, description: n } = r;
|
|
346
|
-
if (e && (t || s))
|
|
347
|
-
throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);
|
|
348
|
-
return e ? { errorMap: e, description: n } : { errorMap: (i, o) => {
|
|
349
|
-
const { message: u } = r;
|
|
350
|
-
return i.code === "invalid_enum_value" ? { message: u ?? o.defaultError } : typeof o.data > "u" ? { message: u ?? s ?? o.defaultError } : i.code !== "invalid_type" ? { message: o.defaultError } : { message: u ?? t ?? o.defaultError };
|
|
351
|
-
}, description: n };
|
|
352
|
-
}
|
|
353
|
-
class I {
|
|
354
|
-
get description() {
|
|
355
|
-
return this._def.description;
|
|
356
|
-
}
|
|
357
|
-
_getType(e) {
|
|
358
|
-
return te(e.data);
|
|
359
|
-
}
|
|
360
|
-
_getOrReturnCtx(e, t) {
|
|
361
|
-
return t || {
|
|
362
|
-
common: e.parent.common,
|
|
363
|
-
data: e.data,
|
|
364
|
-
parsedType: te(e.data),
|
|
365
|
-
schemaErrorMap: this._def.errorMap,
|
|
366
|
-
path: e.path,
|
|
367
|
-
parent: e.parent
|
|
368
|
-
};
|
|
369
|
-
}
|
|
370
|
-
_processInputParams(e) {
|
|
371
|
-
return {
|
|
372
|
-
status: new M(),
|
|
373
|
-
ctx: {
|
|
374
|
-
common: e.parent.common,
|
|
375
|
-
data: e.data,
|
|
376
|
-
parsedType: te(e.data),
|
|
377
|
-
schemaErrorMap: this._def.errorMap,
|
|
378
|
-
path: e.path,
|
|
379
|
-
parent: e.parent
|
|
380
|
-
}
|
|
381
|
-
};
|
|
382
|
-
}
|
|
383
|
-
_parseSync(e) {
|
|
384
|
-
const t = this._parse(e);
|
|
385
|
-
if (Se(t))
|
|
386
|
-
throw new Error("Synchronous parse encountered promise.");
|
|
387
|
-
return t;
|
|
388
|
-
}
|
|
389
|
-
_parseAsync(e) {
|
|
390
|
-
const t = this._parse(e);
|
|
391
|
-
return Promise.resolve(t);
|
|
392
|
-
}
|
|
393
|
-
parse(e, t) {
|
|
394
|
-
const s = this.safeParse(e, t);
|
|
395
|
-
if (s.success)
|
|
396
|
-
return s.data;
|
|
397
|
-
throw s.error;
|
|
398
|
-
}
|
|
399
|
-
safeParse(e, t) {
|
|
400
|
-
const s = {
|
|
401
|
-
common: {
|
|
402
|
-
issues: [],
|
|
403
|
-
async: t?.async ?? !1,
|
|
404
|
-
contextualErrorMap: t?.errorMap
|
|
405
|
-
},
|
|
406
|
-
path: t?.path || [],
|
|
407
|
-
schemaErrorMap: this._def.errorMap,
|
|
408
|
-
parent: null,
|
|
409
|
-
data: e,
|
|
410
|
-
parsedType: te(e)
|
|
411
|
-
}, n = this._parseSync({ data: e, path: s.path, parent: s });
|
|
412
|
-
return He(s, n);
|
|
413
|
-
}
|
|
414
|
-
"~validate"(e) {
|
|
415
|
-
const t = {
|
|
416
|
-
common: {
|
|
417
|
-
issues: [],
|
|
418
|
-
async: !!this["~standard"].async
|
|
419
|
-
},
|
|
420
|
-
path: [],
|
|
421
|
-
schemaErrorMap: this._def.errorMap,
|
|
422
|
-
parent: null,
|
|
423
|
-
data: e,
|
|
424
|
-
parsedType: te(e)
|
|
425
|
-
};
|
|
426
|
-
if (!this["~standard"].async)
|
|
427
|
-
try {
|
|
428
|
-
const s = this._parseSync({ data: e, path: [], parent: t });
|
|
429
|
-
return de(s) ? {
|
|
430
|
-
value: s.value
|
|
431
|
-
} : {
|
|
432
|
-
issues: t.common.issues
|
|
433
|
-
};
|
|
434
|
-
} catch (s) {
|
|
435
|
-
s?.message?.toLowerCase()?.includes("encountered") && (this["~standard"].async = !0), t.common = {
|
|
436
|
-
issues: [],
|
|
437
|
-
async: !0
|
|
438
|
-
};
|
|
439
|
-
}
|
|
440
|
-
return this._parseAsync({ data: e, path: [], parent: t }).then((s) => de(s) ? {
|
|
441
|
-
value: s.value
|
|
442
|
-
} : {
|
|
443
|
-
issues: t.common.issues
|
|
444
|
-
});
|
|
445
|
-
}
|
|
446
|
-
async parseAsync(e, t) {
|
|
447
|
-
const s = await this.safeParseAsync(e, t);
|
|
448
|
-
if (s.success)
|
|
449
|
-
return s.data;
|
|
450
|
-
throw s.error;
|
|
451
|
-
}
|
|
452
|
-
async safeParseAsync(e, t) {
|
|
453
|
-
const s = {
|
|
454
|
-
common: {
|
|
455
|
-
issues: [],
|
|
456
|
-
contextualErrorMap: t?.errorMap,
|
|
457
|
-
async: !0
|
|
458
|
-
},
|
|
459
|
-
path: t?.path || [],
|
|
460
|
-
schemaErrorMap: this._def.errorMap,
|
|
461
|
-
parent: null,
|
|
462
|
-
data: e,
|
|
463
|
-
parsedType: te(e)
|
|
464
|
-
}, n = this._parse({ data: e, path: s.path, parent: s }), a = await (Se(n) ? n : Promise.resolve(n));
|
|
465
|
-
return He(s, a);
|
|
466
|
-
}
|
|
467
|
-
refine(e, t) {
|
|
468
|
-
const s = (n) => typeof t == "string" || typeof t > "u" ? { message: t } : typeof t == "function" ? t(n) : t;
|
|
469
|
-
return this._refinement((n, a) => {
|
|
470
|
-
const i = e(n), o = () => a.addIssue({
|
|
471
|
-
code: p.custom,
|
|
472
|
-
...s(n)
|
|
473
|
-
});
|
|
474
|
-
return typeof Promise < "u" && i instanceof Promise ? i.then((u) => u ? !0 : (o(), !1)) : i ? !0 : (o(), !1);
|
|
475
|
-
});
|
|
476
|
-
}
|
|
477
|
-
refinement(e, t) {
|
|
478
|
-
return this._refinement((s, n) => e(s) ? !0 : (n.addIssue(typeof t == "function" ? t(s, n) : t), !1));
|
|
479
|
-
}
|
|
480
|
-
_refinement(e) {
|
|
481
|
-
return new se({
|
|
482
|
-
schema: this,
|
|
483
|
-
typeName: O.ZodEffects,
|
|
484
|
-
effect: { type: "refinement", refinement: e }
|
|
485
|
-
});
|
|
486
|
-
}
|
|
487
|
-
superRefine(e) {
|
|
488
|
-
return this._refinement(e);
|
|
489
|
-
}
|
|
490
|
-
constructor(e) {
|
|
491
|
-
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"] = {
|
|
492
|
-
version: 1,
|
|
493
|
-
vendor: "zod",
|
|
494
|
-
validate: (t) => this["~validate"](t)
|
|
495
|
-
};
|
|
496
|
-
}
|
|
497
|
-
optional() {
|
|
498
|
-
return G.create(this, this._def);
|
|
499
|
-
}
|
|
500
|
-
nullable() {
|
|
501
|
-
return ae.create(this, this._def);
|
|
502
|
-
}
|
|
503
|
-
nullish() {
|
|
504
|
-
return this.nullable().optional();
|
|
505
|
-
}
|
|
506
|
-
array() {
|
|
507
|
-
return W.create(this);
|
|
508
|
-
}
|
|
509
|
-
promise() {
|
|
510
|
-
return Ce.create(this, this._def);
|
|
511
|
-
}
|
|
512
|
-
or(e) {
|
|
513
|
-
return Te.create([this, e], this._def);
|
|
514
|
-
}
|
|
515
|
-
and(e) {
|
|
516
|
-
return Ne.create(this, e, this._def);
|
|
517
|
-
}
|
|
518
|
-
transform(e) {
|
|
519
|
-
return new se({
|
|
520
|
-
...T(this._def),
|
|
521
|
-
schema: this,
|
|
522
|
-
typeName: O.ZodEffects,
|
|
523
|
-
effect: { type: "transform", transform: e }
|
|
524
|
-
});
|
|
525
|
-
}
|
|
526
|
-
default(e) {
|
|
527
|
-
const t = typeof e == "function" ? e : () => e;
|
|
528
|
-
return new Ee({
|
|
529
|
-
...T(this._def),
|
|
530
|
-
innerType: this,
|
|
531
|
-
defaultValue: t,
|
|
532
|
-
typeName: O.ZodDefault
|
|
533
|
-
});
|
|
534
|
-
}
|
|
535
|
-
brand() {
|
|
536
|
-
return new ir({
|
|
537
|
-
typeName: O.ZodBranded,
|
|
538
|
-
type: this,
|
|
539
|
-
...T(this._def)
|
|
540
|
-
});
|
|
541
|
-
}
|
|
542
|
-
catch(e) {
|
|
543
|
-
const t = typeof e == "function" ? e : () => e;
|
|
544
|
-
return new ze({
|
|
545
|
-
...T(this._def),
|
|
546
|
-
innerType: this,
|
|
547
|
-
catchValue: t,
|
|
548
|
-
typeName: O.ZodCatch
|
|
549
|
-
});
|
|
550
|
-
}
|
|
551
|
-
describe(e) {
|
|
552
|
-
const t = this.constructor;
|
|
553
|
-
return new t({
|
|
554
|
-
...this._def,
|
|
555
|
-
description: e
|
|
556
|
-
});
|
|
557
|
-
}
|
|
558
|
-
pipe(e) {
|
|
559
|
-
return Ue.create(this, e);
|
|
560
|
-
}
|
|
561
|
-
readonly() {
|
|
562
|
-
return Me.create(this);
|
|
563
|
-
}
|
|
564
|
-
isOptional() {
|
|
565
|
-
return this.safeParse(void 0).success;
|
|
566
|
-
}
|
|
567
|
-
isNullable() {
|
|
568
|
-
return this.safeParse(null).success;
|
|
569
|
-
}
|
|
570
|
-
}
|
|
571
|
-
const Dt = /^c[^\s-]{8,}$/i, zt = /^[0-9a-z]+$/, Mt = /^[0-9A-HJKMNP-TV-Z]{26}$/i, Lt = /^[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, Ft = /^[a-z0-9_-]{21}$/i, Ut = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/, Bt = /^[-+]?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)?)??$/, Jt = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i, Wt = "^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";
|
|
572
|
-
let $e;
|
|
573
|
-
const Gt = /^(?:(?: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])$/, qt = /^(?:(?: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])$/, Kt = /^(([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]))$/, Yt = /^(([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])$/, Ht = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/, Qt = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/, ht = "((\\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])))", Xt = new RegExp(`^${ht}$`);
|
|
574
|
-
function pt(r) {
|
|
575
|
-
let e = "[0-5]\\d";
|
|
576
|
-
r.precision ? e = `${e}\\.\\d{${r.precision}}` : r.precision == null && (e = `${e}(\\.\\d+)?`);
|
|
577
|
-
const t = r.precision ? "+" : "?";
|
|
578
|
-
return `([01]\\d|2[0-3]):[0-5]\\d(:${e})${t}`;
|
|
579
|
-
}
|
|
580
|
-
function er(r) {
|
|
581
|
-
return new RegExp(`^${pt(r)}$`);
|
|
582
|
-
}
|
|
583
|
-
function tr(r) {
|
|
584
|
-
let e = `${ht}T${pt(r)}`;
|
|
585
|
-
const t = [];
|
|
586
|
-
return t.push(r.local ? "Z?" : "Z"), r.offset && t.push("([+-]\\d{2}:?\\d{2})"), e = `${e}(${t.join("|")})`, new RegExp(`^${e}$`);
|
|
587
|
-
}
|
|
588
|
-
function rr(r, e) {
|
|
589
|
-
return !!((e === "v4" || !e) && Gt.test(r) || (e === "v6" || !e) && Kt.test(r));
|
|
590
|
-
}
|
|
591
|
-
function nr(r, e) {
|
|
592
|
-
if (!Ut.test(r))
|
|
593
|
-
return !1;
|
|
594
|
-
try {
|
|
595
|
-
const [t] = r.split(".");
|
|
596
|
-
if (!t)
|
|
597
|
-
return !1;
|
|
598
|
-
const s = t.replace(/-/g, "+").replace(/_/g, "/").padEnd(t.length + (4 - t.length % 4) % 4, "="), n = JSON.parse(atob(s));
|
|
599
|
-
return !(typeof n != "object" || n === null || "typ" in n && n?.typ !== "JWT" || !n.alg || e && n.alg !== e);
|
|
600
|
-
} catch {
|
|
601
|
-
return !1;
|
|
602
|
-
}
|
|
603
|
-
}
|
|
604
|
-
function sr(r, e) {
|
|
605
|
-
return !!((e === "v4" || !e) && qt.test(r) || (e === "v6" || !e) && Yt.test(r));
|
|
606
|
-
}
|
|
607
|
-
class Y extends I {
|
|
608
|
-
_parse(e) {
|
|
609
|
-
if (this._def.coerce && (e.data = String(e.data)), this._getType(e) !== y.string) {
|
|
610
|
-
const a = this._getOrReturnCtx(e);
|
|
611
|
-
return v(a, {
|
|
612
|
-
code: p.invalid_type,
|
|
613
|
-
expected: y.string,
|
|
614
|
-
received: a.parsedType
|
|
615
|
-
}), S;
|
|
616
|
-
}
|
|
617
|
-
const s = new M();
|
|
618
|
-
let n;
|
|
619
|
-
for (const a of this._def.checks)
|
|
620
|
-
if (a.kind === "min")
|
|
621
|
-
e.data.length < a.value && (n = this._getOrReturnCtx(e, n), v(n, {
|
|
622
|
-
code: p.too_small,
|
|
623
|
-
minimum: a.value,
|
|
624
|
-
type: "string",
|
|
625
|
-
inclusive: !0,
|
|
626
|
-
exact: !1,
|
|
627
|
-
message: a.message
|
|
628
|
-
}), s.dirty());
|
|
629
|
-
else if (a.kind === "max")
|
|
630
|
-
e.data.length > a.value && (n = this._getOrReturnCtx(e, n), v(n, {
|
|
631
|
-
code: p.too_big,
|
|
632
|
-
maximum: a.value,
|
|
633
|
-
type: "string",
|
|
634
|
-
inclusive: !0,
|
|
635
|
-
exact: !1,
|
|
636
|
-
message: a.message
|
|
637
|
-
}), s.dirty());
|
|
638
|
-
else if (a.kind === "length") {
|
|
639
|
-
const i = e.data.length > a.value, o = e.data.length < a.value;
|
|
640
|
-
(i || o) && (n = this._getOrReturnCtx(e, n), i ? v(n, {
|
|
641
|
-
code: p.too_big,
|
|
642
|
-
maximum: a.value,
|
|
643
|
-
type: "string",
|
|
644
|
-
inclusive: !0,
|
|
645
|
-
exact: !0,
|
|
646
|
-
message: a.message
|
|
647
|
-
}) : o && v(n, {
|
|
648
|
-
code: p.too_small,
|
|
649
|
-
minimum: a.value,
|
|
650
|
-
type: "string",
|
|
651
|
-
inclusive: !0,
|
|
652
|
-
exact: !0,
|
|
653
|
-
message: a.message
|
|
654
|
-
}), s.dirty());
|
|
655
|
-
} else if (a.kind === "email")
|
|
656
|
-
Jt.test(e.data) || (n = this._getOrReturnCtx(e, n), v(n, {
|
|
657
|
-
validation: "email",
|
|
658
|
-
code: p.invalid_string,
|
|
659
|
-
message: a.message
|
|
660
|
-
}), s.dirty());
|
|
661
|
-
else if (a.kind === "emoji")
|
|
662
|
-
$e || ($e = new RegExp(Wt, "u")), $e.test(e.data) || (n = this._getOrReturnCtx(e, n), v(n, {
|
|
663
|
-
validation: "emoji",
|
|
664
|
-
code: p.invalid_string,
|
|
665
|
-
message: a.message
|
|
666
|
-
}), s.dirty());
|
|
667
|
-
else if (a.kind === "uuid")
|
|
668
|
-
Lt.test(e.data) || (n = this._getOrReturnCtx(e, n), v(n, {
|
|
669
|
-
validation: "uuid",
|
|
670
|
-
code: p.invalid_string,
|
|
671
|
-
message: a.message
|
|
672
|
-
}), s.dirty());
|
|
673
|
-
else if (a.kind === "nanoid")
|
|
674
|
-
Ft.test(e.data) || (n = this._getOrReturnCtx(e, n), v(n, {
|
|
675
|
-
validation: "nanoid",
|
|
676
|
-
code: p.invalid_string,
|
|
677
|
-
message: a.message
|
|
678
|
-
}), s.dirty());
|
|
679
|
-
else if (a.kind === "cuid")
|
|
680
|
-
Dt.test(e.data) || (n = this._getOrReturnCtx(e, n), v(n, {
|
|
681
|
-
validation: "cuid",
|
|
682
|
-
code: p.invalid_string,
|
|
683
|
-
message: a.message
|
|
684
|
-
}), s.dirty());
|
|
685
|
-
else if (a.kind === "cuid2")
|
|
686
|
-
zt.test(e.data) || (n = this._getOrReturnCtx(e, n), v(n, {
|
|
687
|
-
validation: "cuid2",
|
|
688
|
-
code: p.invalid_string,
|
|
689
|
-
message: a.message
|
|
690
|
-
}), s.dirty());
|
|
691
|
-
else if (a.kind === "ulid")
|
|
692
|
-
Mt.test(e.data) || (n = this._getOrReturnCtx(e, n), v(n, {
|
|
693
|
-
validation: "ulid",
|
|
694
|
-
code: p.invalid_string,
|
|
695
|
-
message: a.message
|
|
696
|
-
}), s.dirty());
|
|
697
|
-
else if (a.kind === "url")
|
|
698
|
-
try {
|
|
699
|
-
new URL(e.data);
|
|
700
|
-
} catch {
|
|
701
|
-
n = this._getOrReturnCtx(e, n), v(n, {
|
|
702
|
-
validation: "url",
|
|
703
|
-
code: p.invalid_string,
|
|
704
|
-
message: a.message
|
|
705
|
-
}), s.dirty();
|
|
706
|
-
}
|
|
707
|
-
else a.kind === "regex" ? (a.regex.lastIndex = 0, a.regex.test(e.data) || (n = this._getOrReturnCtx(e, n), v(n, {
|
|
708
|
-
validation: "regex",
|
|
709
|
-
code: p.invalid_string,
|
|
710
|
-
message: a.message
|
|
711
|
-
}), s.dirty())) : a.kind === "trim" ? e.data = e.data.trim() : a.kind === "includes" ? e.data.includes(a.value, a.position) || (n = this._getOrReturnCtx(e, n), v(n, {
|
|
712
|
-
code: p.invalid_string,
|
|
713
|
-
validation: { includes: a.value, position: a.position },
|
|
714
|
-
message: a.message
|
|
715
|
-
}), s.dirty()) : a.kind === "toLowerCase" ? e.data = e.data.toLowerCase() : a.kind === "toUpperCase" ? e.data = e.data.toUpperCase() : a.kind === "startsWith" ? e.data.startsWith(a.value) || (n = this._getOrReturnCtx(e, n), v(n, {
|
|
716
|
-
code: p.invalid_string,
|
|
717
|
-
validation: { startsWith: a.value },
|
|
718
|
-
message: a.message
|
|
719
|
-
}), s.dirty()) : a.kind === "endsWith" ? e.data.endsWith(a.value) || (n = this._getOrReturnCtx(e, n), v(n, {
|
|
720
|
-
code: p.invalid_string,
|
|
721
|
-
validation: { endsWith: a.value },
|
|
722
|
-
message: a.message
|
|
723
|
-
}), s.dirty()) : a.kind === "datetime" ? tr(a).test(e.data) || (n = this._getOrReturnCtx(e, n), v(n, {
|
|
724
|
-
code: p.invalid_string,
|
|
725
|
-
validation: "datetime",
|
|
726
|
-
message: a.message
|
|
727
|
-
}), s.dirty()) : a.kind === "date" ? Xt.test(e.data) || (n = this._getOrReturnCtx(e, n), v(n, {
|
|
728
|
-
code: p.invalid_string,
|
|
729
|
-
validation: "date",
|
|
730
|
-
message: a.message
|
|
731
|
-
}), s.dirty()) : a.kind === "time" ? er(a).test(e.data) || (n = this._getOrReturnCtx(e, n), v(n, {
|
|
732
|
-
code: p.invalid_string,
|
|
733
|
-
validation: "time",
|
|
734
|
-
message: a.message
|
|
735
|
-
}), s.dirty()) : a.kind === "duration" ? Bt.test(e.data) || (n = this._getOrReturnCtx(e, n), v(n, {
|
|
736
|
-
validation: "duration",
|
|
737
|
-
code: p.invalid_string,
|
|
738
|
-
message: a.message
|
|
739
|
-
}), s.dirty()) : a.kind === "ip" ? rr(e.data, a.version) || (n = this._getOrReturnCtx(e, n), v(n, {
|
|
740
|
-
validation: "ip",
|
|
741
|
-
code: p.invalid_string,
|
|
742
|
-
message: a.message
|
|
743
|
-
}), s.dirty()) : a.kind === "jwt" ? nr(e.data, a.alg) || (n = this._getOrReturnCtx(e, n), v(n, {
|
|
744
|
-
validation: "jwt",
|
|
745
|
-
code: p.invalid_string,
|
|
746
|
-
message: a.message
|
|
747
|
-
}), s.dirty()) : a.kind === "cidr" ? sr(e.data, a.version) || (n = this._getOrReturnCtx(e, n), v(n, {
|
|
748
|
-
validation: "cidr",
|
|
749
|
-
code: p.invalid_string,
|
|
750
|
-
message: a.message
|
|
751
|
-
}), s.dirty()) : a.kind === "base64" ? Ht.test(e.data) || (n = this._getOrReturnCtx(e, n), v(n, {
|
|
752
|
-
validation: "base64",
|
|
753
|
-
code: p.invalid_string,
|
|
754
|
-
message: a.message
|
|
755
|
-
}), s.dirty()) : a.kind === "base64url" ? Qt.test(e.data) || (n = this._getOrReturnCtx(e, n), v(n, {
|
|
756
|
-
validation: "base64url",
|
|
757
|
-
code: p.invalid_string,
|
|
758
|
-
message: a.message
|
|
759
|
-
}), s.dirty()) : V.assertNever(a);
|
|
760
|
-
return { status: s.value, value: e.data };
|
|
761
|
-
}
|
|
762
|
-
_regex(e, t, s) {
|
|
763
|
-
return this.refinement((n) => e.test(n), {
|
|
764
|
-
validation: t,
|
|
765
|
-
code: p.invalid_string,
|
|
766
|
-
..._.errToObj(s)
|
|
767
|
-
});
|
|
768
|
-
}
|
|
769
|
-
_addCheck(e) {
|
|
770
|
-
return new Y({
|
|
771
|
-
...this._def,
|
|
772
|
-
checks: [...this._def.checks, e]
|
|
773
|
-
});
|
|
774
|
-
}
|
|
775
|
-
email(e) {
|
|
776
|
-
return this._addCheck({ kind: "email", ..._.errToObj(e) });
|
|
777
|
-
}
|
|
778
|
-
url(e) {
|
|
779
|
-
return this._addCheck({ kind: "url", ..._.errToObj(e) });
|
|
780
|
-
}
|
|
781
|
-
emoji(e) {
|
|
782
|
-
return this._addCheck({ kind: "emoji", ..._.errToObj(e) });
|
|
783
|
-
}
|
|
784
|
-
uuid(e) {
|
|
785
|
-
return this._addCheck({ kind: "uuid", ..._.errToObj(e) });
|
|
786
|
-
}
|
|
787
|
-
nanoid(e) {
|
|
788
|
-
return this._addCheck({ kind: "nanoid", ..._.errToObj(e) });
|
|
789
|
-
}
|
|
790
|
-
cuid(e) {
|
|
791
|
-
return this._addCheck({ kind: "cuid", ..._.errToObj(e) });
|
|
792
|
-
}
|
|
793
|
-
cuid2(e) {
|
|
794
|
-
return this._addCheck({ kind: "cuid2", ..._.errToObj(e) });
|
|
795
|
-
}
|
|
796
|
-
ulid(e) {
|
|
797
|
-
return this._addCheck({ kind: "ulid", ..._.errToObj(e) });
|
|
798
|
-
}
|
|
799
|
-
base64(e) {
|
|
800
|
-
return this._addCheck({ kind: "base64", ..._.errToObj(e) });
|
|
801
|
-
}
|
|
802
|
-
base64url(e) {
|
|
803
|
-
return this._addCheck({
|
|
804
|
-
kind: "base64url",
|
|
805
|
-
..._.errToObj(e)
|
|
806
|
-
});
|
|
807
|
-
}
|
|
808
|
-
jwt(e) {
|
|
809
|
-
return this._addCheck({ kind: "jwt", ..._.errToObj(e) });
|
|
810
|
-
}
|
|
811
|
-
ip(e) {
|
|
812
|
-
return this._addCheck({ kind: "ip", ..._.errToObj(e) });
|
|
813
|
-
}
|
|
814
|
-
cidr(e) {
|
|
815
|
-
return this._addCheck({ kind: "cidr", ..._.errToObj(e) });
|
|
816
|
-
}
|
|
817
|
-
datetime(e) {
|
|
818
|
-
return typeof e == "string" ? this._addCheck({
|
|
819
|
-
kind: "datetime",
|
|
820
|
-
precision: null,
|
|
821
|
-
offset: !1,
|
|
822
|
-
local: !1,
|
|
823
|
-
message: e
|
|
824
|
-
}) : this._addCheck({
|
|
825
|
-
kind: "datetime",
|
|
826
|
-
precision: typeof e?.precision > "u" ? null : e?.precision,
|
|
827
|
-
offset: e?.offset ?? !1,
|
|
828
|
-
local: e?.local ?? !1,
|
|
829
|
-
..._.errToObj(e?.message)
|
|
830
|
-
});
|
|
831
|
-
}
|
|
832
|
-
date(e) {
|
|
833
|
-
return this._addCheck({ kind: "date", message: e });
|
|
834
|
-
}
|
|
835
|
-
time(e) {
|
|
836
|
-
return typeof e == "string" ? this._addCheck({
|
|
837
|
-
kind: "time",
|
|
838
|
-
precision: null,
|
|
839
|
-
message: e
|
|
840
|
-
}) : this._addCheck({
|
|
841
|
-
kind: "time",
|
|
842
|
-
precision: typeof e?.precision > "u" ? null : e?.precision,
|
|
843
|
-
..._.errToObj(e?.message)
|
|
844
|
-
});
|
|
845
|
-
}
|
|
846
|
-
duration(e) {
|
|
847
|
-
return this._addCheck({ kind: "duration", ..._.errToObj(e) });
|
|
848
|
-
}
|
|
849
|
-
regex(e, t) {
|
|
850
|
-
return this._addCheck({
|
|
851
|
-
kind: "regex",
|
|
852
|
-
regex: e,
|
|
853
|
-
..._.errToObj(t)
|
|
854
|
-
});
|
|
855
|
-
}
|
|
856
|
-
includes(e, t) {
|
|
857
|
-
return this._addCheck({
|
|
858
|
-
kind: "includes",
|
|
859
|
-
value: e,
|
|
860
|
-
position: t?.position,
|
|
861
|
-
..._.errToObj(t?.message)
|
|
862
|
-
});
|
|
863
|
-
}
|
|
864
|
-
startsWith(e, t) {
|
|
865
|
-
return this._addCheck({
|
|
866
|
-
kind: "startsWith",
|
|
867
|
-
value: e,
|
|
868
|
-
..._.errToObj(t)
|
|
869
|
-
});
|
|
870
|
-
}
|
|
871
|
-
endsWith(e, t) {
|
|
872
|
-
return this._addCheck({
|
|
873
|
-
kind: "endsWith",
|
|
874
|
-
value: e,
|
|
875
|
-
..._.errToObj(t)
|
|
876
|
-
});
|
|
877
|
-
}
|
|
878
|
-
min(e, t) {
|
|
879
|
-
return this._addCheck({
|
|
880
|
-
kind: "min",
|
|
881
|
-
value: e,
|
|
882
|
-
..._.errToObj(t)
|
|
883
|
-
});
|
|
884
|
-
}
|
|
885
|
-
max(e, t) {
|
|
886
|
-
return this._addCheck({
|
|
887
|
-
kind: "max",
|
|
888
|
-
value: e,
|
|
889
|
-
..._.errToObj(t)
|
|
890
|
-
});
|
|
891
|
-
}
|
|
892
|
-
length(e, t) {
|
|
893
|
-
return this._addCheck({
|
|
894
|
-
kind: "length",
|
|
895
|
-
value: e,
|
|
896
|
-
..._.errToObj(t)
|
|
897
|
-
});
|
|
898
|
-
}
|
|
899
|
-
/**
|
|
900
|
-
* Equivalent to `.min(1)`
|
|
901
|
-
*/
|
|
902
|
-
nonempty(e) {
|
|
903
|
-
return this.min(1, _.errToObj(e));
|
|
904
|
-
}
|
|
905
|
-
trim() {
|
|
906
|
-
return new Y({
|
|
907
|
-
...this._def,
|
|
908
|
-
checks: [...this._def.checks, { kind: "trim" }]
|
|
909
|
-
});
|
|
910
|
-
}
|
|
911
|
-
toLowerCase() {
|
|
912
|
-
return new Y({
|
|
913
|
-
...this._def,
|
|
914
|
-
checks: [...this._def.checks, { kind: "toLowerCase" }]
|
|
915
|
-
});
|
|
916
|
-
}
|
|
917
|
-
toUpperCase() {
|
|
918
|
-
return new Y({
|
|
919
|
-
...this._def,
|
|
920
|
-
checks: [...this._def.checks, { kind: "toUpperCase" }]
|
|
921
|
-
});
|
|
922
|
-
}
|
|
923
|
-
get isDatetime() {
|
|
924
|
-
return !!this._def.checks.find((e) => e.kind === "datetime");
|
|
925
|
-
}
|
|
926
|
-
get isDate() {
|
|
927
|
-
return !!this._def.checks.find((e) => e.kind === "date");
|
|
928
|
-
}
|
|
929
|
-
get isTime() {
|
|
930
|
-
return !!this._def.checks.find((e) => e.kind === "time");
|
|
931
|
-
}
|
|
932
|
-
get isDuration() {
|
|
933
|
-
return !!this._def.checks.find((e) => e.kind === "duration");
|
|
934
|
-
}
|
|
935
|
-
get isEmail() {
|
|
936
|
-
return !!this._def.checks.find((e) => e.kind === "email");
|
|
937
|
-
}
|
|
938
|
-
get isURL() {
|
|
939
|
-
return !!this._def.checks.find((e) => e.kind === "url");
|
|
940
|
-
}
|
|
941
|
-
get isEmoji() {
|
|
942
|
-
return !!this._def.checks.find((e) => e.kind === "emoji");
|
|
943
|
-
}
|
|
944
|
-
get isUUID() {
|
|
945
|
-
return !!this._def.checks.find((e) => e.kind === "uuid");
|
|
946
|
-
}
|
|
947
|
-
get isNANOID() {
|
|
948
|
-
return !!this._def.checks.find((e) => e.kind === "nanoid");
|
|
949
|
-
}
|
|
950
|
-
get isCUID() {
|
|
951
|
-
return !!this._def.checks.find((e) => e.kind === "cuid");
|
|
952
|
-
}
|
|
953
|
-
get isCUID2() {
|
|
954
|
-
return !!this._def.checks.find((e) => e.kind === "cuid2");
|
|
955
|
-
}
|
|
956
|
-
get isULID() {
|
|
957
|
-
return !!this._def.checks.find((e) => e.kind === "ulid");
|
|
958
|
-
}
|
|
959
|
-
get isIP() {
|
|
960
|
-
return !!this._def.checks.find((e) => e.kind === "ip");
|
|
961
|
-
}
|
|
962
|
-
get isCIDR() {
|
|
963
|
-
return !!this._def.checks.find((e) => e.kind === "cidr");
|
|
964
|
-
}
|
|
965
|
-
get isBase64() {
|
|
966
|
-
return !!this._def.checks.find((e) => e.kind === "base64");
|
|
967
|
-
}
|
|
968
|
-
get isBase64url() {
|
|
969
|
-
return !!this._def.checks.find((e) => e.kind === "base64url");
|
|
970
|
-
}
|
|
971
|
-
get minLength() {
|
|
972
|
-
let e = null;
|
|
973
|
-
for (const t of this._def.checks)
|
|
974
|
-
t.kind === "min" && (e === null || t.value > e) && (e = t.value);
|
|
975
|
-
return e;
|
|
976
|
-
}
|
|
977
|
-
get maxLength() {
|
|
978
|
-
let e = null;
|
|
979
|
-
for (const t of this._def.checks)
|
|
980
|
-
t.kind === "max" && (e === null || t.value < e) && (e = t.value);
|
|
981
|
-
return e;
|
|
982
|
-
}
|
|
983
|
-
}
|
|
984
|
-
Y.create = (r) => new Y({
|
|
985
|
-
checks: [],
|
|
986
|
-
typeName: O.ZodString,
|
|
987
|
-
coerce: r?.coerce ?? !1,
|
|
988
|
-
...T(r)
|
|
989
|
-
});
|
|
990
|
-
function ar(r, e) {
|
|
991
|
-
const t = (r.toString().split(".")[1] || "").length, s = (e.toString().split(".")[1] || "").length, n = t > s ? t : s, a = Number.parseInt(r.toFixed(n).replace(".", "")), i = Number.parseInt(e.toFixed(n).replace(".", ""));
|
|
992
|
-
return a % i / 10 ** n;
|
|
993
|
-
}
|
|
994
|
-
class ve extends I {
|
|
995
|
-
constructor() {
|
|
996
|
-
super(...arguments), this.min = this.gte, this.max = this.lte, this.step = this.multipleOf;
|
|
997
|
-
}
|
|
998
|
-
_parse(e) {
|
|
999
|
-
if (this._def.coerce && (e.data = Number(e.data)), this._getType(e) !== y.number) {
|
|
1000
|
-
const a = this._getOrReturnCtx(e);
|
|
1001
|
-
return v(a, {
|
|
1002
|
-
code: p.invalid_type,
|
|
1003
|
-
expected: y.number,
|
|
1004
|
-
received: a.parsedType
|
|
1005
|
-
}), S;
|
|
1006
|
-
}
|
|
1007
|
-
let s;
|
|
1008
|
-
const n = new M();
|
|
1009
|
-
for (const a of this._def.checks)
|
|
1010
|
-
a.kind === "int" ? V.isInteger(e.data) || (s = this._getOrReturnCtx(e, s), v(s, {
|
|
1011
|
-
code: p.invalid_type,
|
|
1012
|
-
expected: "integer",
|
|
1013
|
-
received: "float",
|
|
1014
|
-
message: a.message
|
|
1015
|
-
}), n.dirty()) : a.kind === "min" ? (a.inclusive ? e.data < a.value : e.data <= a.value) && (s = this._getOrReturnCtx(e, s), v(s, {
|
|
1016
|
-
code: p.too_small,
|
|
1017
|
-
minimum: a.value,
|
|
1018
|
-
type: "number",
|
|
1019
|
-
inclusive: a.inclusive,
|
|
1020
|
-
exact: !1,
|
|
1021
|
-
message: a.message
|
|
1022
|
-
}), n.dirty()) : a.kind === "max" ? (a.inclusive ? e.data > a.value : e.data >= a.value) && (s = this._getOrReturnCtx(e, s), v(s, {
|
|
1023
|
-
code: p.too_big,
|
|
1024
|
-
maximum: a.value,
|
|
1025
|
-
type: "number",
|
|
1026
|
-
inclusive: a.inclusive,
|
|
1027
|
-
exact: !1,
|
|
1028
|
-
message: a.message
|
|
1029
|
-
}), n.dirty()) : a.kind === "multipleOf" ? ar(e.data, a.value) !== 0 && (s = this._getOrReturnCtx(e, s), v(s, {
|
|
1030
|
-
code: p.not_multiple_of,
|
|
1031
|
-
multipleOf: a.value,
|
|
1032
|
-
message: a.message
|
|
1033
|
-
}), n.dirty()) : a.kind === "finite" ? Number.isFinite(e.data) || (s = this._getOrReturnCtx(e, s), v(s, {
|
|
1034
|
-
code: p.not_finite,
|
|
1035
|
-
message: a.message
|
|
1036
|
-
}), n.dirty()) : V.assertNever(a);
|
|
1037
|
-
return { status: n.value, value: e.data };
|
|
1038
|
-
}
|
|
1039
|
-
gte(e, t) {
|
|
1040
|
-
return this.setLimit("min", e, !0, _.toString(t));
|
|
1041
|
-
}
|
|
1042
|
-
gt(e, t) {
|
|
1043
|
-
return this.setLimit("min", e, !1, _.toString(t));
|
|
1044
|
-
}
|
|
1045
|
-
lte(e, t) {
|
|
1046
|
-
return this.setLimit("max", e, !0, _.toString(t));
|
|
1047
|
-
}
|
|
1048
|
-
lt(e, t) {
|
|
1049
|
-
return this.setLimit("max", e, !1, _.toString(t));
|
|
1050
|
-
}
|
|
1051
|
-
setLimit(e, t, s, n) {
|
|
1052
|
-
return new ve({
|
|
1053
|
-
...this._def,
|
|
1054
|
-
checks: [
|
|
1055
|
-
...this._def.checks,
|
|
1056
|
-
{
|
|
1057
|
-
kind: e,
|
|
1058
|
-
value: t,
|
|
1059
|
-
inclusive: s,
|
|
1060
|
-
message: _.toString(n)
|
|
1061
|
-
}
|
|
1062
|
-
]
|
|
1063
|
-
});
|
|
1064
|
-
}
|
|
1065
|
-
_addCheck(e) {
|
|
1066
|
-
return new ve({
|
|
1067
|
-
...this._def,
|
|
1068
|
-
checks: [...this._def.checks, e]
|
|
1069
|
-
});
|
|
1070
|
-
}
|
|
1071
|
-
int(e) {
|
|
1072
|
-
return this._addCheck({
|
|
1073
|
-
kind: "int",
|
|
1074
|
-
message: _.toString(e)
|
|
1075
|
-
});
|
|
1076
|
-
}
|
|
1077
|
-
positive(e) {
|
|
1078
|
-
return this._addCheck({
|
|
1079
|
-
kind: "min",
|
|
1080
|
-
value: 0,
|
|
1081
|
-
inclusive: !1,
|
|
1082
|
-
message: _.toString(e)
|
|
1083
|
-
});
|
|
1084
|
-
}
|
|
1085
|
-
negative(e) {
|
|
1086
|
-
return this._addCheck({
|
|
1087
|
-
kind: "max",
|
|
1088
|
-
value: 0,
|
|
1089
|
-
inclusive: !1,
|
|
1090
|
-
message: _.toString(e)
|
|
1091
|
-
});
|
|
1092
|
-
}
|
|
1093
|
-
nonpositive(e) {
|
|
1094
|
-
return this._addCheck({
|
|
1095
|
-
kind: "max",
|
|
1096
|
-
value: 0,
|
|
1097
|
-
inclusive: !0,
|
|
1098
|
-
message: _.toString(e)
|
|
1099
|
-
});
|
|
1100
|
-
}
|
|
1101
|
-
nonnegative(e) {
|
|
1102
|
-
return this._addCheck({
|
|
1103
|
-
kind: "min",
|
|
1104
|
-
value: 0,
|
|
1105
|
-
inclusive: !0,
|
|
1106
|
-
message: _.toString(e)
|
|
1107
|
-
});
|
|
1108
|
-
}
|
|
1109
|
-
multipleOf(e, t) {
|
|
1110
|
-
return this._addCheck({
|
|
1111
|
-
kind: "multipleOf",
|
|
1112
|
-
value: e,
|
|
1113
|
-
message: _.toString(t)
|
|
1114
|
-
});
|
|
1115
|
-
}
|
|
1116
|
-
finite(e) {
|
|
1117
|
-
return this._addCheck({
|
|
1118
|
-
kind: "finite",
|
|
1119
|
-
message: _.toString(e)
|
|
1120
|
-
});
|
|
1121
|
-
}
|
|
1122
|
-
safe(e) {
|
|
1123
|
-
return this._addCheck({
|
|
1124
|
-
kind: "min",
|
|
1125
|
-
inclusive: !0,
|
|
1126
|
-
value: Number.MIN_SAFE_INTEGER,
|
|
1127
|
-
message: _.toString(e)
|
|
1128
|
-
})._addCheck({
|
|
1129
|
-
kind: "max",
|
|
1130
|
-
inclusive: !0,
|
|
1131
|
-
value: Number.MAX_SAFE_INTEGER,
|
|
1132
|
-
message: _.toString(e)
|
|
1133
|
-
});
|
|
1134
|
-
}
|
|
1135
|
-
get minValue() {
|
|
1136
|
-
let e = null;
|
|
1137
|
-
for (const t of this._def.checks)
|
|
1138
|
-
t.kind === "min" && (e === null || t.value > e) && (e = t.value);
|
|
1139
|
-
return e;
|
|
1140
|
-
}
|
|
1141
|
-
get maxValue() {
|
|
1142
|
-
let e = null;
|
|
1143
|
-
for (const t of this._def.checks)
|
|
1144
|
-
t.kind === "max" && (e === null || t.value < e) && (e = t.value);
|
|
1145
|
-
return e;
|
|
1146
|
-
}
|
|
1147
|
-
get isInt() {
|
|
1148
|
-
return !!this._def.checks.find((e) => e.kind === "int" || e.kind === "multipleOf" && V.isInteger(e.value));
|
|
1149
|
-
}
|
|
1150
|
-
get isFinite() {
|
|
1151
|
-
let e = null, t = null;
|
|
1152
|
-
for (const s of this._def.checks) {
|
|
1153
|
-
if (s.kind === "finite" || s.kind === "int" || s.kind === "multipleOf")
|
|
1154
|
-
return !0;
|
|
1155
|
-
s.kind === "min" ? (t === null || s.value > t) && (t = s.value) : s.kind === "max" && (e === null || s.value < e) && (e = s.value);
|
|
1156
|
-
}
|
|
1157
|
-
return Number.isFinite(t) && Number.isFinite(e);
|
|
1158
|
-
}
|
|
1159
|
-
}
|
|
1160
|
-
ve.create = (r) => new ve({
|
|
1161
|
-
checks: [],
|
|
1162
|
-
typeName: O.ZodNumber,
|
|
1163
|
-
coerce: r?.coerce || !1,
|
|
1164
|
-
...T(r)
|
|
1165
|
-
});
|
|
1166
|
-
class ye extends I {
|
|
1167
|
-
constructor() {
|
|
1168
|
-
super(...arguments), this.min = this.gte, this.max = this.lte;
|
|
1169
|
-
}
|
|
1170
|
-
_parse(e) {
|
|
1171
|
-
if (this._def.coerce)
|
|
1172
|
-
try {
|
|
1173
|
-
e.data = BigInt(e.data);
|
|
1174
|
-
} catch {
|
|
1175
|
-
return this._getInvalidInput(e);
|
|
1176
|
-
}
|
|
1177
|
-
if (this._getType(e) !== y.bigint)
|
|
1178
|
-
return this._getInvalidInput(e);
|
|
1179
|
-
let s;
|
|
1180
|
-
const n = new M();
|
|
1181
|
-
for (const a of this._def.checks)
|
|
1182
|
-
a.kind === "min" ? (a.inclusive ? e.data < a.value : e.data <= a.value) && (s = this._getOrReturnCtx(e, s), v(s, {
|
|
1183
|
-
code: p.too_small,
|
|
1184
|
-
type: "bigint",
|
|
1185
|
-
minimum: a.value,
|
|
1186
|
-
inclusive: a.inclusive,
|
|
1187
|
-
message: a.message
|
|
1188
|
-
}), n.dirty()) : a.kind === "max" ? (a.inclusive ? e.data > a.value : e.data >= a.value) && (s = this._getOrReturnCtx(e, s), v(s, {
|
|
1189
|
-
code: p.too_big,
|
|
1190
|
-
type: "bigint",
|
|
1191
|
-
maximum: a.value,
|
|
1192
|
-
inclusive: a.inclusive,
|
|
1193
|
-
message: a.message
|
|
1194
|
-
}), n.dirty()) : a.kind === "multipleOf" ? e.data % a.value !== BigInt(0) && (s = this._getOrReturnCtx(e, s), v(s, {
|
|
1195
|
-
code: p.not_multiple_of,
|
|
1196
|
-
multipleOf: a.value,
|
|
1197
|
-
message: a.message
|
|
1198
|
-
}), n.dirty()) : V.assertNever(a);
|
|
1199
|
-
return { status: n.value, value: e.data };
|
|
1200
|
-
}
|
|
1201
|
-
_getInvalidInput(e) {
|
|
1202
|
-
const t = this._getOrReturnCtx(e);
|
|
1203
|
-
return v(t, {
|
|
1204
|
-
code: p.invalid_type,
|
|
1205
|
-
expected: y.bigint,
|
|
1206
|
-
received: t.parsedType
|
|
1207
|
-
}), S;
|
|
1208
|
-
}
|
|
1209
|
-
gte(e, t) {
|
|
1210
|
-
return this.setLimit("min", e, !0, _.toString(t));
|
|
1211
|
-
}
|
|
1212
|
-
gt(e, t) {
|
|
1213
|
-
return this.setLimit("min", e, !1, _.toString(t));
|
|
1214
|
-
}
|
|
1215
|
-
lte(e, t) {
|
|
1216
|
-
return this.setLimit("max", e, !0, _.toString(t));
|
|
1217
|
-
}
|
|
1218
|
-
lt(e, t) {
|
|
1219
|
-
return this.setLimit("max", e, !1, _.toString(t));
|
|
1220
|
-
}
|
|
1221
|
-
setLimit(e, t, s, n) {
|
|
1222
|
-
return new ye({
|
|
1223
|
-
...this._def,
|
|
1224
|
-
checks: [
|
|
1225
|
-
...this._def.checks,
|
|
1226
|
-
{
|
|
1227
|
-
kind: e,
|
|
1228
|
-
value: t,
|
|
1229
|
-
inclusive: s,
|
|
1230
|
-
message: _.toString(n)
|
|
1231
|
-
}
|
|
1232
|
-
]
|
|
1233
|
-
});
|
|
1234
|
-
}
|
|
1235
|
-
_addCheck(e) {
|
|
1236
|
-
return new ye({
|
|
1237
|
-
...this._def,
|
|
1238
|
-
checks: [...this._def.checks, e]
|
|
1239
|
-
});
|
|
1240
|
-
}
|
|
1241
|
-
positive(e) {
|
|
1242
|
-
return this._addCheck({
|
|
1243
|
-
kind: "min",
|
|
1244
|
-
value: BigInt(0),
|
|
1245
|
-
inclusive: !1,
|
|
1246
|
-
message: _.toString(e)
|
|
1247
|
-
});
|
|
1248
|
-
}
|
|
1249
|
-
negative(e) {
|
|
1250
|
-
return this._addCheck({
|
|
1251
|
-
kind: "max",
|
|
1252
|
-
value: BigInt(0),
|
|
1253
|
-
inclusive: !1,
|
|
1254
|
-
message: _.toString(e)
|
|
1255
|
-
});
|
|
1256
|
-
}
|
|
1257
|
-
nonpositive(e) {
|
|
1258
|
-
return this._addCheck({
|
|
1259
|
-
kind: "max",
|
|
1260
|
-
value: BigInt(0),
|
|
1261
|
-
inclusive: !0,
|
|
1262
|
-
message: _.toString(e)
|
|
1263
|
-
});
|
|
1264
|
-
}
|
|
1265
|
-
nonnegative(e) {
|
|
1266
|
-
return this._addCheck({
|
|
1267
|
-
kind: "min",
|
|
1268
|
-
value: BigInt(0),
|
|
1269
|
-
inclusive: !0,
|
|
1270
|
-
message: _.toString(e)
|
|
1271
|
-
});
|
|
1272
|
-
}
|
|
1273
|
-
multipleOf(e, t) {
|
|
1274
|
-
return this._addCheck({
|
|
1275
|
-
kind: "multipleOf",
|
|
1276
|
-
value: e,
|
|
1277
|
-
message: _.toString(t)
|
|
1278
|
-
});
|
|
1279
|
-
}
|
|
1280
|
-
get minValue() {
|
|
1281
|
-
let e = null;
|
|
1282
|
-
for (const t of this._def.checks)
|
|
1283
|
-
t.kind === "min" && (e === null || t.value > e) && (e = t.value);
|
|
1284
|
-
return e;
|
|
1285
|
-
}
|
|
1286
|
-
get maxValue() {
|
|
1287
|
-
let e = null;
|
|
1288
|
-
for (const t of this._def.checks)
|
|
1289
|
-
t.kind === "max" && (e === null || t.value < e) && (e = t.value);
|
|
1290
|
-
return e;
|
|
1291
|
-
}
|
|
1292
|
-
}
|
|
1293
|
-
ye.create = (r) => new ye({
|
|
1294
|
-
checks: [],
|
|
1295
|
-
typeName: O.ZodBigInt,
|
|
1296
|
-
coerce: r?.coerce ?? !1,
|
|
1297
|
-
...T(r)
|
|
1298
|
-
});
|
|
1299
|
-
class Qe extends I {
|
|
1300
|
-
_parse(e) {
|
|
1301
|
-
if (this._def.coerce && (e.data = !!e.data), this._getType(e) !== y.boolean) {
|
|
1302
|
-
const s = this._getOrReturnCtx(e);
|
|
1303
|
-
return v(s, {
|
|
1304
|
-
code: p.invalid_type,
|
|
1305
|
-
expected: y.boolean,
|
|
1306
|
-
received: s.parsedType
|
|
1307
|
-
}), S;
|
|
1308
|
-
}
|
|
1309
|
-
return U(e.data);
|
|
1310
|
-
}
|
|
1311
|
-
}
|
|
1312
|
-
Qe.create = (r) => new Qe({
|
|
1313
|
-
typeName: O.ZodBoolean,
|
|
1314
|
-
coerce: r?.coerce || !1,
|
|
1315
|
-
...T(r)
|
|
1316
|
-
});
|
|
1317
|
-
class je extends I {
|
|
1318
|
-
_parse(e) {
|
|
1319
|
-
if (this._def.coerce && (e.data = new Date(e.data)), this._getType(e) !== y.date) {
|
|
1320
|
-
const a = this._getOrReturnCtx(e);
|
|
1321
|
-
return v(a, {
|
|
1322
|
-
code: p.invalid_type,
|
|
1323
|
-
expected: y.date,
|
|
1324
|
-
received: a.parsedType
|
|
1325
|
-
}), S;
|
|
1326
|
-
}
|
|
1327
|
-
if (Number.isNaN(e.data.getTime())) {
|
|
1328
|
-
const a = this._getOrReturnCtx(e);
|
|
1329
|
-
return v(a, {
|
|
1330
|
-
code: p.invalid_date
|
|
1331
|
-
}), S;
|
|
1332
|
-
}
|
|
1333
|
-
const s = new M();
|
|
1334
|
-
let n;
|
|
1335
|
-
for (const a of this._def.checks)
|
|
1336
|
-
a.kind === "min" ? e.data.getTime() < a.value && (n = this._getOrReturnCtx(e, n), v(n, {
|
|
1337
|
-
code: p.too_small,
|
|
1338
|
-
message: a.message,
|
|
1339
|
-
inclusive: !0,
|
|
1340
|
-
exact: !1,
|
|
1341
|
-
minimum: a.value,
|
|
1342
|
-
type: "date"
|
|
1343
|
-
}), s.dirty()) : a.kind === "max" ? e.data.getTime() > a.value && (n = this._getOrReturnCtx(e, n), v(n, {
|
|
1344
|
-
code: p.too_big,
|
|
1345
|
-
message: a.message,
|
|
1346
|
-
inclusive: !0,
|
|
1347
|
-
exact: !1,
|
|
1348
|
-
maximum: a.value,
|
|
1349
|
-
type: "date"
|
|
1350
|
-
}), s.dirty()) : V.assertNever(a);
|
|
1351
|
-
return {
|
|
1352
|
-
status: s.value,
|
|
1353
|
-
value: new Date(e.data.getTime())
|
|
1354
|
-
};
|
|
1355
|
-
}
|
|
1356
|
-
_addCheck(e) {
|
|
1357
|
-
return new je({
|
|
1358
|
-
...this._def,
|
|
1359
|
-
checks: [...this._def.checks, e]
|
|
1360
|
-
});
|
|
1361
|
-
}
|
|
1362
|
-
min(e, t) {
|
|
1363
|
-
return this._addCheck({
|
|
1364
|
-
kind: "min",
|
|
1365
|
-
value: e.getTime(),
|
|
1366
|
-
message: _.toString(t)
|
|
1367
|
-
});
|
|
1368
|
-
}
|
|
1369
|
-
max(e, t) {
|
|
1370
|
-
return this._addCheck({
|
|
1371
|
-
kind: "max",
|
|
1372
|
-
value: e.getTime(),
|
|
1373
|
-
message: _.toString(t)
|
|
1374
|
-
});
|
|
1375
|
-
}
|
|
1376
|
-
get minDate() {
|
|
1377
|
-
let e = null;
|
|
1378
|
-
for (const t of this._def.checks)
|
|
1379
|
-
t.kind === "min" && (e === null || t.value > e) && (e = t.value);
|
|
1380
|
-
return e != null ? new Date(e) : null;
|
|
1381
|
-
}
|
|
1382
|
-
get maxDate() {
|
|
1383
|
-
let e = null;
|
|
1384
|
-
for (const t of this._def.checks)
|
|
1385
|
-
t.kind === "max" && (e === null || t.value < e) && (e = t.value);
|
|
1386
|
-
return e != null ? new Date(e) : null;
|
|
1387
|
-
}
|
|
1388
|
-
}
|
|
1389
|
-
je.create = (r) => new je({
|
|
1390
|
-
checks: [],
|
|
1391
|
-
coerce: r?.coerce || !1,
|
|
1392
|
-
typeName: O.ZodDate,
|
|
1393
|
-
...T(r)
|
|
1394
|
-
});
|
|
1395
|
-
class Xe extends I {
|
|
1396
|
-
_parse(e) {
|
|
1397
|
-
if (this._getType(e) !== y.symbol) {
|
|
1398
|
-
const s = this._getOrReturnCtx(e);
|
|
1399
|
-
return v(s, {
|
|
1400
|
-
code: p.invalid_type,
|
|
1401
|
-
expected: y.symbol,
|
|
1402
|
-
received: s.parsedType
|
|
1403
|
-
}), S;
|
|
1404
|
-
}
|
|
1405
|
-
return U(e.data);
|
|
1406
|
-
}
|
|
1407
|
-
}
|
|
1408
|
-
Xe.create = (r) => new Xe({
|
|
1409
|
-
typeName: O.ZodSymbol,
|
|
1410
|
-
...T(r)
|
|
1411
|
-
});
|
|
1412
|
-
class et extends I {
|
|
1413
|
-
_parse(e) {
|
|
1414
|
-
if (this._getType(e) !== y.undefined) {
|
|
1415
|
-
const s = this._getOrReturnCtx(e);
|
|
1416
|
-
return v(s, {
|
|
1417
|
-
code: p.invalid_type,
|
|
1418
|
-
expected: y.undefined,
|
|
1419
|
-
received: s.parsedType
|
|
1420
|
-
}), S;
|
|
1421
|
-
}
|
|
1422
|
-
return U(e.data);
|
|
1423
|
-
}
|
|
1424
|
-
}
|
|
1425
|
-
et.create = (r) => new et({
|
|
1426
|
-
typeName: O.ZodUndefined,
|
|
1427
|
-
...T(r)
|
|
1428
|
-
});
|
|
1429
|
-
class tt extends I {
|
|
1430
|
-
_parse(e) {
|
|
1431
|
-
if (this._getType(e) !== y.null) {
|
|
1432
|
-
const s = this._getOrReturnCtx(e);
|
|
1433
|
-
return v(s, {
|
|
1434
|
-
code: p.invalid_type,
|
|
1435
|
-
expected: y.null,
|
|
1436
|
-
received: s.parsedType
|
|
1437
|
-
}), S;
|
|
1438
|
-
}
|
|
1439
|
-
return U(e.data);
|
|
1440
|
-
}
|
|
1441
|
-
}
|
|
1442
|
-
tt.create = (r) => new tt({
|
|
1443
|
-
typeName: O.ZodNull,
|
|
1444
|
-
...T(r)
|
|
1445
|
-
});
|
|
1446
|
-
class rt extends I {
|
|
1447
|
-
constructor() {
|
|
1448
|
-
super(...arguments), this._any = !0;
|
|
1449
|
-
}
|
|
1450
|
-
_parse(e) {
|
|
1451
|
-
return U(e.data);
|
|
1452
|
-
}
|
|
1453
|
-
}
|
|
1454
|
-
rt.create = (r) => new rt({
|
|
1455
|
-
typeName: O.ZodAny,
|
|
1456
|
-
...T(r)
|
|
1457
|
-
});
|
|
1458
|
-
class nt extends I {
|
|
1459
|
-
constructor() {
|
|
1460
|
-
super(...arguments), this._unknown = !0;
|
|
1461
|
-
}
|
|
1462
|
-
_parse(e) {
|
|
1463
|
-
return U(e.data);
|
|
1464
|
-
}
|
|
1465
|
-
}
|
|
1466
|
-
nt.create = (r) => new nt({
|
|
1467
|
-
typeName: O.ZodUnknown,
|
|
1468
|
-
...T(r)
|
|
1469
|
-
});
|
|
1470
|
-
class ne extends I {
|
|
1471
|
-
_parse(e) {
|
|
1472
|
-
const t = this._getOrReturnCtx(e);
|
|
1473
|
-
return v(t, {
|
|
1474
|
-
code: p.invalid_type,
|
|
1475
|
-
expected: y.never,
|
|
1476
|
-
received: t.parsedType
|
|
1477
|
-
}), S;
|
|
1478
|
-
}
|
|
1479
|
-
}
|
|
1480
|
-
ne.create = (r) => new ne({
|
|
1481
|
-
typeName: O.ZodNever,
|
|
1482
|
-
...T(r)
|
|
1483
|
-
});
|
|
1484
|
-
class st extends I {
|
|
1485
|
-
_parse(e) {
|
|
1486
|
-
if (this._getType(e) !== y.undefined) {
|
|
1487
|
-
const s = this._getOrReturnCtx(e);
|
|
1488
|
-
return v(s, {
|
|
1489
|
-
code: p.invalid_type,
|
|
1490
|
-
expected: y.void,
|
|
1491
|
-
received: s.parsedType
|
|
1492
|
-
}), S;
|
|
1493
|
-
}
|
|
1494
|
-
return U(e.data);
|
|
1495
|
-
}
|
|
1496
|
-
}
|
|
1497
|
-
st.create = (r) => new st({
|
|
1498
|
-
typeName: O.ZodVoid,
|
|
1499
|
-
...T(r)
|
|
1500
|
-
});
|
|
1501
|
-
class W extends I {
|
|
1502
|
-
_parse(e) {
|
|
1503
|
-
const { ctx: t, status: s } = this._processInputParams(e), n = this._def;
|
|
1504
|
-
if (t.parsedType !== y.array)
|
|
1505
|
-
return v(t, {
|
|
1506
|
-
code: p.invalid_type,
|
|
1507
|
-
expected: y.array,
|
|
1508
|
-
received: t.parsedType
|
|
1509
|
-
}), S;
|
|
1510
|
-
if (n.exactLength !== null) {
|
|
1511
|
-
const i = t.data.length > n.exactLength.value, o = t.data.length < n.exactLength.value;
|
|
1512
|
-
(i || o) && (v(t, {
|
|
1513
|
-
code: i ? p.too_big : p.too_small,
|
|
1514
|
-
minimum: o ? n.exactLength.value : void 0,
|
|
1515
|
-
maximum: i ? n.exactLength.value : void 0,
|
|
1516
|
-
type: "array",
|
|
1517
|
-
inclusive: !0,
|
|
1518
|
-
exact: !0,
|
|
1519
|
-
message: n.exactLength.message
|
|
1520
|
-
}), s.dirty());
|
|
1521
|
-
}
|
|
1522
|
-
if (n.minLength !== null && t.data.length < n.minLength.value && (v(t, {
|
|
1523
|
-
code: p.too_small,
|
|
1524
|
-
minimum: n.minLength.value,
|
|
1525
|
-
type: "array",
|
|
1526
|
-
inclusive: !0,
|
|
1527
|
-
exact: !1,
|
|
1528
|
-
message: n.minLength.message
|
|
1529
|
-
}), s.dirty()), n.maxLength !== null && t.data.length > n.maxLength.value && (v(t, {
|
|
1530
|
-
code: p.too_big,
|
|
1531
|
-
maximum: n.maxLength.value,
|
|
1532
|
-
type: "array",
|
|
1533
|
-
inclusive: !0,
|
|
1534
|
-
exact: !1,
|
|
1535
|
-
message: n.maxLength.message
|
|
1536
|
-
}), s.dirty()), t.common.async)
|
|
1537
|
-
return Promise.all([...t.data].map((i, o) => n.type._parseAsync(new K(t, i, t.path, o)))).then((i) => M.mergeArray(s, i));
|
|
1538
|
-
const a = [...t.data].map((i, o) => n.type._parseSync(new K(t, i, t.path, o)));
|
|
1539
|
-
return M.mergeArray(s, a);
|
|
1540
|
-
}
|
|
1541
|
-
get element() {
|
|
1542
|
-
return this._def.type;
|
|
1543
|
-
}
|
|
1544
|
-
min(e, t) {
|
|
1545
|
-
return new W({
|
|
1546
|
-
...this._def,
|
|
1547
|
-
minLength: { value: e, message: _.toString(t) }
|
|
1548
|
-
});
|
|
1549
|
-
}
|
|
1550
|
-
max(e, t) {
|
|
1551
|
-
return new W({
|
|
1552
|
-
...this._def,
|
|
1553
|
-
maxLength: { value: e, message: _.toString(t) }
|
|
1554
|
-
});
|
|
1555
|
-
}
|
|
1556
|
-
length(e, t) {
|
|
1557
|
-
return new W({
|
|
1558
|
-
...this._def,
|
|
1559
|
-
exactLength: { value: e, message: _.toString(t) }
|
|
1560
|
-
});
|
|
1561
|
-
}
|
|
1562
|
-
nonempty(e) {
|
|
1563
|
-
return this.min(1, e);
|
|
1564
|
-
}
|
|
1565
|
-
}
|
|
1566
|
-
W.create = (r, e) => new W({
|
|
1567
|
-
type: r,
|
|
1568
|
-
minLength: null,
|
|
1569
|
-
maxLength: null,
|
|
1570
|
-
exactLength: null,
|
|
1571
|
-
typeName: O.ZodArray,
|
|
1572
|
-
...T(e)
|
|
1573
|
-
});
|
|
1574
|
-
function oe(r) {
|
|
1575
|
-
if (r instanceof $) {
|
|
1576
|
-
const e = {};
|
|
1577
|
-
for (const t in r.shape) {
|
|
1578
|
-
const s = r.shape[t];
|
|
1579
|
-
e[t] = G.create(oe(s));
|
|
1580
|
-
}
|
|
1581
|
-
return new $({
|
|
1582
|
-
...r._def,
|
|
1583
|
-
shape: () => e
|
|
1584
|
-
});
|
|
1585
|
-
} else return r instanceof W ? new W({
|
|
1586
|
-
...r._def,
|
|
1587
|
-
type: oe(r.element)
|
|
1588
|
-
}) : r instanceof G ? G.create(oe(r.unwrap())) : r instanceof ae ? ae.create(oe(r.unwrap())) : r instanceof ie ? ie.create(r.items.map((e) => oe(e))) : r;
|
|
1589
|
-
}
|
|
1590
|
-
class $ extends I {
|
|
1591
|
-
constructor() {
|
|
1592
|
-
super(...arguments), this._cached = null, this.nonstrict = this.passthrough, this.augment = this.extend;
|
|
1593
|
-
}
|
|
1594
|
-
_getCached() {
|
|
1595
|
-
if (this._cached !== null)
|
|
1596
|
-
return this._cached;
|
|
1597
|
-
const e = this._def.shape(), t = V.objectKeys(e);
|
|
1598
|
-
return this._cached = { shape: e, keys: t }, this._cached;
|
|
1599
|
-
}
|
|
1600
|
-
_parse(e) {
|
|
1601
|
-
if (this._getType(e) !== y.object) {
|
|
1602
|
-
const l = this._getOrReturnCtx(e);
|
|
1603
|
-
return v(l, {
|
|
1604
|
-
code: p.invalid_type,
|
|
1605
|
-
expected: y.object,
|
|
1606
|
-
received: l.parsedType
|
|
1607
|
-
}), S;
|
|
1608
|
-
}
|
|
1609
|
-
const { status: s, ctx: n } = this._processInputParams(e), { shape: a, keys: i } = this._getCached(), o = [];
|
|
1610
|
-
if (!(this._def.catchall instanceof ne && this._def.unknownKeys === "strip"))
|
|
1611
|
-
for (const l in n.data)
|
|
1612
|
-
i.includes(l) || o.push(l);
|
|
1613
|
-
const u = [];
|
|
1614
|
-
for (const l of i) {
|
|
1615
|
-
const d = a[l], f = n.data[l];
|
|
1616
|
-
u.push({
|
|
1617
|
-
key: { status: "valid", value: l },
|
|
1618
|
-
value: d._parse(new K(n, f, n.path, l)),
|
|
1619
|
-
alwaysSet: l in n.data
|
|
1620
|
-
});
|
|
1621
|
-
}
|
|
1622
|
-
if (this._def.catchall instanceof ne) {
|
|
1623
|
-
const l = this._def.unknownKeys;
|
|
1624
|
-
if (l === "passthrough")
|
|
1625
|
-
for (const d of o)
|
|
1626
|
-
u.push({
|
|
1627
|
-
key: { status: "valid", value: d },
|
|
1628
|
-
value: { status: "valid", value: n.data[d] }
|
|
1629
|
-
});
|
|
1630
|
-
else if (l === "strict")
|
|
1631
|
-
o.length > 0 && (v(n, {
|
|
1632
|
-
code: p.unrecognized_keys,
|
|
1633
|
-
keys: o
|
|
1634
|
-
}), s.dirty());
|
|
1635
|
-
else if (l !== "strip") throw new Error("Internal ZodObject error: invalid unknownKeys value.");
|
|
1636
|
-
} else {
|
|
1637
|
-
const l = this._def.catchall;
|
|
1638
|
-
for (const d of o) {
|
|
1639
|
-
const f = n.data[d];
|
|
1640
|
-
u.push({
|
|
1641
|
-
key: { status: "valid", value: d },
|
|
1642
|
-
value: l._parse(
|
|
1643
|
-
new K(n, f, n.path, d)
|
|
1644
|
-
//, ctx.child(key), value, getParsedType(value)
|
|
1645
|
-
),
|
|
1646
|
-
alwaysSet: d in n.data
|
|
1647
|
-
});
|
|
1648
|
-
}
|
|
1649
|
-
}
|
|
1650
|
-
return n.common.async ? Promise.resolve().then(async () => {
|
|
1651
|
-
const l = [];
|
|
1652
|
-
for (const d of u) {
|
|
1653
|
-
const f = await d.key, k = await d.value;
|
|
1654
|
-
l.push({
|
|
1655
|
-
key: f,
|
|
1656
|
-
value: k,
|
|
1657
|
-
alwaysSet: d.alwaysSet
|
|
1658
|
-
});
|
|
1659
|
-
}
|
|
1660
|
-
return l;
|
|
1661
|
-
}).then((l) => M.mergeObjectSync(s, l)) : M.mergeObjectSync(s, u);
|
|
1662
|
-
}
|
|
1663
|
-
get shape() {
|
|
1664
|
-
return this._def.shape();
|
|
1665
|
-
}
|
|
1666
|
-
strict(e) {
|
|
1667
|
-
return _.errToObj, new $({
|
|
1668
|
-
...this._def,
|
|
1669
|
-
unknownKeys: "strict",
|
|
1670
|
-
...e !== void 0 ? {
|
|
1671
|
-
errorMap: (t, s) => {
|
|
1672
|
-
const n = this._def.errorMap?.(t, s).message ?? s.defaultError;
|
|
1673
|
-
return t.code === "unrecognized_keys" ? {
|
|
1674
|
-
message: _.errToObj(e).message ?? n
|
|
1675
|
-
} : {
|
|
1676
|
-
message: n
|
|
1677
|
-
};
|
|
1678
|
-
}
|
|
1679
|
-
} : {}
|
|
1680
|
-
});
|
|
1681
|
-
}
|
|
1682
|
-
strip() {
|
|
1683
|
-
return new $({
|
|
1684
|
-
...this._def,
|
|
1685
|
-
unknownKeys: "strip"
|
|
1686
|
-
});
|
|
1687
|
-
}
|
|
1688
|
-
passthrough() {
|
|
1689
|
-
return new $({
|
|
1690
|
-
...this._def,
|
|
1691
|
-
unknownKeys: "passthrough"
|
|
1692
|
-
});
|
|
1693
|
-
}
|
|
1694
|
-
// const AugmentFactory =
|
|
1695
|
-
// <Def extends ZodObjectDef>(def: Def) =>
|
|
1696
|
-
// <Augmentation extends ZodRawShape>(
|
|
1697
|
-
// augmentation: Augmentation
|
|
1698
|
-
// ): ZodObject<
|
|
1699
|
-
// extendShape<ReturnType<Def["shape"]>, Augmentation>,
|
|
1700
|
-
// Def["unknownKeys"],
|
|
1701
|
-
// Def["catchall"]
|
|
1702
|
-
// > => {
|
|
1703
|
-
// return new ZodObject({
|
|
1704
|
-
// ...def,
|
|
1705
|
-
// shape: () => ({
|
|
1706
|
-
// ...def.shape(),
|
|
1707
|
-
// ...augmentation,
|
|
1708
|
-
// }),
|
|
1709
|
-
// }) as any;
|
|
1710
|
-
// };
|
|
1711
|
-
extend(e) {
|
|
1712
|
-
return new $({
|
|
1713
|
-
...this._def,
|
|
1714
|
-
shape: () => ({
|
|
1715
|
-
...this._def.shape(),
|
|
1716
|
-
...e
|
|
1717
|
-
})
|
|
1718
|
-
});
|
|
1719
|
-
}
|
|
1720
|
-
/**
|
|
1721
|
-
* Prior to zod@1.0.12 there was a bug in the
|
|
1722
|
-
* inferred type of merged objects. Please
|
|
1723
|
-
* upgrade if you are experiencing issues.
|
|
1724
|
-
*/
|
|
1725
|
-
merge(e) {
|
|
1726
|
-
return new $({
|
|
1727
|
-
unknownKeys: e._def.unknownKeys,
|
|
1728
|
-
catchall: e._def.catchall,
|
|
1729
|
-
shape: () => ({
|
|
1730
|
-
...this._def.shape(),
|
|
1731
|
-
...e._def.shape()
|
|
1732
|
-
}),
|
|
1733
|
-
typeName: O.ZodObject
|
|
1734
|
-
});
|
|
1735
|
-
}
|
|
1736
|
-
// merge<
|
|
1737
|
-
// Incoming extends AnyZodObject,
|
|
1738
|
-
// Augmentation extends Incoming["shape"],
|
|
1739
|
-
// NewOutput extends {
|
|
1740
|
-
// [k in keyof Augmentation | keyof Output]: k extends keyof Augmentation
|
|
1741
|
-
// ? Augmentation[k]["_output"]
|
|
1742
|
-
// : k extends keyof Output
|
|
1743
|
-
// ? Output[k]
|
|
1744
|
-
// : never;
|
|
1745
|
-
// },
|
|
1746
|
-
// NewInput extends {
|
|
1747
|
-
// [k in keyof Augmentation | keyof Input]: k extends keyof Augmentation
|
|
1748
|
-
// ? Augmentation[k]["_input"]
|
|
1749
|
-
// : k extends keyof Input
|
|
1750
|
-
// ? Input[k]
|
|
1751
|
-
// : never;
|
|
1752
|
-
// }
|
|
1753
|
-
// >(
|
|
1754
|
-
// merging: Incoming
|
|
1755
|
-
// ): ZodObject<
|
|
1756
|
-
// extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
|
|
1757
|
-
// Incoming["_def"]["unknownKeys"],
|
|
1758
|
-
// Incoming["_def"]["catchall"],
|
|
1759
|
-
// NewOutput,
|
|
1760
|
-
// NewInput
|
|
1761
|
-
// > {
|
|
1762
|
-
// const merged: any = new ZodObject({
|
|
1763
|
-
// unknownKeys: merging._def.unknownKeys,
|
|
1764
|
-
// catchall: merging._def.catchall,
|
|
1765
|
-
// shape: () =>
|
|
1766
|
-
// objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
|
|
1767
|
-
// typeName: ZodFirstPartyTypeKind.ZodObject,
|
|
1768
|
-
// }) as any;
|
|
1769
|
-
// return merged;
|
|
1770
|
-
// }
|
|
1771
|
-
setKey(e, t) {
|
|
1772
|
-
return this.augment({ [e]: t });
|
|
1773
|
-
}
|
|
1774
|
-
// merge<Incoming extends AnyZodObject>(
|
|
1775
|
-
// merging: Incoming
|
|
1776
|
-
// ): //ZodObject<T & Incoming["_shape"], UnknownKeys, Catchall> = (merging) => {
|
|
1777
|
-
// ZodObject<
|
|
1778
|
-
// extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
|
|
1779
|
-
// Incoming["_def"]["unknownKeys"],
|
|
1780
|
-
// Incoming["_def"]["catchall"]
|
|
1781
|
-
// > {
|
|
1782
|
-
// // const mergedShape = objectUtil.mergeShapes(
|
|
1783
|
-
// // this._def.shape(),
|
|
1784
|
-
// // merging._def.shape()
|
|
1785
|
-
// // );
|
|
1786
|
-
// const merged: any = new ZodObject({
|
|
1787
|
-
// unknownKeys: merging._def.unknownKeys,
|
|
1788
|
-
// catchall: merging._def.catchall,
|
|
1789
|
-
// shape: () =>
|
|
1790
|
-
// objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
|
|
1791
|
-
// typeName: ZodFirstPartyTypeKind.ZodObject,
|
|
1792
|
-
// }) as any;
|
|
1793
|
-
// return merged;
|
|
1794
|
-
// }
|
|
1795
|
-
catchall(e) {
|
|
1796
|
-
return new $({
|
|
1797
|
-
...this._def,
|
|
1798
|
-
catchall: e
|
|
1799
|
-
});
|
|
1800
|
-
}
|
|
1801
|
-
pick(e) {
|
|
1802
|
-
const t = {};
|
|
1803
|
-
for (const s of V.objectKeys(e))
|
|
1804
|
-
e[s] && this.shape[s] && (t[s] = this.shape[s]);
|
|
1805
|
-
return new $({
|
|
1806
|
-
...this._def,
|
|
1807
|
-
shape: () => t
|
|
1808
|
-
});
|
|
1809
|
-
}
|
|
1810
|
-
omit(e) {
|
|
1811
|
-
const t = {};
|
|
1812
|
-
for (const s of V.objectKeys(this.shape))
|
|
1813
|
-
e[s] || (t[s] = this.shape[s]);
|
|
1814
|
-
return new $({
|
|
1815
|
-
...this._def,
|
|
1816
|
-
shape: () => t
|
|
1817
|
-
});
|
|
1818
|
-
}
|
|
1819
|
-
/**
|
|
1820
|
-
* @deprecated
|
|
1821
|
-
*/
|
|
1822
|
-
deepPartial() {
|
|
1823
|
-
return oe(this);
|
|
1824
|
-
}
|
|
1825
|
-
partial(e) {
|
|
1826
|
-
const t = {};
|
|
1827
|
-
for (const s of V.objectKeys(this.shape)) {
|
|
1828
|
-
const n = this.shape[s];
|
|
1829
|
-
e && !e[s] ? t[s] = n : t[s] = n.optional();
|
|
1830
|
-
}
|
|
1831
|
-
return new $({
|
|
1832
|
-
...this._def,
|
|
1833
|
-
shape: () => t
|
|
1834
|
-
});
|
|
1835
|
-
}
|
|
1836
|
-
required(e) {
|
|
1837
|
-
const t = {};
|
|
1838
|
-
for (const s of V.objectKeys(this.shape))
|
|
1839
|
-
if (e && !e[s])
|
|
1840
|
-
t[s] = this.shape[s];
|
|
1841
|
-
else {
|
|
1842
|
-
let a = this.shape[s];
|
|
1843
|
-
for (; a instanceof G; )
|
|
1844
|
-
a = a._def.innerType;
|
|
1845
|
-
t[s] = a;
|
|
1846
|
-
}
|
|
1847
|
-
return new $({
|
|
1848
|
-
...this._def,
|
|
1849
|
-
shape: () => t
|
|
1850
|
-
});
|
|
1851
|
-
}
|
|
1852
|
-
keyof() {
|
|
1853
|
-
return mt(V.objectKeys(this.shape));
|
|
1854
|
-
}
|
|
1855
|
-
}
|
|
1856
|
-
$.create = (r, e) => new $({
|
|
1857
|
-
shape: () => r,
|
|
1858
|
-
unknownKeys: "strip",
|
|
1859
|
-
catchall: ne.create(),
|
|
1860
|
-
typeName: O.ZodObject,
|
|
1861
|
-
...T(e)
|
|
1862
|
-
});
|
|
1863
|
-
$.strictCreate = (r, e) => new $({
|
|
1864
|
-
shape: () => r,
|
|
1865
|
-
unknownKeys: "strict",
|
|
1866
|
-
catchall: ne.create(),
|
|
1867
|
-
typeName: O.ZodObject,
|
|
1868
|
-
...T(e)
|
|
1869
|
-
});
|
|
1870
|
-
$.lazycreate = (r, e) => new $({
|
|
1871
|
-
shape: r,
|
|
1872
|
-
unknownKeys: "strip",
|
|
1873
|
-
catchall: ne.create(),
|
|
1874
|
-
typeName: O.ZodObject,
|
|
1875
|
-
...T(e)
|
|
1876
|
-
});
|
|
1877
|
-
class Te extends I {
|
|
1878
|
-
_parse(e) {
|
|
1879
|
-
const { ctx: t } = this._processInputParams(e), s = this._def.options;
|
|
1880
|
-
function n(a) {
|
|
1881
|
-
for (const o of a)
|
|
1882
|
-
if (o.result.status === "valid")
|
|
1883
|
-
return o.result;
|
|
1884
|
-
for (const o of a)
|
|
1885
|
-
if (o.result.status === "dirty")
|
|
1886
|
-
return t.common.issues.push(...o.ctx.common.issues), o.result;
|
|
1887
|
-
const i = a.map((o) => new q(o.ctx.common.issues));
|
|
1888
|
-
return v(t, {
|
|
1889
|
-
code: p.invalid_union,
|
|
1890
|
-
unionErrors: i
|
|
1891
|
-
}), S;
|
|
1892
|
-
}
|
|
1893
|
-
if (t.common.async)
|
|
1894
|
-
return Promise.all(s.map(async (a) => {
|
|
1895
|
-
const i = {
|
|
1896
|
-
...t,
|
|
1897
|
-
common: {
|
|
1898
|
-
...t.common,
|
|
1899
|
-
issues: []
|
|
1900
|
-
},
|
|
1901
|
-
parent: null
|
|
1902
|
-
};
|
|
1903
|
-
return {
|
|
1904
|
-
result: await a._parseAsync({
|
|
1905
|
-
data: t.data,
|
|
1906
|
-
path: t.path,
|
|
1907
|
-
parent: i
|
|
1908
|
-
}),
|
|
1909
|
-
ctx: i
|
|
1910
|
-
};
|
|
1911
|
-
})).then(n);
|
|
1912
|
-
{
|
|
1913
|
-
let a;
|
|
1914
|
-
const i = [];
|
|
1915
|
-
for (const u of s) {
|
|
1916
|
-
const l = {
|
|
1917
|
-
...t,
|
|
1918
|
-
common: {
|
|
1919
|
-
...t.common,
|
|
1920
|
-
issues: []
|
|
1921
|
-
},
|
|
1922
|
-
parent: null
|
|
1923
|
-
}, d = u._parseSync({
|
|
1924
|
-
data: t.data,
|
|
1925
|
-
path: t.path,
|
|
1926
|
-
parent: l
|
|
1927
|
-
});
|
|
1928
|
-
if (d.status === "valid")
|
|
1929
|
-
return d;
|
|
1930
|
-
d.status === "dirty" && !a && (a = { result: d, ctx: l }), l.common.issues.length && i.push(l.common.issues);
|
|
1931
|
-
}
|
|
1932
|
-
if (a)
|
|
1933
|
-
return t.common.issues.push(...a.ctx.common.issues), a.result;
|
|
1934
|
-
const o = i.map((u) => new q(u));
|
|
1935
|
-
return v(t, {
|
|
1936
|
-
code: p.invalid_union,
|
|
1937
|
-
unionErrors: o
|
|
1938
|
-
}), S;
|
|
1939
|
-
}
|
|
1940
|
-
}
|
|
1941
|
-
get options() {
|
|
1942
|
-
return this._def.options;
|
|
1943
|
-
}
|
|
1944
|
-
}
|
|
1945
|
-
Te.create = (r, e) => new Te({
|
|
1946
|
-
options: r,
|
|
1947
|
-
typeName: O.ZodUnion,
|
|
1948
|
-
...T(e)
|
|
1949
|
-
});
|
|
1950
|
-
function De(r, e) {
|
|
1951
|
-
const t = te(r), s = te(e);
|
|
1952
|
-
if (r === e)
|
|
1953
|
-
return { valid: !0, data: r };
|
|
1954
|
-
if (t === y.object && s === y.object) {
|
|
1955
|
-
const n = V.objectKeys(e), a = V.objectKeys(r).filter((o) => n.indexOf(o) !== -1), i = { ...r, ...e };
|
|
1956
|
-
for (const o of a) {
|
|
1957
|
-
const u = De(r[o], e[o]);
|
|
1958
|
-
if (!u.valid)
|
|
1959
|
-
return { valid: !1 };
|
|
1960
|
-
i[o] = u.data;
|
|
1961
|
-
}
|
|
1962
|
-
return { valid: !0, data: i };
|
|
1963
|
-
} else if (t === y.array && s === y.array) {
|
|
1964
|
-
if (r.length !== e.length)
|
|
1965
|
-
return { valid: !1 };
|
|
1966
|
-
const n = [];
|
|
1967
|
-
for (let a = 0; a < r.length; a++) {
|
|
1968
|
-
const i = r[a], o = e[a], u = De(i, o);
|
|
1969
|
-
if (!u.valid)
|
|
1970
|
-
return { valid: !1 };
|
|
1971
|
-
n.push(u.data);
|
|
1972
|
-
}
|
|
1973
|
-
return { valid: !0, data: n };
|
|
1974
|
-
} else return t === y.date && s === y.date && +r == +e ? { valid: !0, data: r } : { valid: !1 };
|
|
1975
|
-
}
|
|
1976
|
-
class Ne extends I {
|
|
1977
|
-
_parse(e) {
|
|
1978
|
-
const { status: t, ctx: s } = this._processInputParams(e), n = (a, i) => {
|
|
1979
|
-
if (Ke(a) || Ke(i))
|
|
1980
|
-
return S;
|
|
1981
|
-
const o = De(a.value, i.value);
|
|
1982
|
-
return o.valid ? ((Ye(a) || Ye(i)) && t.dirty(), { status: t.value, value: o.data }) : (v(s, {
|
|
1983
|
-
code: p.invalid_intersection_types
|
|
1984
|
-
}), S);
|
|
1985
|
-
};
|
|
1986
|
-
return s.common.async ? Promise.all([
|
|
1987
|
-
this._def.left._parseAsync({
|
|
1988
|
-
data: s.data,
|
|
1989
|
-
path: s.path,
|
|
1990
|
-
parent: s
|
|
1991
|
-
}),
|
|
1992
|
-
this._def.right._parseAsync({
|
|
1993
|
-
data: s.data,
|
|
1994
|
-
path: s.path,
|
|
1995
|
-
parent: s
|
|
1996
|
-
})
|
|
1997
|
-
]).then(([a, i]) => n(a, i)) : n(this._def.left._parseSync({
|
|
1998
|
-
data: s.data,
|
|
1999
|
-
path: s.path,
|
|
2000
|
-
parent: s
|
|
2001
|
-
}), this._def.right._parseSync({
|
|
2002
|
-
data: s.data,
|
|
2003
|
-
path: s.path,
|
|
2004
|
-
parent: s
|
|
2005
|
-
}));
|
|
2006
|
-
}
|
|
2007
|
-
}
|
|
2008
|
-
Ne.create = (r, e, t) => new Ne({
|
|
2009
|
-
left: r,
|
|
2010
|
-
right: e,
|
|
2011
|
-
typeName: O.ZodIntersection,
|
|
2012
|
-
...T(t)
|
|
2013
|
-
});
|
|
2014
|
-
class ie extends I {
|
|
2015
|
-
_parse(e) {
|
|
2016
|
-
const { status: t, ctx: s } = this._processInputParams(e);
|
|
2017
|
-
if (s.parsedType !== y.array)
|
|
2018
|
-
return v(s, {
|
|
2019
|
-
code: p.invalid_type,
|
|
2020
|
-
expected: y.array,
|
|
2021
|
-
received: s.parsedType
|
|
2022
|
-
}), S;
|
|
2023
|
-
if (s.data.length < this._def.items.length)
|
|
2024
|
-
return v(s, {
|
|
2025
|
-
code: p.too_small,
|
|
2026
|
-
minimum: this._def.items.length,
|
|
2027
|
-
inclusive: !0,
|
|
2028
|
-
exact: !1,
|
|
2029
|
-
type: "array"
|
|
2030
|
-
}), S;
|
|
2031
|
-
!this._def.rest && s.data.length > this._def.items.length && (v(s, {
|
|
2032
|
-
code: p.too_big,
|
|
2033
|
-
maximum: this._def.items.length,
|
|
2034
|
-
inclusive: !0,
|
|
2035
|
-
exact: !1,
|
|
2036
|
-
type: "array"
|
|
2037
|
-
}), t.dirty());
|
|
2038
|
-
const a = [...s.data].map((i, o) => {
|
|
2039
|
-
const u = this._def.items[o] || this._def.rest;
|
|
2040
|
-
return u ? u._parse(new K(s, i, s.path, o)) : null;
|
|
2041
|
-
}).filter((i) => !!i);
|
|
2042
|
-
return s.common.async ? Promise.all(a).then((i) => M.mergeArray(t, i)) : M.mergeArray(t, a);
|
|
2043
|
-
}
|
|
2044
|
-
get items() {
|
|
2045
|
-
return this._def.items;
|
|
2046
|
-
}
|
|
2047
|
-
rest(e) {
|
|
2048
|
-
return new ie({
|
|
2049
|
-
...this._def,
|
|
2050
|
-
rest: e
|
|
2051
|
-
});
|
|
2052
|
-
}
|
|
2053
|
-
}
|
|
2054
|
-
ie.create = (r, e) => {
|
|
2055
|
-
if (!Array.isArray(r))
|
|
2056
|
-
throw new Error("You must pass an array of schemas to z.tuple([ ... ])");
|
|
2057
|
-
return new ie({
|
|
2058
|
-
items: r,
|
|
2059
|
-
typeName: O.ZodTuple,
|
|
2060
|
-
rest: null,
|
|
2061
|
-
...T(e)
|
|
2062
|
-
});
|
|
2063
|
-
};
|
|
2064
|
-
class Ie extends I {
|
|
2065
|
-
get keySchema() {
|
|
2066
|
-
return this._def.keyType;
|
|
2067
|
-
}
|
|
2068
|
-
get valueSchema() {
|
|
2069
|
-
return this._def.valueType;
|
|
2070
|
-
}
|
|
2071
|
-
_parse(e) {
|
|
2072
|
-
const { status: t, ctx: s } = this._processInputParams(e);
|
|
2073
|
-
if (s.parsedType !== y.object)
|
|
2074
|
-
return v(s, {
|
|
2075
|
-
code: p.invalid_type,
|
|
2076
|
-
expected: y.object,
|
|
2077
|
-
received: s.parsedType
|
|
2078
|
-
}), S;
|
|
2079
|
-
const n = [], a = this._def.keyType, i = this._def.valueType;
|
|
2080
|
-
for (const o in s.data)
|
|
2081
|
-
n.push({
|
|
2082
|
-
key: a._parse(new K(s, o, s.path, o)),
|
|
2083
|
-
value: i._parse(new K(s, s.data[o], s.path, o)),
|
|
2084
|
-
alwaysSet: o in s.data
|
|
2085
|
-
});
|
|
2086
|
-
return s.common.async ? M.mergeObjectAsync(t, n) : M.mergeObjectSync(t, n);
|
|
2087
|
-
}
|
|
2088
|
-
get element() {
|
|
2089
|
-
return this._def.valueType;
|
|
2090
|
-
}
|
|
2091
|
-
static create(e, t, s) {
|
|
2092
|
-
return t instanceof I ? new Ie({
|
|
2093
|
-
keyType: e,
|
|
2094
|
-
valueType: t,
|
|
2095
|
-
typeName: O.ZodRecord,
|
|
2096
|
-
...T(s)
|
|
2097
|
-
}) : new Ie({
|
|
2098
|
-
keyType: Y.create(),
|
|
2099
|
-
valueType: e,
|
|
2100
|
-
typeName: O.ZodRecord,
|
|
2101
|
-
...T(t)
|
|
2102
|
-
});
|
|
2103
|
-
}
|
|
2104
|
-
}
|
|
2105
|
-
class at extends I {
|
|
2106
|
-
get keySchema() {
|
|
2107
|
-
return this._def.keyType;
|
|
2108
|
-
}
|
|
2109
|
-
get valueSchema() {
|
|
2110
|
-
return this._def.valueType;
|
|
2111
|
-
}
|
|
2112
|
-
_parse(e) {
|
|
2113
|
-
const { status: t, ctx: s } = this._processInputParams(e);
|
|
2114
|
-
if (s.parsedType !== y.map)
|
|
2115
|
-
return v(s, {
|
|
2116
|
-
code: p.invalid_type,
|
|
2117
|
-
expected: y.map,
|
|
2118
|
-
received: s.parsedType
|
|
2119
|
-
}), S;
|
|
2120
|
-
const n = this._def.keyType, a = this._def.valueType, i = [...s.data.entries()].map(([o, u], l) => ({
|
|
2121
|
-
key: n._parse(new K(s, o, s.path, [l, "key"])),
|
|
2122
|
-
value: a._parse(new K(s, u, s.path, [l, "value"]))
|
|
2123
|
-
}));
|
|
2124
|
-
if (s.common.async) {
|
|
2125
|
-
const o = /* @__PURE__ */ new Map();
|
|
2126
|
-
return Promise.resolve().then(async () => {
|
|
2127
|
-
for (const u of i) {
|
|
2128
|
-
const l = await u.key, d = await u.value;
|
|
2129
|
-
if (l.status === "aborted" || d.status === "aborted")
|
|
2130
|
-
return S;
|
|
2131
|
-
(l.status === "dirty" || d.status === "dirty") && t.dirty(), o.set(l.value, d.value);
|
|
2132
|
-
}
|
|
2133
|
-
return { status: t.value, value: o };
|
|
2134
|
-
});
|
|
2135
|
-
} else {
|
|
2136
|
-
const o = /* @__PURE__ */ new Map();
|
|
2137
|
-
for (const u of i) {
|
|
2138
|
-
const l = u.key, d = u.value;
|
|
2139
|
-
if (l.status === "aborted" || d.status === "aborted")
|
|
2140
|
-
return S;
|
|
2141
|
-
(l.status === "dirty" || d.status === "dirty") && t.dirty(), o.set(l.value, d.value);
|
|
2142
|
-
}
|
|
2143
|
-
return { status: t.value, value: o };
|
|
2144
|
-
}
|
|
2145
|
-
}
|
|
2146
|
-
}
|
|
2147
|
-
at.create = (r, e, t) => new at({
|
|
2148
|
-
valueType: e,
|
|
2149
|
-
keyType: r,
|
|
2150
|
-
typeName: O.ZodMap,
|
|
2151
|
-
...T(t)
|
|
2152
|
-
});
|
|
2153
|
-
class ge extends I {
|
|
2154
|
-
_parse(e) {
|
|
2155
|
-
const { status: t, ctx: s } = this._processInputParams(e);
|
|
2156
|
-
if (s.parsedType !== y.set)
|
|
2157
|
-
return v(s, {
|
|
2158
|
-
code: p.invalid_type,
|
|
2159
|
-
expected: y.set,
|
|
2160
|
-
received: s.parsedType
|
|
2161
|
-
}), S;
|
|
2162
|
-
const n = this._def;
|
|
2163
|
-
n.minSize !== null && s.data.size < n.minSize.value && (v(s, {
|
|
2164
|
-
code: p.too_small,
|
|
2165
|
-
minimum: n.minSize.value,
|
|
2166
|
-
type: "set",
|
|
2167
|
-
inclusive: !0,
|
|
2168
|
-
exact: !1,
|
|
2169
|
-
message: n.minSize.message
|
|
2170
|
-
}), t.dirty()), n.maxSize !== null && s.data.size > n.maxSize.value && (v(s, {
|
|
2171
|
-
code: p.too_big,
|
|
2172
|
-
maximum: n.maxSize.value,
|
|
2173
|
-
type: "set",
|
|
2174
|
-
inclusive: !0,
|
|
2175
|
-
exact: !1,
|
|
2176
|
-
message: n.maxSize.message
|
|
2177
|
-
}), t.dirty());
|
|
2178
|
-
const a = this._def.valueType;
|
|
2179
|
-
function i(u) {
|
|
2180
|
-
const l = /* @__PURE__ */ new Set();
|
|
2181
|
-
for (const d of u) {
|
|
2182
|
-
if (d.status === "aborted")
|
|
2183
|
-
return S;
|
|
2184
|
-
d.status === "dirty" && t.dirty(), l.add(d.value);
|
|
2185
|
-
}
|
|
2186
|
-
return { status: t.value, value: l };
|
|
2187
|
-
}
|
|
2188
|
-
const o = [...s.data.values()].map((u, l) => a._parse(new K(s, u, s.path, l)));
|
|
2189
|
-
return s.common.async ? Promise.all(o).then((u) => i(u)) : i(o);
|
|
2190
|
-
}
|
|
2191
|
-
min(e, t) {
|
|
2192
|
-
return new ge({
|
|
2193
|
-
...this._def,
|
|
2194
|
-
minSize: { value: e, message: _.toString(t) }
|
|
2195
|
-
});
|
|
2196
|
-
}
|
|
2197
|
-
max(e, t) {
|
|
2198
|
-
return new ge({
|
|
2199
|
-
...this._def,
|
|
2200
|
-
maxSize: { value: e, message: _.toString(t) }
|
|
2201
|
-
});
|
|
2202
|
-
}
|
|
2203
|
-
size(e, t) {
|
|
2204
|
-
return this.min(e, t).max(e, t);
|
|
2205
|
-
}
|
|
2206
|
-
nonempty(e) {
|
|
2207
|
-
return this.min(1, e);
|
|
2208
|
-
}
|
|
2209
|
-
}
|
|
2210
|
-
ge.create = (r, e) => new ge({
|
|
2211
|
-
valueType: r,
|
|
2212
|
-
minSize: null,
|
|
2213
|
-
maxSize: null,
|
|
2214
|
-
typeName: O.ZodSet,
|
|
2215
|
-
...T(e)
|
|
2216
|
-
});
|
|
2217
|
-
class it extends I {
|
|
2218
|
-
get schema() {
|
|
2219
|
-
return this._def.getter();
|
|
2220
|
-
}
|
|
2221
|
-
_parse(e) {
|
|
2222
|
-
const { ctx: t } = this._processInputParams(e);
|
|
2223
|
-
return this._def.getter()._parse({ data: t.data, path: t.path, parent: t });
|
|
2224
|
-
}
|
|
2225
|
-
}
|
|
2226
|
-
it.create = (r, e) => new it({
|
|
2227
|
-
getter: r,
|
|
2228
|
-
typeName: O.ZodLazy,
|
|
2229
|
-
...T(e)
|
|
2230
|
-
});
|
|
2231
|
-
class ot extends I {
|
|
2232
|
-
_parse(e) {
|
|
2233
|
-
if (e.data !== this._def.value) {
|
|
2234
|
-
const t = this._getOrReturnCtx(e);
|
|
2235
|
-
return v(t, {
|
|
2236
|
-
received: t.data,
|
|
2237
|
-
code: p.invalid_literal,
|
|
2238
|
-
expected: this._def.value
|
|
2239
|
-
}), S;
|
|
2240
|
-
}
|
|
2241
|
-
return { status: "valid", value: e.data };
|
|
2242
|
-
}
|
|
2243
|
-
get value() {
|
|
2244
|
-
return this._def.value;
|
|
2245
|
-
}
|
|
2246
|
-
}
|
|
2247
|
-
ot.create = (r, e) => new ot({
|
|
2248
|
-
value: r,
|
|
2249
|
-
typeName: O.ZodLiteral,
|
|
2250
|
-
...T(e)
|
|
2251
|
-
});
|
|
2252
|
-
function mt(r, e) {
|
|
2253
|
-
return new fe({
|
|
2254
|
-
values: r,
|
|
2255
|
-
typeName: O.ZodEnum,
|
|
2256
|
-
...T(e)
|
|
2257
|
-
});
|
|
2258
|
-
}
|
|
2259
|
-
class fe extends I {
|
|
2260
|
-
_parse(e) {
|
|
2261
|
-
if (typeof e.data != "string") {
|
|
2262
|
-
const t = this._getOrReturnCtx(e), s = this._def.values;
|
|
2263
|
-
return v(t, {
|
|
2264
|
-
expected: V.joinValues(s),
|
|
2265
|
-
received: t.parsedType,
|
|
2266
|
-
code: p.invalid_type
|
|
2267
|
-
}), S;
|
|
2268
|
-
}
|
|
2269
|
-
if (this._cache || (this._cache = new Set(this._def.values)), !this._cache.has(e.data)) {
|
|
2270
|
-
const t = this._getOrReturnCtx(e), s = this._def.values;
|
|
2271
|
-
return v(t, {
|
|
2272
|
-
received: t.data,
|
|
2273
|
-
code: p.invalid_enum_value,
|
|
2274
|
-
options: s
|
|
2275
|
-
}), S;
|
|
2276
|
-
}
|
|
2277
|
-
return U(e.data);
|
|
2278
|
-
}
|
|
2279
|
-
get options() {
|
|
2280
|
-
return this._def.values;
|
|
2281
|
-
}
|
|
2282
|
-
get enum() {
|
|
2283
|
-
const e = {};
|
|
2284
|
-
for (const t of this._def.values)
|
|
2285
|
-
e[t] = t;
|
|
2286
|
-
return e;
|
|
2287
|
-
}
|
|
2288
|
-
get Values() {
|
|
2289
|
-
const e = {};
|
|
2290
|
-
for (const t of this._def.values)
|
|
2291
|
-
e[t] = t;
|
|
2292
|
-
return e;
|
|
2293
|
-
}
|
|
2294
|
-
get Enum() {
|
|
2295
|
-
const e = {};
|
|
2296
|
-
for (const t of this._def.values)
|
|
2297
|
-
e[t] = t;
|
|
2298
|
-
return e;
|
|
2299
|
-
}
|
|
2300
|
-
extract(e, t = this._def) {
|
|
2301
|
-
return fe.create(e, {
|
|
2302
|
-
...this._def,
|
|
2303
|
-
...t
|
|
2304
|
-
});
|
|
2305
|
-
}
|
|
2306
|
-
exclude(e, t = this._def) {
|
|
2307
|
-
return fe.create(this.options.filter((s) => !e.includes(s)), {
|
|
2308
|
-
...this._def,
|
|
2309
|
-
...t
|
|
2310
|
-
});
|
|
2311
|
-
}
|
|
2312
|
-
}
|
|
2313
|
-
fe.create = mt;
|
|
2314
|
-
class ut extends I {
|
|
2315
|
-
_parse(e) {
|
|
2316
|
-
const t = V.getValidEnumValues(this._def.values), s = this._getOrReturnCtx(e);
|
|
2317
|
-
if (s.parsedType !== y.string && s.parsedType !== y.number) {
|
|
2318
|
-
const n = V.objectValues(t);
|
|
2319
|
-
return v(s, {
|
|
2320
|
-
expected: V.joinValues(n),
|
|
2321
|
-
received: s.parsedType,
|
|
2322
|
-
code: p.invalid_type
|
|
2323
|
-
}), S;
|
|
2324
|
-
}
|
|
2325
|
-
if (this._cache || (this._cache = new Set(V.getValidEnumValues(this._def.values))), !this._cache.has(e.data)) {
|
|
2326
|
-
const n = V.objectValues(t);
|
|
2327
|
-
return v(s, {
|
|
2328
|
-
received: s.data,
|
|
2329
|
-
code: p.invalid_enum_value,
|
|
2330
|
-
options: n
|
|
2331
|
-
}), S;
|
|
2332
|
-
}
|
|
2333
|
-
return U(e.data);
|
|
2334
|
-
}
|
|
2335
|
-
get enum() {
|
|
2336
|
-
return this._def.values;
|
|
2337
|
-
}
|
|
2338
|
-
}
|
|
2339
|
-
ut.create = (r, e) => new ut({
|
|
2340
|
-
values: r,
|
|
2341
|
-
typeName: O.ZodNativeEnum,
|
|
2342
|
-
...T(e)
|
|
2343
|
-
});
|
|
2344
|
-
class Ce extends I {
|
|
2345
|
-
unwrap() {
|
|
2346
|
-
return this._def.type;
|
|
2347
|
-
}
|
|
2348
|
-
_parse(e) {
|
|
2349
|
-
const { ctx: t } = this._processInputParams(e);
|
|
2350
|
-
if (t.parsedType !== y.promise && t.common.async === !1)
|
|
2351
|
-
return v(t, {
|
|
2352
|
-
code: p.invalid_type,
|
|
2353
|
-
expected: y.promise,
|
|
2354
|
-
received: t.parsedType
|
|
2355
|
-
}), S;
|
|
2356
|
-
const s = t.parsedType === y.promise ? t.data : Promise.resolve(t.data);
|
|
2357
|
-
return U(s.then((n) => this._def.type.parseAsync(n, {
|
|
2358
|
-
path: t.path,
|
|
2359
|
-
errorMap: t.common.contextualErrorMap
|
|
2360
|
-
})));
|
|
2361
|
-
}
|
|
2362
|
-
}
|
|
2363
|
-
Ce.create = (r, e) => new Ce({
|
|
2364
|
-
type: r,
|
|
2365
|
-
typeName: O.ZodPromise,
|
|
2366
|
-
...T(e)
|
|
2367
|
-
});
|
|
2368
|
-
class se extends I {
|
|
2369
|
-
innerType() {
|
|
2370
|
-
return this._def.schema;
|
|
2371
|
-
}
|
|
2372
|
-
sourceType() {
|
|
2373
|
-
return this._def.schema._def.typeName === O.ZodEffects ? this._def.schema.sourceType() : this._def.schema;
|
|
2374
|
-
}
|
|
2375
|
-
_parse(e) {
|
|
2376
|
-
const { status: t, ctx: s } = this._processInputParams(e), n = this._def.effect || null, a = {
|
|
2377
|
-
addIssue: (i) => {
|
|
2378
|
-
v(s, i), i.fatal ? t.abort() : t.dirty();
|
|
2379
|
-
},
|
|
2380
|
-
get path() {
|
|
2381
|
-
return s.path;
|
|
2382
|
-
}
|
|
2383
|
-
};
|
|
2384
|
-
if (a.addIssue = a.addIssue.bind(a), n.type === "preprocess") {
|
|
2385
|
-
const i = n.transform(s.data, a);
|
|
2386
|
-
if (s.common.async)
|
|
2387
|
-
return Promise.resolve(i).then(async (o) => {
|
|
2388
|
-
if (t.value === "aborted")
|
|
2389
|
-
return S;
|
|
2390
|
-
const u = await this._def.schema._parseAsync({
|
|
2391
|
-
data: o,
|
|
2392
|
-
path: s.path,
|
|
2393
|
-
parent: s
|
|
2394
|
-
});
|
|
2395
|
-
return u.status === "aborted" ? S : u.status === "dirty" || t.value === "dirty" ? pe(u.value) : u;
|
|
2396
|
-
});
|
|
2397
|
-
{
|
|
2398
|
-
if (t.value === "aborted")
|
|
2399
|
-
return S;
|
|
2400
|
-
const o = this._def.schema._parseSync({
|
|
2401
|
-
data: i,
|
|
2402
|
-
path: s.path,
|
|
2403
|
-
parent: s
|
|
2404
|
-
});
|
|
2405
|
-
return o.status === "aborted" ? S : o.status === "dirty" || t.value === "dirty" ? pe(o.value) : o;
|
|
2406
|
-
}
|
|
2407
|
-
}
|
|
2408
|
-
if (n.type === "refinement") {
|
|
2409
|
-
const i = (o) => {
|
|
2410
|
-
const u = n.refinement(o, a);
|
|
2411
|
-
if (s.common.async)
|
|
2412
|
-
return Promise.resolve(u);
|
|
2413
|
-
if (u instanceof Promise)
|
|
2414
|
-
throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");
|
|
2415
|
-
return o;
|
|
2416
|
-
};
|
|
2417
|
-
if (s.common.async === !1) {
|
|
2418
|
-
const o = this._def.schema._parseSync({
|
|
2419
|
-
data: s.data,
|
|
2420
|
-
path: s.path,
|
|
2421
|
-
parent: s
|
|
2422
|
-
});
|
|
2423
|
-
return o.status === "aborted" ? S : (o.status === "dirty" && t.dirty(), i(o.value), { status: t.value, value: o.value });
|
|
2424
|
-
} else
|
|
2425
|
-
return this._def.schema._parseAsync({ data: s.data, path: s.path, parent: s }).then((o) => o.status === "aborted" ? S : (o.status === "dirty" && t.dirty(), i(o.value).then(() => ({ status: t.value, value: o.value }))));
|
|
2426
|
-
}
|
|
2427
|
-
if (n.type === "transform")
|
|
2428
|
-
if (s.common.async === !1) {
|
|
2429
|
-
const i = this._def.schema._parseSync({
|
|
2430
|
-
data: s.data,
|
|
2431
|
-
path: s.path,
|
|
2432
|
-
parent: s
|
|
2433
|
-
});
|
|
2434
|
-
if (!de(i))
|
|
2435
|
-
return S;
|
|
2436
|
-
const o = n.transform(i.value, a);
|
|
2437
|
-
if (o instanceof Promise)
|
|
2438
|
-
throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");
|
|
2439
|
-
return { status: t.value, value: o };
|
|
2440
|
-
} else
|
|
2441
|
-
return this._def.schema._parseAsync({ data: s.data, path: s.path, parent: s }).then((i) => de(i) ? Promise.resolve(n.transform(i.value, a)).then((o) => ({
|
|
2442
|
-
status: t.value,
|
|
2443
|
-
value: o
|
|
2444
|
-
})) : S);
|
|
2445
|
-
V.assertNever(n);
|
|
2446
|
-
}
|
|
2447
|
-
}
|
|
2448
|
-
se.create = (r, e, t) => new se({
|
|
2449
|
-
schema: r,
|
|
2450
|
-
typeName: O.ZodEffects,
|
|
2451
|
-
effect: e,
|
|
2452
|
-
...T(t)
|
|
2453
|
-
});
|
|
2454
|
-
se.createWithPreprocess = (r, e, t) => new se({
|
|
2455
|
-
schema: e,
|
|
2456
|
-
effect: { type: "preprocess", transform: r },
|
|
2457
|
-
typeName: O.ZodEffects,
|
|
2458
|
-
...T(t)
|
|
2459
|
-
});
|
|
2460
|
-
class G extends I {
|
|
2461
|
-
_parse(e) {
|
|
2462
|
-
return this._getType(e) === y.undefined ? U(void 0) : this._def.innerType._parse(e);
|
|
2463
|
-
}
|
|
2464
|
-
unwrap() {
|
|
2465
|
-
return this._def.innerType;
|
|
2466
|
-
}
|
|
2467
|
-
}
|
|
2468
|
-
G.create = (r, e) => new G({
|
|
2469
|
-
innerType: r,
|
|
2470
|
-
typeName: O.ZodOptional,
|
|
2471
|
-
...T(e)
|
|
2472
|
-
});
|
|
2473
|
-
class ae extends I {
|
|
2474
|
-
_parse(e) {
|
|
2475
|
-
return this._getType(e) === y.null ? U(null) : this._def.innerType._parse(e);
|
|
2476
|
-
}
|
|
2477
|
-
unwrap() {
|
|
2478
|
-
return this._def.innerType;
|
|
2479
|
-
}
|
|
2480
|
-
}
|
|
2481
|
-
ae.create = (r, e) => new ae({
|
|
2482
|
-
innerType: r,
|
|
2483
|
-
typeName: O.ZodNullable,
|
|
2484
|
-
...T(e)
|
|
2485
|
-
});
|
|
2486
|
-
class Ee extends I {
|
|
2487
|
-
_parse(e) {
|
|
2488
|
-
const { ctx: t } = this._processInputParams(e);
|
|
2489
|
-
let s = t.data;
|
|
2490
|
-
return t.parsedType === y.undefined && (s = this._def.defaultValue()), this._def.innerType._parse({
|
|
2491
|
-
data: s,
|
|
2492
|
-
path: t.path,
|
|
2493
|
-
parent: t
|
|
2494
|
-
});
|
|
2495
|
-
}
|
|
2496
|
-
removeDefault() {
|
|
2497
|
-
return this._def.innerType;
|
|
2498
|
-
}
|
|
2499
|
-
}
|
|
2500
|
-
Ee.create = (r, e) => new Ee({
|
|
2501
|
-
innerType: r,
|
|
2502
|
-
typeName: O.ZodDefault,
|
|
2503
|
-
defaultValue: typeof e.default == "function" ? e.default : () => e.default,
|
|
2504
|
-
...T(e)
|
|
2505
|
-
});
|
|
2506
|
-
class ze extends I {
|
|
2507
|
-
_parse(e) {
|
|
2508
|
-
const { ctx: t } = this._processInputParams(e), s = {
|
|
2509
|
-
...t,
|
|
2510
|
-
common: {
|
|
2511
|
-
...t.common,
|
|
2512
|
-
issues: []
|
|
2513
|
-
}
|
|
2514
|
-
}, n = this._def.innerType._parse({
|
|
2515
|
-
data: s.data,
|
|
2516
|
-
path: s.path,
|
|
2517
|
-
parent: {
|
|
2518
|
-
...s
|
|
2519
|
-
}
|
|
2520
|
-
});
|
|
2521
|
-
return Se(n) ? n.then((a) => ({
|
|
2522
|
-
status: "valid",
|
|
2523
|
-
value: a.status === "valid" ? a.value : this._def.catchValue({
|
|
2524
|
-
get error() {
|
|
2525
|
-
return new q(s.common.issues);
|
|
2526
|
-
},
|
|
2527
|
-
input: s.data
|
|
2528
|
-
})
|
|
2529
|
-
})) : {
|
|
2530
|
-
status: "valid",
|
|
2531
|
-
value: n.status === "valid" ? n.value : this._def.catchValue({
|
|
2532
|
-
get error() {
|
|
2533
|
-
return new q(s.common.issues);
|
|
2534
|
-
},
|
|
2535
|
-
input: s.data
|
|
2536
|
-
})
|
|
2537
|
-
};
|
|
2538
|
-
}
|
|
2539
|
-
removeCatch() {
|
|
2540
|
-
return this._def.innerType;
|
|
2541
|
-
}
|
|
2542
|
-
}
|
|
2543
|
-
ze.create = (r, e) => new ze({
|
|
2544
|
-
innerType: r,
|
|
2545
|
-
typeName: O.ZodCatch,
|
|
2546
|
-
catchValue: typeof e.catch == "function" ? e.catch : () => e.catch,
|
|
2547
|
-
...T(e)
|
|
2548
|
-
});
|
|
2549
|
-
class ct extends I {
|
|
2550
|
-
_parse(e) {
|
|
2551
|
-
if (this._getType(e) !== y.nan) {
|
|
2552
|
-
const s = this._getOrReturnCtx(e);
|
|
2553
|
-
return v(s, {
|
|
2554
|
-
code: p.invalid_type,
|
|
2555
|
-
expected: y.nan,
|
|
2556
|
-
received: s.parsedType
|
|
2557
|
-
}), S;
|
|
2558
|
-
}
|
|
2559
|
-
return { status: "valid", value: e.data };
|
|
2560
|
-
}
|
|
2561
|
-
}
|
|
2562
|
-
ct.create = (r) => new ct({
|
|
2563
|
-
typeName: O.ZodNaN,
|
|
2564
|
-
...T(r)
|
|
2565
|
-
});
|
|
2566
|
-
class ir extends I {
|
|
2567
|
-
_parse(e) {
|
|
2568
|
-
const { ctx: t } = this._processInputParams(e), s = t.data;
|
|
2569
|
-
return this._def.type._parse({
|
|
2570
|
-
data: s,
|
|
2571
|
-
path: t.path,
|
|
2572
|
-
parent: t
|
|
2573
|
-
});
|
|
2574
|
-
}
|
|
2575
|
-
unwrap() {
|
|
2576
|
-
return this._def.type;
|
|
2577
|
-
}
|
|
2578
|
-
}
|
|
2579
|
-
class Ue extends I {
|
|
2580
|
-
_parse(e) {
|
|
2581
|
-
const { status: t, ctx: s } = this._processInputParams(e);
|
|
2582
|
-
if (s.common.async)
|
|
2583
|
-
return (async () => {
|
|
2584
|
-
const a = await this._def.in._parseAsync({
|
|
2585
|
-
data: s.data,
|
|
2586
|
-
path: s.path,
|
|
2587
|
-
parent: s
|
|
2588
|
-
});
|
|
2589
|
-
return a.status === "aborted" ? S : a.status === "dirty" ? (t.dirty(), pe(a.value)) : this._def.out._parseAsync({
|
|
2590
|
-
data: a.value,
|
|
2591
|
-
path: s.path,
|
|
2592
|
-
parent: s
|
|
2593
|
-
});
|
|
2594
|
-
})();
|
|
2595
|
-
{
|
|
2596
|
-
const n = this._def.in._parseSync({
|
|
2597
|
-
data: s.data,
|
|
2598
|
-
path: s.path,
|
|
2599
|
-
parent: s
|
|
2600
|
-
});
|
|
2601
|
-
return n.status === "aborted" ? S : n.status === "dirty" ? (t.dirty(), {
|
|
2602
|
-
status: "dirty",
|
|
2603
|
-
value: n.value
|
|
2604
|
-
}) : this._def.out._parseSync({
|
|
2605
|
-
data: n.value,
|
|
2606
|
-
path: s.path,
|
|
2607
|
-
parent: s
|
|
2608
|
-
});
|
|
2609
|
-
}
|
|
2610
|
-
}
|
|
2611
|
-
static create(e, t) {
|
|
2612
|
-
return new Ue({
|
|
2613
|
-
in: e,
|
|
2614
|
-
out: t,
|
|
2615
|
-
typeName: O.ZodPipeline
|
|
2616
|
-
});
|
|
2617
|
-
}
|
|
2618
|
-
}
|
|
2619
|
-
class Me extends I {
|
|
2620
|
-
_parse(e) {
|
|
2621
|
-
const t = this._def.innerType._parse(e), s = (n) => (de(n) && (n.value = Object.freeze(n.value)), n);
|
|
2622
|
-
return Se(t) ? t.then((n) => s(n)) : s(t);
|
|
2623
|
-
}
|
|
2624
|
-
unwrap() {
|
|
2625
|
-
return this._def.innerType;
|
|
2626
|
-
}
|
|
2627
|
-
}
|
|
2628
|
-
Me.create = (r, e) => new Me({
|
|
2629
|
-
innerType: r,
|
|
2630
|
-
typeName: O.ZodReadonly,
|
|
2631
|
-
...T(e)
|
|
2632
|
-
});
|
|
2633
|
-
var O;
|
|
2634
|
-
(function(r) {
|
|
2635
|
-
r.ZodString = "ZodString", r.ZodNumber = "ZodNumber", r.ZodNaN = "ZodNaN", r.ZodBigInt = "ZodBigInt", r.ZodBoolean = "ZodBoolean", r.ZodDate = "ZodDate", r.ZodSymbol = "ZodSymbol", r.ZodUndefined = "ZodUndefined", r.ZodNull = "ZodNull", r.ZodAny = "ZodAny", r.ZodUnknown = "ZodUnknown", r.ZodNever = "ZodNever", r.ZodVoid = "ZodVoid", r.ZodArray = "ZodArray", r.ZodObject = "ZodObject", r.ZodUnion = "ZodUnion", r.ZodDiscriminatedUnion = "ZodDiscriminatedUnion", r.ZodIntersection = "ZodIntersection", r.ZodTuple = "ZodTuple", r.ZodRecord = "ZodRecord", r.ZodMap = "ZodMap", r.ZodSet = "ZodSet", r.ZodFunction = "ZodFunction", r.ZodLazy = "ZodLazy", r.ZodLiteral = "ZodLiteral", r.ZodEnum = "ZodEnum", r.ZodEffects = "ZodEffects", r.ZodNativeEnum = "ZodNativeEnum", r.ZodOptional = "ZodOptional", r.ZodNullable = "ZodNullable", r.ZodDefault = "ZodDefault", r.ZodCatch = "ZodCatch", r.ZodPromise = "ZodPromise", r.ZodBranded = "ZodBranded", r.ZodPipeline = "ZodPipeline", r.ZodReadonly = "ZodReadonly";
|
|
2636
|
-
})(O || (O = {}));
|
|
2637
|
-
Y.create;
|
|
2638
|
-
ne.create;
|
|
2639
|
-
W.create;
|
|
2640
|
-
Te.create;
|
|
2641
|
-
Ne.create;
|
|
2642
|
-
ie.create;
|
|
2643
|
-
fe.create;
|
|
2644
|
-
Ce.create;
|
|
2645
|
-
G.create;
|
|
2646
|
-
ae.create;
|
|
2647
|
-
function vt(r, e, t) {
|
|
2648
|
-
function s(o, u) {
|
|
2649
|
-
var l;
|
|
2650
|
-
Object.defineProperty(o, "_zod", {
|
|
2651
|
-
value: o._zod ?? {},
|
|
2652
|
-
enumerable: !1
|
|
2653
|
-
}), (l = o._zod).traits ?? (l.traits = /* @__PURE__ */ new Set()), o._zod.traits.add(r), e(o, u);
|
|
2654
|
-
for (const d in i.prototype)
|
|
2655
|
-
d in o || Object.defineProperty(o, d, { value: i.prototype[d].bind(o) });
|
|
2656
|
-
o._zod.constr = i, o._zod.def = u;
|
|
2657
|
-
}
|
|
2658
|
-
const n = t?.Parent ?? Object;
|
|
2659
|
-
class a extends n {
|
|
2660
|
-
}
|
|
2661
|
-
Object.defineProperty(a, "name", { value: r });
|
|
2662
|
-
function i(o) {
|
|
2663
|
-
var u;
|
|
2664
|
-
const l = t?.Parent ? new a() : this;
|
|
2665
|
-
s(l, o), (u = l._zod).deferred ?? (u.deferred = []);
|
|
2666
|
-
for (const d of l._zod.deferred)
|
|
2667
|
-
d();
|
|
2668
|
-
return l;
|
|
2669
|
-
}
|
|
2670
|
-
return Object.defineProperty(i, "init", { value: s }), Object.defineProperty(i, Symbol.hasInstance, {
|
|
2671
|
-
value: (o) => t?.Parent && o instanceof t.Parent ? !0 : o?._zod?.traits?.has(r)
|
|
2672
|
-
}), Object.defineProperty(i, "name", { value: r }), i;
|
|
2673
|
-
}
|
|
2674
|
-
class or extends Error {
|
|
2675
|
-
constructor() {
|
|
2676
|
-
super("Encountered Promise during synchronous parse. Use .parseAsync() instead.");
|
|
2677
|
-
}
|
|
2678
|
-
}
|
|
2679
|
-
const ur = {};
|
|
2680
|
-
function yt(r) {
|
|
2681
|
-
return ur;
|
|
2682
|
-
}
|
|
2683
|
-
function cr(r) {
|
|
2684
|
-
const e = Object.values(r).filter((s) => typeof s == "number");
|
|
2685
|
-
return Object.entries(r).filter(([s, n]) => e.indexOf(+s) === -1).map(([s, n]) => n);
|
|
2686
|
-
}
|
|
2687
|
-
function lr(r, e) {
|
|
2688
|
-
return typeof e == "bigint" ? e.toString() : e;
|
|
2689
|
-
}
|
|
2690
|
-
function be(r) {
|
|
2691
|
-
return typeof r == "string" ? r : r?.message;
|
|
2692
|
-
}
|
|
2693
|
-
function gt(r, e, t) {
|
|
2694
|
-
const s = { ...r, path: r.path ?? [] };
|
|
2695
|
-
if (!r.message) {
|
|
2696
|
-
const n = be(r.inst?._zod.def?.error?.(r)) ?? be(e?.error?.(r)) ?? be(t.customError?.(r)) ?? be(t.localeError?.(r)) ?? "Invalid input";
|
|
2697
|
-
s.message = n;
|
|
2698
|
-
}
|
|
2699
|
-
return delete s.inst, delete s.continue, e?.reportInput || delete s.input, s;
|
|
2700
|
-
}
|
|
2701
|
-
const _t = (r, e) => {
|
|
2702
|
-
r.name = "$ZodError", Object.defineProperty(r, "_zod", {
|
|
2703
|
-
value: r._zod,
|
|
2704
|
-
enumerable: !1
|
|
2705
|
-
}), Object.defineProperty(r, "issues", {
|
|
2706
|
-
value: e,
|
|
2707
|
-
enumerable: !1
|
|
2708
|
-
}), r.message = JSON.stringify(e, lr, 2), Object.defineProperty(r, "toString", {
|
|
2709
|
-
value: () => r.message,
|
|
2710
|
-
enumerable: !1
|
|
2711
|
-
});
|
|
2712
|
-
}, bt = vt("$ZodError", _t), xt = vt("$ZodError", _t, { Parent: Error });
|
|
2713
|
-
function kt(r, e) {
|
|
2714
|
-
const t = function(a) {
|
|
2715
|
-
return a.message;
|
|
2716
|
-
}, s = { _errors: [] }, n = (a) => {
|
|
2717
|
-
for (const i of a.issues)
|
|
2718
|
-
if (i.code === "invalid_union" && i.errors.length)
|
|
2719
|
-
i.errors.map((o) => n({ issues: o }));
|
|
2720
|
-
else if (i.code === "invalid_key")
|
|
2721
|
-
n({ issues: i.issues });
|
|
2722
|
-
else if (i.code === "invalid_element")
|
|
2723
|
-
n({ issues: i.issues });
|
|
2724
|
-
else if (i.path.length === 0)
|
|
2725
|
-
s._errors.push(t(i));
|
|
2726
|
-
else {
|
|
2727
|
-
let o = s, u = 0;
|
|
2728
|
-
for (; u < i.path.length; ) {
|
|
2729
|
-
const l = i.path[u];
|
|
2730
|
-
u === i.path.length - 1 ? (o[l] = o[l] || { _errors: [] }, o[l]._errors.push(t(i))) : o[l] = o[l] || { _errors: [] }, o = o[l], u++;
|
|
2731
|
-
}
|
|
2732
|
-
}
|
|
2733
|
-
};
|
|
2734
|
-
return n(r), s;
|
|
2735
|
-
}
|
|
2736
|
-
const dr = (r) => (e, t, s) => {
|
|
2737
|
-
const n = s ? { ...s, async: !1 } : { async: !1 }, a = e._zod.run({ value: t, issues: [] }, n);
|
|
2738
|
-
if (a instanceof Promise)
|
|
2739
|
-
throw new or();
|
|
2740
|
-
return a.issues.length ? {
|
|
2741
|
-
success: !1,
|
|
2742
|
-
error: new (r ?? bt)(a.issues.map((i) => gt(i, n, yt())))
|
|
2743
|
-
} : { success: !0, data: a.value };
|
|
2744
|
-
}, fr = /* @__PURE__ */ dr(xt), hr = (r) => async (e, t, s) => {
|
|
2745
|
-
const n = s ? Object.assign(s, { async: !0 }) : { async: !0 };
|
|
2746
|
-
let a = e._zod.run({ value: t, issues: [] }, n);
|
|
2747
|
-
return a instanceof Promise && (a = await a), a.issues.length ? {
|
|
2748
|
-
success: !1,
|
|
2749
|
-
error: new r(a.issues.map((i) => gt(i, n, yt())))
|
|
2750
|
-
} : { success: !0, data: a.value };
|
|
2751
|
-
}, pr = /* @__PURE__ */ hr(xt);
|
|
2752
|
-
class wt {
|
|
2753
|
-
constructor() {
|
|
2754
|
-
this._map = /* @__PURE__ */ new Map(), this._idmap = /* @__PURE__ */ new Map();
|
|
2755
|
-
}
|
|
2756
|
-
add(e, ...t) {
|
|
2757
|
-
const s = t[0];
|
|
2758
|
-
if (this._map.set(e, s), s && typeof s == "object" && "id" in s) {
|
|
2759
|
-
if (this._idmap.has(s.id))
|
|
2760
|
-
throw new Error(`ID ${s.id} already exists in the registry`);
|
|
2761
|
-
this._idmap.set(s.id, e);
|
|
2762
|
-
}
|
|
2763
|
-
return this;
|
|
2764
|
-
}
|
|
2765
|
-
clear() {
|
|
2766
|
-
return this._map = /* @__PURE__ */ new Map(), this._idmap = /* @__PURE__ */ new Map(), this;
|
|
2767
|
-
}
|
|
2768
|
-
remove(e) {
|
|
2769
|
-
const t = this._map.get(e);
|
|
2770
|
-
return t && typeof t == "object" && "id" in t && this._idmap.delete(t.id), this._map.delete(e), this;
|
|
2771
|
-
}
|
|
2772
|
-
get(e) {
|
|
2773
|
-
const t = e._zod.parent;
|
|
2774
|
-
if (t) {
|
|
2775
|
-
const s = { ...this.get(t) ?? {} };
|
|
2776
|
-
delete s.id;
|
|
2777
|
-
const n = { ...s, ...this._map.get(e) };
|
|
2778
|
-
return Object.keys(n).length ? n : void 0;
|
|
2779
|
-
}
|
|
2780
|
-
return this._map.get(e);
|
|
2781
|
-
}
|
|
2782
|
-
has(e) {
|
|
2783
|
-
return this._map.has(e);
|
|
2784
|
-
}
|
|
2785
|
-
}
|
|
2786
|
-
function mr() {
|
|
2787
|
-
return new wt();
|
|
2788
|
-
}
|
|
2789
|
-
const vr = /* @__PURE__ */ mr();
|
|
2790
|
-
class lt {
|
|
2791
|
-
constructor(e) {
|
|
2792
|
-
this.counter = 0, this.metadataRegistry = e?.metadata ?? vr, this.target = e?.target ?? "draft-2020-12", this.unrepresentable = e?.unrepresentable ?? "throw", this.override = e?.override ?? (() => {
|
|
2793
|
-
}), this.io = e?.io ?? "output", this.seen = /* @__PURE__ */ new Map();
|
|
2794
|
-
}
|
|
2795
|
-
process(e, t = { path: [], schemaPath: [] }) {
|
|
2796
|
-
var s;
|
|
2797
|
-
const n = e._zod.def, a = {
|
|
2798
|
-
guid: "uuid",
|
|
2799
|
-
url: "uri",
|
|
2800
|
-
datetime: "date-time",
|
|
2801
|
-
json_string: "json-string",
|
|
2802
|
-
regex: ""
|
|
2803
|
-
// do not set
|
|
2804
|
-
}, i = this.seen.get(e);
|
|
2805
|
-
if (i)
|
|
2806
|
-
return i.count++, t.schemaPath.includes(e) && (i.cycle = t.path), i.schema;
|
|
2807
|
-
const o = { schema: {}, count: 1, cycle: void 0, path: t.path };
|
|
2808
|
-
this.seen.set(e, o);
|
|
2809
|
-
const u = e._zod.toJSONSchema?.();
|
|
2810
|
-
if (u)
|
|
2811
|
-
o.schema = u;
|
|
2812
|
-
else {
|
|
2813
|
-
const f = {
|
|
2814
|
-
...t,
|
|
2815
|
-
schemaPath: [...t.schemaPath, e],
|
|
2816
|
-
path: t.path
|
|
2817
|
-
}, k = e._zod.parent;
|
|
2818
|
-
if (k)
|
|
2819
|
-
o.ref = k, this.process(k, f), this.seen.get(k).isParent = !0;
|
|
2820
|
-
else {
|
|
2821
|
-
const b = o.schema;
|
|
2822
|
-
switch (n.type) {
|
|
2823
|
-
case "string": {
|
|
2824
|
-
const c = b;
|
|
2825
|
-
c.type = "string";
|
|
2826
|
-
const { minimum: h, maximum: m, format: x, patterns: j, contentEncoding: N } = e._zod.bag;
|
|
2827
|
-
if (typeof h == "number" && (c.minLength = h), typeof m == "number" && (c.maxLength = m), x && (c.format = a[x] ?? x, c.format === "" && delete c.format), N && (c.contentEncoding = N), j && j.size > 0) {
|
|
2828
|
-
const P = [...j];
|
|
2829
|
-
P.length === 1 ? c.pattern = P[0].source : P.length > 1 && (o.schema.allOf = [
|
|
2830
|
-
...P.map((E) => ({
|
|
2831
|
-
...this.target === "draft-7" ? { type: "string" } : {},
|
|
2832
|
-
pattern: E.source
|
|
2833
|
-
}))
|
|
2834
|
-
]);
|
|
2835
|
-
}
|
|
2836
|
-
break;
|
|
2837
|
-
}
|
|
2838
|
-
case "number": {
|
|
2839
|
-
const c = b, { minimum: h, maximum: m, format: x, multipleOf: j, exclusiveMaximum: N, exclusiveMinimum: P } = e._zod.bag;
|
|
2840
|
-
typeof x == "string" && x.includes("int") ? c.type = "integer" : c.type = "number", typeof P == "number" && (c.exclusiveMinimum = P), typeof h == "number" && (c.minimum = h, typeof P == "number" && (P >= h ? delete c.minimum : delete c.exclusiveMinimum)), typeof N == "number" && (c.exclusiveMaximum = N), typeof m == "number" && (c.maximum = m, typeof N == "number" && (N <= m ? delete c.maximum : delete c.exclusiveMaximum)), typeof j == "number" && (c.multipleOf = j);
|
|
2841
|
-
break;
|
|
2842
|
-
}
|
|
2843
|
-
case "boolean": {
|
|
2844
|
-
const c = b;
|
|
2845
|
-
c.type = "boolean";
|
|
2846
|
-
break;
|
|
2847
|
-
}
|
|
2848
|
-
case "bigint": {
|
|
2849
|
-
if (this.unrepresentable === "throw")
|
|
2850
|
-
throw new Error("BigInt cannot be represented in JSON Schema");
|
|
2851
|
-
break;
|
|
2852
|
-
}
|
|
2853
|
-
case "symbol": {
|
|
2854
|
-
if (this.unrepresentable === "throw")
|
|
2855
|
-
throw new Error("Symbols cannot be represented in JSON Schema");
|
|
2856
|
-
break;
|
|
2857
|
-
}
|
|
2858
|
-
case "null": {
|
|
2859
|
-
b.type = "null";
|
|
2860
|
-
break;
|
|
2861
|
-
}
|
|
2862
|
-
case "any":
|
|
2863
|
-
break;
|
|
2864
|
-
case "unknown":
|
|
2865
|
-
break;
|
|
2866
|
-
case "undefined": {
|
|
2867
|
-
if (this.unrepresentable === "throw")
|
|
2868
|
-
throw new Error("Undefined cannot be represented in JSON Schema");
|
|
2869
|
-
break;
|
|
2870
|
-
}
|
|
2871
|
-
case "void": {
|
|
2872
|
-
if (this.unrepresentable === "throw")
|
|
2873
|
-
throw new Error("Void cannot be represented in JSON Schema");
|
|
2874
|
-
break;
|
|
2875
|
-
}
|
|
2876
|
-
case "never": {
|
|
2877
|
-
b.not = {};
|
|
2878
|
-
break;
|
|
2879
|
-
}
|
|
2880
|
-
case "date": {
|
|
2881
|
-
if (this.unrepresentable === "throw")
|
|
2882
|
-
throw new Error("Date cannot be represented in JSON Schema");
|
|
2883
|
-
break;
|
|
2884
|
-
}
|
|
2885
|
-
case "array": {
|
|
2886
|
-
const c = b, { minimum: h, maximum: m } = e._zod.bag;
|
|
2887
|
-
typeof h == "number" && (c.minItems = h), typeof m == "number" && (c.maxItems = m), c.type = "array", c.items = this.process(n.element, { ...f, path: [...f.path, "items"] });
|
|
2888
|
-
break;
|
|
2889
|
-
}
|
|
2890
|
-
case "object": {
|
|
2891
|
-
const c = b;
|
|
2892
|
-
c.type = "object", c.properties = {};
|
|
2893
|
-
const h = n.shape;
|
|
2894
|
-
for (const j in h)
|
|
2895
|
-
c.properties[j] = this.process(h[j], {
|
|
2896
|
-
...f,
|
|
2897
|
-
path: [...f.path, "properties", j]
|
|
2898
|
-
});
|
|
2899
|
-
const m = new Set(Object.keys(h)), x = new Set([...m].filter((j) => {
|
|
2900
|
-
const N = n.shape[j]._zod;
|
|
2901
|
-
return this.io === "input" ? N.optin === void 0 : N.optout === void 0;
|
|
2902
|
-
}));
|
|
2903
|
-
x.size > 0 && (c.required = Array.from(x)), n.catchall?._zod.def.type === "never" ? c.additionalProperties = !1 : n.catchall ? n.catchall && (c.additionalProperties = this.process(n.catchall, {
|
|
2904
|
-
...f,
|
|
2905
|
-
path: [...f.path, "additionalProperties"]
|
|
2906
|
-
})) : this.io === "output" && (c.additionalProperties = !1);
|
|
2907
|
-
break;
|
|
2908
|
-
}
|
|
2909
|
-
case "union": {
|
|
2910
|
-
const c = b;
|
|
2911
|
-
c.anyOf = n.options.map((h, m) => this.process(h, {
|
|
2912
|
-
...f,
|
|
2913
|
-
path: [...f.path, "anyOf", m]
|
|
2914
|
-
}));
|
|
2915
|
-
break;
|
|
2916
|
-
}
|
|
2917
|
-
case "intersection": {
|
|
2918
|
-
const c = b, h = this.process(n.left, {
|
|
2919
|
-
...f,
|
|
2920
|
-
path: [...f.path, "allOf", 0]
|
|
2921
|
-
}), m = this.process(n.right, {
|
|
2922
|
-
...f,
|
|
2923
|
-
path: [...f.path, "allOf", 1]
|
|
2924
|
-
}), x = (N) => "allOf" in N && Object.keys(N).length === 1, j = [
|
|
2925
|
-
...x(h) ? h.allOf : [h],
|
|
2926
|
-
...x(m) ? m.allOf : [m]
|
|
2927
|
-
];
|
|
2928
|
-
c.allOf = j;
|
|
2929
|
-
break;
|
|
2930
|
-
}
|
|
2931
|
-
case "tuple": {
|
|
2932
|
-
const c = b;
|
|
2933
|
-
c.type = "array";
|
|
2934
|
-
const h = n.items.map((j, N) => this.process(j, { ...f, path: [...f.path, "prefixItems", N] }));
|
|
2935
|
-
if (this.target === "draft-2020-12" ? c.prefixItems = h : c.items = h, n.rest) {
|
|
2936
|
-
const j = this.process(n.rest, {
|
|
2937
|
-
...f,
|
|
2938
|
-
path: [...f.path, "items"]
|
|
2939
|
-
});
|
|
2940
|
-
this.target === "draft-2020-12" ? c.items = j : c.additionalItems = j;
|
|
2941
|
-
}
|
|
2942
|
-
n.rest && (c.items = this.process(n.rest, {
|
|
2943
|
-
...f,
|
|
2944
|
-
path: [...f.path, "items"]
|
|
2945
|
-
}));
|
|
2946
|
-
const { minimum: m, maximum: x } = e._zod.bag;
|
|
2947
|
-
typeof m == "number" && (c.minItems = m), typeof x == "number" && (c.maxItems = x);
|
|
2948
|
-
break;
|
|
2949
|
-
}
|
|
2950
|
-
case "record": {
|
|
2951
|
-
const c = b;
|
|
2952
|
-
c.type = "object", c.propertyNames = this.process(n.keyType, { ...f, path: [...f.path, "propertyNames"] }), c.additionalProperties = this.process(n.valueType, {
|
|
2953
|
-
...f,
|
|
2954
|
-
path: [...f.path, "additionalProperties"]
|
|
2955
|
-
});
|
|
2956
|
-
break;
|
|
2957
|
-
}
|
|
2958
|
-
case "map": {
|
|
2959
|
-
if (this.unrepresentable === "throw")
|
|
2960
|
-
throw new Error("Map cannot be represented in JSON Schema");
|
|
2961
|
-
break;
|
|
2962
|
-
}
|
|
2963
|
-
case "set": {
|
|
2964
|
-
if (this.unrepresentable === "throw")
|
|
2965
|
-
throw new Error("Set cannot be represented in JSON Schema");
|
|
2966
|
-
break;
|
|
2967
|
-
}
|
|
2968
|
-
case "enum": {
|
|
2969
|
-
const c = b, h = cr(n.entries);
|
|
2970
|
-
h.every((m) => typeof m == "number") && (c.type = "number"), h.every((m) => typeof m == "string") && (c.type = "string"), c.enum = h;
|
|
2971
|
-
break;
|
|
2972
|
-
}
|
|
2973
|
-
case "literal": {
|
|
2974
|
-
const c = b, h = [];
|
|
2975
|
-
for (const m of n.values)
|
|
2976
|
-
if (m === void 0) {
|
|
2977
|
-
if (this.unrepresentable === "throw")
|
|
2978
|
-
throw new Error("Literal `undefined` cannot be represented in JSON Schema");
|
|
2979
|
-
} else if (typeof m == "bigint") {
|
|
2980
|
-
if (this.unrepresentable === "throw")
|
|
2981
|
-
throw new Error("BigInt literals cannot be represented in JSON Schema");
|
|
2982
|
-
h.push(Number(m));
|
|
2983
|
-
} else
|
|
2984
|
-
h.push(m);
|
|
2985
|
-
if (h.length !== 0) if (h.length === 1) {
|
|
2986
|
-
const m = h[0];
|
|
2987
|
-
c.type = m === null ? "null" : typeof m, c.const = m;
|
|
2988
|
-
} else
|
|
2989
|
-
h.every((m) => typeof m == "number") && (c.type = "number"), h.every((m) => typeof m == "string") && (c.type = "string"), h.every((m) => typeof m == "boolean") && (c.type = "string"), h.every((m) => m === null) && (c.type = "null"), c.enum = h;
|
|
2990
|
-
break;
|
|
2991
|
-
}
|
|
2992
|
-
case "file": {
|
|
2993
|
-
const c = b, h = {
|
|
2994
|
-
type: "string",
|
|
2995
|
-
format: "binary",
|
|
2996
|
-
contentEncoding: "binary"
|
|
2997
|
-
}, { minimum: m, maximum: x, mime: j } = e._zod.bag;
|
|
2998
|
-
m !== void 0 && (h.minLength = m), x !== void 0 && (h.maxLength = x), j ? j.length === 1 ? (h.contentMediaType = j[0], Object.assign(c, h)) : c.anyOf = j.map((N) => ({ ...h, contentMediaType: N })) : Object.assign(c, h);
|
|
2999
|
-
break;
|
|
3000
|
-
}
|
|
3001
|
-
case "transform": {
|
|
3002
|
-
if (this.unrepresentable === "throw")
|
|
3003
|
-
throw new Error("Transforms cannot be represented in JSON Schema");
|
|
3004
|
-
break;
|
|
3005
|
-
}
|
|
3006
|
-
case "nullable": {
|
|
3007
|
-
const c = this.process(n.innerType, f);
|
|
3008
|
-
b.anyOf = [c, { type: "null" }];
|
|
3009
|
-
break;
|
|
3010
|
-
}
|
|
3011
|
-
case "nonoptional": {
|
|
3012
|
-
this.process(n.innerType, f), o.ref = n.innerType;
|
|
3013
|
-
break;
|
|
3014
|
-
}
|
|
3015
|
-
case "success": {
|
|
3016
|
-
const c = b;
|
|
3017
|
-
c.type = "boolean";
|
|
3018
|
-
break;
|
|
3019
|
-
}
|
|
3020
|
-
case "default": {
|
|
3021
|
-
this.process(n.innerType, f), o.ref = n.innerType, b.default = JSON.parse(JSON.stringify(n.defaultValue));
|
|
3022
|
-
break;
|
|
3023
|
-
}
|
|
3024
|
-
case "prefault": {
|
|
3025
|
-
this.process(n.innerType, f), o.ref = n.innerType, this.io === "input" && (b._prefault = JSON.parse(JSON.stringify(n.defaultValue)));
|
|
3026
|
-
break;
|
|
3027
|
-
}
|
|
3028
|
-
case "catch": {
|
|
3029
|
-
this.process(n.innerType, f), o.ref = n.innerType;
|
|
3030
|
-
let c;
|
|
3031
|
-
try {
|
|
3032
|
-
c = n.catchValue(void 0);
|
|
3033
|
-
} catch {
|
|
3034
|
-
throw new Error("Dynamic catch values are not supported in JSON Schema");
|
|
3035
|
-
}
|
|
3036
|
-
b.default = c;
|
|
3037
|
-
break;
|
|
3038
|
-
}
|
|
3039
|
-
case "nan": {
|
|
3040
|
-
if (this.unrepresentable === "throw")
|
|
3041
|
-
throw new Error("NaN cannot be represented in JSON Schema");
|
|
3042
|
-
break;
|
|
3043
|
-
}
|
|
3044
|
-
case "template_literal": {
|
|
3045
|
-
const c = b, h = e._zod.pattern;
|
|
3046
|
-
if (!h)
|
|
3047
|
-
throw new Error("Pattern not found in template literal");
|
|
3048
|
-
c.type = "string", c.pattern = h.source;
|
|
3049
|
-
break;
|
|
3050
|
-
}
|
|
3051
|
-
case "pipe": {
|
|
3052
|
-
const c = this.io === "input" ? n.in._zod.def.type === "transform" ? n.out : n.in : n.out;
|
|
3053
|
-
this.process(c, f), o.ref = c;
|
|
3054
|
-
break;
|
|
3055
|
-
}
|
|
3056
|
-
case "readonly": {
|
|
3057
|
-
this.process(n.innerType, f), o.ref = n.innerType, b.readOnly = !0;
|
|
3058
|
-
break;
|
|
3059
|
-
}
|
|
3060
|
-
// passthrough types
|
|
3061
|
-
case "promise": {
|
|
3062
|
-
this.process(n.innerType, f), o.ref = n.innerType;
|
|
3063
|
-
break;
|
|
3064
|
-
}
|
|
3065
|
-
case "optional": {
|
|
3066
|
-
this.process(n.innerType, f), o.ref = n.innerType;
|
|
3067
|
-
break;
|
|
3068
|
-
}
|
|
3069
|
-
case "lazy": {
|
|
3070
|
-
const c = e._zod.innerType;
|
|
3071
|
-
this.process(c, f), o.ref = c;
|
|
3072
|
-
break;
|
|
3073
|
-
}
|
|
3074
|
-
case "custom": {
|
|
3075
|
-
if (this.unrepresentable === "throw")
|
|
3076
|
-
throw new Error("Custom types cannot be represented in JSON Schema");
|
|
3077
|
-
break;
|
|
3078
|
-
}
|
|
3079
|
-
}
|
|
3080
|
-
}
|
|
3081
|
-
}
|
|
3082
|
-
const l = this.metadataRegistry.get(e);
|
|
3083
|
-
return l && Object.assign(o.schema, l), this.io === "input" && z(e) && (delete o.schema.examples, delete o.schema.default), this.io === "input" && o.schema._prefault && ((s = o.schema).default ?? (s.default = o.schema._prefault)), delete o.schema._prefault, this.seen.get(e).schema;
|
|
3084
|
-
}
|
|
3085
|
-
emit(e, t) {
|
|
3086
|
-
const s = {
|
|
3087
|
-
cycles: t?.cycles ?? "ref",
|
|
3088
|
-
reused: t?.reused ?? "inline",
|
|
3089
|
-
// unrepresentable: _params?.unrepresentable ?? "throw",
|
|
3090
|
-
// uri: _params?.uri ?? ((id) => `${id}`),
|
|
3091
|
-
external: t?.external ?? void 0
|
|
3092
|
-
}, n = this.seen.get(e);
|
|
3093
|
-
if (!n)
|
|
3094
|
-
throw new Error("Unprocessed schema. This is a bug in Zod.");
|
|
3095
|
-
const a = (d) => {
|
|
3096
|
-
const f = this.target === "draft-2020-12" ? "$defs" : "definitions";
|
|
3097
|
-
if (s.external) {
|
|
3098
|
-
const h = s.external.registry.get(d[0])?.id, m = s.external.uri ?? ((j) => j);
|
|
3099
|
-
if (h)
|
|
3100
|
-
return { ref: m(h) };
|
|
3101
|
-
const x = d[1].defId ?? d[1].schema.id ?? `schema${this.counter++}`;
|
|
3102
|
-
return d[1].defId = x, { defId: x, ref: `${m("__shared")}#/${f}/${x}` };
|
|
3103
|
-
}
|
|
3104
|
-
if (d[1] === n)
|
|
3105
|
-
return { ref: "#" };
|
|
3106
|
-
const b = `#/${f}/`, c = d[1].schema.id ?? `__schema${this.counter++}`;
|
|
3107
|
-
return { defId: c, ref: b + c };
|
|
3108
|
-
}, i = (d) => {
|
|
3109
|
-
if (d[1].schema.$ref)
|
|
3110
|
-
return;
|
|
3111
|
-
const f = d[1], { ref: k, defId: b } = a(d);
|
|
3112
|
-
f.def = { ...f.schema }, b && (f.defId = b);
|
|
3113
|
-
const c = f.schema;
|
|
3114
|
-
for (const h in c)
|
|
3115
|
-
delete c[h];
|
|
3116
|
-
c.$ref = k;
|
|
3117
|
-
};
|
|
3118
|
-
if (s.cycles === "throw")
|
|
3119
|
-
for (const d of this.seen.entries()) {
|
|
3120
|
-
const f = d[1];
|
|
3121
|
-
if (f.cycle)
|
|
3122
|
-
throw new Error(`Cycle detected: #/${f.cycle?.join("/")}/<root>
|
|
3123
|
-
|
|
3124
|
-
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`);
|
|
3125
|
-
}
|
|
3126
|
-
for (const d of this.seen.entries()) {
|
|
3127
|
-
const f = d[1];
|
|
3128
|
-
if (e === d[0]) {
|
|
3129
|
-
i(d);
|
|
3130
|
-
continue;
|
|
3131
|
-
}
|
|
3132
|
-
if (s.external) {
|
|
3133
|
-
const b = s.external.registry.get(d[0])?.id;
|
|
3134
|
-
if (e !== d[0] && b) {
|
|
3135
|
-
i(d);
|
|
3136
|
-
continue;
|
|
3137
|
-
}
|
|
3138
|
-
}
|
|
3139
|
-
if (this.metadataRegistry.get(d[0])?.id) {
|
|
3140
|
-
i(d);
|
|
3141
|
-
continue;
|
|
3142
|
-
}
|
|
3143
|
-
if (f.cycle) {
|
|
3144
|
-
i(d);
|
|
3145
|
-
continue;
|
|
3146
|
-
}
|
|
3147
|
-
if (f.count > 1 && s.reused === "ref") {
|
|
3148
|
-
i(d);
|
|
3149
|
-
continue;
|
|
3150
|
-
}
|
|
3151
|
-
}
|
|
3152
|
-
const o = (d, f) => {
|
|
3153
|
-
const k = this.seen.get(d), b = k.def ?? k.schema, c = { ...b };
|
|
3154
|
-
if (k.ref === null)
|
|
3155
|
-
return;
|
|
3156
|
-
const h = k.ref;
|
|
3157
|
-
if (k.ref = null, h) {
|
|
3158
|
-
o(h, f);
|
|
3159
|
-
const m = this.seen.get(h).schema;
|
|
3160
|
-
m.$ref && f.target === "draft-7" ? (b.allOf = b.allOf ?? [], b.allOf.push(m)) : (Object.assign(b, m), Object.assign(b, c));
|
|
3161
|
-
}
|
|
3162
|
-
k.isParent || this.override({
|
|
3163
|
-
zodSchema: d,
|
|
3164
|
-
jsonSchema: b,
|
|
3165
|
-
path: k.path ?? []
|
|
3166
|
-
});
|
|
3167
|
-
};
|
|
3168
|
-
for (const d of [...this.seen.entries()].reverse())
|
|
3169
|
-
o(d[0], { target: this.target });
|
|
3170
|
-
const u = {};
|
|
3171
|
-
if (this.target === "draft-2020-12" ? u.$schema = "https://json-schema.org/draft/2020-12/schema" : this.target === "draft-7" ? u.$schema = "http://json-schema.org/draft-07/schema#" : console.warn(`Invalid target: ${this.target}`), s.external?.uri) {
|
|
3172
|
-
const d = s.external.registry.get(e)?.id;
|
|
3173
|
-
if (!d)
|
|
3174
|
-
throw new Error("Schema is missing an `id` property");
|
|
3175
|
-
u.$id = s.external.uri(d);
|
|
3176
|
-
}
|
|
3177
|
-
Object.assign(u, n.def);
|
|
3178
|
-
const l = s.external?.defs ?? {};
|
|
3179
|
-
for (const d of this.seen.entries()) {
|
|
3180
|
-
const f = d[1];
|
|
3181
|
-
f.def && f.defId && (l[f.defId] = f.def);
|
|
3182
|
-
}
|
|
3183
|
-
s.external || Object.keys(l).length > 0 && (this.target === "draft-2020-12" ? u.$defs = l : u.definitions = l);
|
|
3184
|
-
try {
|
|
3185
|
-
return JSON.parse(JSON.stringify(u));
|
|
3186
|
-
} catch {
|
|
3187
|
-
throw new Error("Error converting schema to JSON.");
|
|
3188
|
-
}
|
|
3189
|
-
}
|
|
3190
|
-
}
|
|
3191
|
-
function yr(r, e) {
|
|
3192
|
-
if (r instanceof wt) {
|
|
3193
|
-
const s = new lt(e), n = {};
|
|
3194
|
-
for (const o of r._idmap.entries()) {
|
|
3195
|
-
const [u, l] = o;
|
|
3196
|
-
s.process(l);
|
|
3197
|
-
}
|
|
3198
|
-
const a = {}, i = {
|
|
3199
|
-
registry: r,
|
|
3200
|
-
uri: e?.uri,
|
|
3201
|
-
defs: n
|
|
3202
|
-
};
|
|
3203
|
-
for (const o of r._idmap.entries()) {
|
|
3204
|
-
const [u, l] = o;
|
|
3205
|
-
a[u] = s.emit(l, {
|
|
3206
|
-
...e,
|
|
3207
|
-
external: i
|
|
3208
|
-
});
|
|
3209
|
-
}
|
|
3210
|
-
if (Object.keys(n).length > 0) {
|
|
3211
|
-
const o = s.target === "draft-2020-12" ? "$defs" : "definitions";
|
|
3212
|
-
a.__shared = {
|
|
3213
|
-
[o]: n
|
|
3214
|
-
};
|
|
3215
|
-
}
|
|
3216
|
-
return { schemas: a };
|
|
3217
|
-
}
|
|
3218
|
-
const t = new lt(e);
|
|
3219
|
-
return t.process(r), t.emit(r, e);
|
|
3220
|
-
}
|
|
3221
|
-
function z(r, e) {
|
|
3222
|
-
const t = e ?? { seen: /* @__PURE__ */ new Set() };
|
|
3223
|
-
if (t.seen.has(r))
|
|
3224
|
-
return !1;
|
|
3225
|
-
t.seen.add(r);
|
|
3226
|
-
const n = r._zod.def;
|
|
3227
|
-
switch (n.type) {
|
|
3228
|
-
case "string":
|
|
3229
|
-
case "number":
|
|
3230
|
-
case "bigint":
|
|
3231
|
-
case "boolean":
|
|
3232
|
-
case "date":
|
|
3233
|
-
case "symbol":
|
|
3234
|
-
case "undefined":
|
|
3235
|
-
case "null":
|
|
3236
|
-
case "any":
|
|
3237
|
-
case "unknown":
|
|
3238
|
-
case "never":
|
|
3239
|
-
case "void":
|
|
3240
|
-
case "literal":
|
|
3241
|
-
case "enum":
|
|
3242
|
-
case "nan":
|
|
3243
|
-
case "file":
|
|
3244
|
-
case "template_literal":
|
|
3245
|
-
return !1;
|
|
3246
|
-
case "array":
|
|
3247
|
-
return z(n.element, t);
|
|
3248
|
-
case "object": {
|
|
3249
|
-
for (const a in n.shape)
|
|
3250
|
-
if (z(n.shape[a], t))
|
|
3251
|
-
return !0;
|
|
3252
|
-
return !1;
|
|
3253
|
-
}
|
|
3254
|
-
case "union": {
|
|
3255
|
-
for (const a of n.options)
|
|
3256
|
-
if (z(a, t))
|
|
3257
|
-
return !0;
|
|
3258
|
-
return !1;
|
|
3259
|
-
}
|
|
3260
|
-
case "intersection":
|
|
3261
|
-
return z(n.left, t) || z(n.right, t);
|
|
3262
|
-
case "tuple": {
|
|
3263
|
-
for (const a of n.items)
|
|
3264
|
-
if (z(a, t))
|
|
3265
|
-
return !0;
|
|
3266
|
-
return !!(n.rest && z(n.rest, t));
|
|
3267
|
-
}
|
|
3268
|
-
case "record":
|
|
3269
|
-
return z(n.keyType, t) || z(n.valueType, t);
|
|
3270
|
-
case "map":
|
|
3271
|
-
return z(n.keyType, t) || z(n.valueType, t);
|
|
3272
|
-
case "set":
|
|
3273
|
-
return z(n.valueType, t);
|
|
3274
|
-
// inner types
|
|
3275
|
-
case "promise":
|
|
3276
|
-
case "optional":
|
|
3277
|
-
case "nonoptional":
|
|
3278
|
-
case "nullable":
|
|
3279
|
-
case "readonly":
|
|
3280
|
-
return z(n.innerType, t);
|
|
3281
|
-
case "lazy":
|
|
3282
|
-
return z(n.getter(), t);
|
|
3283
|
-
case "default":
|
|
3284
|
-
return z(n.innerType, t);
|
|
3285
|
-
case "prefault":
|
|
3286
|
-
return z(n.innerType, t);
|
|
3287
|
-
case "custom":
|
|
3288
|
-
return !1;
|
|
3289
|
-
case "transform":
|
|
3290
|
-
return !0;
|
|
3291
|
-
case "pipe":
|
|
3292
|
-
return z(n.in, t) || z(n.out, t);
|
|
3293
|
-
case "success":
|
|
3294
|
-
return !1;
|
|
3295
|
-
case "catch":
|
|
3296
|
-
return !1;
|
|
3297
|
-
}
|
|
3298
|
-
throw new Error(`Unknown schema type: ${n.type}`);
|
|
3299
|
-
}
|
|
3300
|
-
const xe = (r) => {
|
|
3301
|
-
let e = r;
|
|
3302
|
-
for (; e instanceof se; )
|
|
3303
|
-
e = e.innerType();
|
|
3304
|
-
return e instanceof G && (e = e._def.innerType), e;
|
|
3305
|
-
}, gr = (r) => {
|
|
3306
|
-
let e = r;
|
|
3307
|
-
for (; e instanceof se; )
|
|
3308
|
-
e = e.innerType();
|
|
3309
|
-
return e instanceof G || e instanceof ae;
|
|
1
|
+
import { ref as _, computed as D, readonly as N, defineComponent as C, h as E, withModifiers as te, toRaw as G, watch as k, isProxy as de, onMounted as q, provide as H, toRefs as X, useId as re, inject as B, onBeforeUnmount as U, unref as P, resolveComponent as Z, defineAsyncComponent as fe, getCurrentInstance as ve } from "vue";
|
|
2
|
+
import { watchIgnorable as ce, throttleFilter as me } from "@vueuse/core";
|
|
3
|
+
import { ZodError as pe } from "zod/v3";
|
|
4
|
+
import { safeParse as ye, safeParseAsync as be, formatError as ae, $ZodError as he } from "zod/v4/core";
|
|
5
|
+
import { toJSONSchema as je } from "zod/v4";
|
|
6
|
+
import { set as ne, get as L } from "ts-dot-prop";
|
|
7
|
+
var V = /* @__PURE__ */ ((e) => (e.text = "text", e.number = "number", e.email = "email", e.password = "password", e.tel = "tel", e.url = "url", e.search = "search", e.date = "date", e.time = "time", e.datetimeLocal = "datetime-local", e.month = "month", e.week = "week", e.color = "color", e.select = "select", e.checkbox = "checkbox", e.radio = "radio", e.textarea = "textarea", e.radioGroup = "radioGroup", e.checkboxGroup = "checkboxGroup", e.combobox = "combobox", e.custom = "custom", e))(V || {}), R = /* @__PURE__ */ ((e) => (e.invalid = "invalid", e.valid = "valid", e.submitting = "submitting", e.reset = "reset", e.updated = "updated", e.unknown = "unknown", e))(R || {});
|
|
8
|
+
const K = (e) => e._def.typeName === "ZodObject", Ve = (e) => e._def.typeName === "ZodDefault", Oe = (e) => e._def.typeName === "ZodNullable", we = (e) => e._def.typeName === "ZodRecord", De = (e) => e._def.typeName === "ZodArray", oe = (e) => e._def.typeName === "ZodEffects", ue = (e) => e._def.typeName === "ZodOptional", z = (e) => {
|
|
9
|
+
let t = e;
|
|
10
|
+
for (; oe(t); )
|
|
11
|
+
t = t.innerType();
|
|
12
|
+
return ue(t) && (t = t._def.innerType), t;
|
|
13
|
+
}, ge = (e) => {
|
|
14
|
+
let t = e;
|
|
15
|
+
for (; oe(t); )
|
|
16
|
+
t = t.innerType();
|
|
17
|
+
return !!ue(t);
|
|
3310
18
|
};
|
|
3311
|
-
function
|
|
3312
|
-
return Array.isArray(
|
|
3313
|
-
}
|
|
3314
|
-
function
|
|
3315
|
-
const
|
|
3316
|
-
return
|
|
3317
|
-
}
|
|
3318
|
-
function
|
|
3319
|
-
if (
|
|
3320
|
-
if (
|
|
3321
|
-
for (const
|
|
3322
|
-
if (
|
|
3323
|
-
return
|
|
3324
|
-
for (const
|
|
3325
|
-
const
|
|
3326
|
-
if (!
|
|
3327
|
-
return
|
|
19
|
+
function Se(e) {
|
|
20
|
+
return Array.isArray(e) ? "array" : e === null ? "null" : typeof e;
|
|
21
|
+
}
|
|
22
|
+
function Ie(e, t) {
|
|
23
|
+
const n = Se(e);
|
|
24
|
+
return t.type ? t.type === n || t.type === "integer" && n === "number" && Number.isInteger(e) : !0;
|
|
25
|
+
}
|
|
26
|
+
function W(e, t) {
|
|
27
|
+
if (e.anyOf && Array.isArray(e.anyOf)) {
|
|
28
|
+
if (t !== void 0) {
|
|
29
|
+
for (const o of e.anyOf)
|
|
30
|
+
if (Ie(t, o))
|
|
31
|
+
return W(o, t);
|
|
32
|
+
for (const o of e.anyOf) {
|
|
33
|
+
const i = o;
|
|
34
|
+
if (!i.type || i.type === "object")
|
|
35
|
+
return W(i, t);
|
|
3328
36
|
}
|
|
3329
37
|
}
|
|
3330
|
-
return
|
|
38
|
+
return W(e.anyOf[0], t);
|
|
3331
39
|
}
|
|
3332
|
-
if (
|
|
3333
|
-
switch (
|
|
40
|
+
if (e.type !== "object" || !e.properties)
|
|
41
|
+
switch (e.type) {
|
|
3334
42
|
case "string":
|
|
3335
|
-
return typeof
|
|
43
|
+
return typeof t == "string" ? t : e.default;
|
|
3336
44
|
case "number":
|
|
3337
45
|
case "integer":
|
|
3338
|
-
return typeof
|
|
46
|
+
return typeof t == "number" ? t : e.default;
|
|
3339
47
|
case "boolean":
|
|
3340
|
-
return typeof
|
|
48
|
+
return typeof t == "boolean" ? t : e.default;
|
|
3341
49
|
case "null":
|
|
3342
|
-
return
|
|
50
|
+
return t === null ? t : e.default;
|
|
3343
51
|
case "array":
|
|
3344
|
-
return Array.isArray(
|
|
52
|
+
return Array.isArray(t) && e.items ? t.map((o) => W(e.items, o)) : e.default;
|
|
3345
53
|
default:
|
|
3346
|
-
return
|
|
54
|
+
return e.default;
|
|
3347
55
|
}
|
|
3348
|
-
const
|
|
3349
|
-
for (const
|
|
3350
|
-
const
|
|
3351
|
-
|
|
3352
|
-
}
|
|
3353
|
-
if (
|
|
3354
|
-
const
|
|
3355
|
-
for (const [
|
|
3356
|
-
|
|
3357
|
-
}
|
|
3358
|
-
return
|
|
3359
|
-
}
|
|
3360
|
-
const
|
|
3361
|
-
function
|
|
3362
|
-
if (
|
|
3363
|
-
const
|
|
3364
|
-
if (
|
|
3365
|
-
return
|
|
3366
|
-
const
|
|
3367
|
-
return
|
|
3368
|
-
}
|
|
3369
|
-
const
|
|
3370
|
-
return
|
|
3371
|
-
...
|
|
56
|
+
const n = e.properties, r = t && typeof t == "object" && !Array.isArray(t) ? t : void 0, u = {};
|
|
57
|
+
for (const o in n) {
|
|
58
|
+
const i = r?.[o];
|
|
59
|
+
u[o] = W(n[o], i);
|
|
60
|
+
}
|
|
61
|
+
if (r && e.additionalProperties !== !1) {
|
|
62
|
+
const o = new Set(Object.keys(n));
|
|
63
|
+
for (const [i, l] of Object.entries(r))
|
|
64
|
+
o.has(i) || (u[i] = l);
|
|
65
|
+
}
|
|
66
|
+
return u;
|
|
67
|
+
}
|
|
68
|
+
const Q = (e) => "_zod" in e;
|
|
69
|
+
function J(e, t = {}) {
|
|
70
|
+
if (Q(e)) {
|
|
71
|
+
const r = je(e);
|
|
72
|
+
if (r.type !== "object" || !r.properties)
|
|
73
|
+
return t;
|
|
74
|
+
const u = ye(e, t);
|
|
75
|
+
return W(r, u.success ? u.data : t);
|
|
76
|
+
}
|
|
77
|
+
const n = z(e);
|
|
78
|
+
return K(n) ? {
|
|
79
|
+
...n._def.unknownKeys === "passthrough" ? t : {},
|
|
3372
80
|
...Object.fromEntries(
|
|
3373
|
-
("shape" in
|
|
3374
|
-
([
|
|
3375
|
-
const
|
|
3376
|
-
let
|
|
3377
|
-
if (
|
|
3378
|
-
return [
|
|
3379
|
-
if (
|
|
3380
|
-
return [
|
|
3381
|
-
if (
|
|
3382
|
-
const d =
|
|
81
|
+
("shape" in n ? Object.entries(n.shape) : []).map(
|
|
82
|
+
([r, u]) => {
|
|
83
|
+
const o = t[r], i = ge(u);
|
|
84
|
+
let l = z(u), f;
|
|
85
|
+
if (Ve(l) && (f = l._def.defaultValue(), l = l._def.innerType), o === null && Oe(l))
|
|
86
|
+
return [r, o];
|
|
87
|
+
if (o == null && i)
|
|
88
|
+
return [r, f];
|
|
89
|
+
if (l) {
|
|
90
|
+
const d = u.safeParse(o);
|
|
3383
91
|
if (d.success)
|
|
3384
|
-
return [
|
|
92
|
+
return [r, d.data ?? f];
|
|
3385
93
|
}
|
|
3386
|
-
if (
|
|
3387
|
-
const d =
|
|
3388
|
-
if (d
|
|
94
|
+
if (De(l) && Array.isArray(o) && o.length) {
|
|
95
|
+
const d = z(l._def.type);
|
|
96
|
+
if (K(d))
|
|
3389
97
|
return [
|
|
3390
|
-
|
|
3391
|
-
|
|
3392
|
-
(
|
|
98
|
+
r,
|
|
99
|
+
o.map(
|
|
100
|
+
(c) => J(
|
|
3393
101
|
d,
|
|
3394
|
-
|
|
102
|
+
c && typeof c == "object" ? c : void 0
|
|
3395
103
|
)
|
|
3396
104
|
)
|
|
3397
105
|
];
|
|
3398
106
|
}
|
|
3399
|
-
if (
|
|
3400
|
-
const d =
|
|
3401
|
-
if (d
|
|
3402
|
-
return [
|
|
107
|
+
if (we(l) && o) {
|
|
108
|
+
const d = z(l._def.valueType);
|
|
109
|
+
if (K(d))
|
|
110
|
+
return [r, Object.keys(o).reduce((c, h) => (c[h] = J(d, o[h]), c), {})];
|
|
3403
111
|
}
|
|
3404
|
-
return
|
|
3405
|
-
|
|
3406
|
-
|
|
3407
|
-
|
|
3408
|
-
|
|
112
|
+
return K(l) ? [
|
|
113
|
+
r,
|
|
114
|
+
J(
|
|
115
|
+
l,
|
|
116
|
+
o && typeof o == "object" ? o : f
|
|
3409
117
|
)
|
|
3410
|
-
] : [
|
|
118
|
+
] : [r, f];
|
|
3411
119
|
}
|
|
3412
120
|
)
|
|
3413
121
|
)
|
|
3414
|
-
} :
|
|
122
|
+
} : t;
|
|
3415
123
|
}
|
|
3416
|
-
const
|
|
3417
|
-
function
|
|
3418
|
-
const
|
|
124
|
+
const Re = (e, t) => Q(e) ? be(e, t) : e.safeParseAsync(t), xe = (e, t) => Q(e) ? ae(t) : t.format(), Ee = (e, t) => Q(e) ? ae(new he(t)) : new pe(t).format();
|
|
125
|
+
function Ae(e, t, n, b, r) {
|
|
126
|
+
const u = _(), o = _(), i = D(() => o.value === R.invalid), l = _(), f = _(!1);
|
|
3419
127
|
let d;
|
|
3420
|
-
const
|
|
3421
|
-
const
|
|
3422
|
-
if (
|
|
3423
|
-
const
|
|
3424
|
-
return new
|
|
128
|
+
const c = (w) => {
|
|
129
|
+
const S = J(e, w);
|
|
130
|
+
if (n?.class) {
|
|
131
|
+
const a = n.class;
|
|
132
|
+
return new a(S);
|
|
3425
133
|
}
|
|
3426
|
-
return
|
|
3427
|
-
},
|
|
3428
|
-
if (d =
|
|
134
|
+
return S;
|
|
135
|
+
}, h = async (w = l.value, S) => {
|
|
136
|
+
if (d = S?.fields, f.value)
|
|
3429
137
|
return !0;
|
|
3430
|
-
const
|
|
3431
|
-
if (!
|
|
3432
|
-
if (
|
|
3433
|
-
return
|
|
3434
|
-
const
|
|
3435
|
-
(
|
|
138
|
+
const a = await Re(e, w);
|
|
139
|
+
if (!a.success) {
|
|
140
|
+
if (o.value = R.invalid, !d?.size)
|
|
141
|
+
return u.value = xe(e, a.error), !1;
|
|
142
|
+
const j = a.error.issues.filter(
|
|
143
|
+
($) => d?.has($.path.join("."))
|
|
3436
144
|
);
|
|
3437
|
-
return
|
|
145
|
+
return j.length ? (u.value = Ee(e, j), !1) : (u.value = void 0, !0);
|
|
3438
146
|
}
|
|
3439
|
-
return
|
|
3440
|
-
},
|
|
3441
|
-
|
|
3442
|
-
},
|
|
3443
|
-
|
|
3444
|
-
},
|
|
3445
|
-
|
|
147
|
+
return u.value = void 0, o.value = R.valid, l.value = c(a.data), !0;
|
|
148
|
+
}, g = () => {
|
|
149
|
+
u.value = void 0, o.value = void 0, d = void 0;
|
|
150
|
+
}, O = () => {
|
|
151
|
+
l.value = c(), g(), o.value = R.reset;
|
|
152
|
+
}, v = async (w) => f.value || !await h(void 0, w) ? !1 : (o.value = R.submitting, !0), { ignoreUpdates: m, stop: y } = ce(
|
|
153
|
+
l,
|
|
3446
154
|
() => {
|
|
3447
|
-
|
|
155
|
+
o.value = R.updated;
|
|
3448
156
|
},
|
|
3449
157
|
{
|
|
3450
158
|
deep: !0,
|
|
3451
|
-
eventFilter:
|
|
159
|
+
eventFilter: me(n?.updateThrottle ?? 500)
|
|
3452
160
|
}
|
|
3453
|
-
),
|
|
161
|
+
), x = N(u), I = N(o), A = C({
|
|
3454
162
|
name: "VvForm",
|
|
3455
163
|
props: {
|
|
3456
164
|
continuousValidation: {
|
|
@@ -3463,7 +171,7 @@ function Or(r, e, t, s, n) {
|
|
|
3463
171
|
},
|
|
3464
172
|
readonly: {
|
|
3465
173
|
type: Boolean,
|
|
3466
|
-
default:
|
|
174
|
+
default: n?.readonly
|
|
3467
175
|
},
|
|
3468
176
|
tag: {
|
|
3469
177
|
type: String,
|
|
@@ -3504,215 +212,152 @@ function Or(r, e, t, s, n) {
|
|
|
3504
212
|
"reset"
|
|
3505
213
|
],
|
|
3506
214
|
slots: Object,
|
|
3507
|
-
setup(
|
|
3508
|
-
return
|
|
3509
|
-
() =>
|
|
3510
|
-
(
|
|
3511
|
-
if (
|
|
3512
|
-
const
|
|
3513
|
-
if (JSON.stringify(
|
|
215
|
+
setup(w, { emit: S }) {
|
|
216
|
+
return l.value = c(G(w.modelValue)), k(
|
|
217
|
+
() => w.modelValue,
|
|
218
|
+
(a) => {
|
|
219
|
+
if (a) {
|
|
220
|
+
const j = de(a) ? G(a) : a;
|
|
221
|
+
if (JSON.stringify(j) === JSON.stringify(G(l.value)))
|
|
3514
222
|
return;
|
|
3515
|
-
|
|
223
|
+
l.value = typeof j?.clone == "function" ? j.clone() : JSON.parse(JSON.stringify(j));
|
|
3516
224
|
}
|
|
3517
225
|
},
|
|
3518
226
|
{ deep: !0 }
|
|
3519
|
-
),
|
|
3520
|
-
if (
|
|
3521
|
-
const
|
|
3522
|
-
|
|
3523
|
-
|
|
227
|
+
), k(o, async (a) => {
|
|
228
|
+
if (a === R.invalid) {
|
|
229
|
+
const j = G(u.value);
|
|
230
|
+
S("invalid", j), n?.onInvalid?.(
|
|
231
|
+
j
|
|
3524
232
|
);
|
|
3525
233
|
return;
|
|
3526
234
|
}
|
|
3527
|
-
if (
|
|
3528
|
-
const
|
|
3529
|
-
|
|
235
|
+
if (a === R.valid) {
|
|
236
|
+
const j = G(l.value);
|
|
237
|
+
S("valid", j), n?.onValid?.(j), S("update:modelValue", j), n?.onUpdate?.(j);
|
|
3530
238
|
return;
|
|
3531
239
|
}
|
|
3532
|
-
if (
|
|
3533
|
-
const
|
|
3534
|
-
|
|
240
|
+
if (a === R.submitting) {
|
|
241
|
+
const j = G(l.value);
|
|
242
|
+
S("submit", j), n?.onSubmit?.(j);
|
|
3535
243
|
return;
|
|
3536
244
|
}
|
|
3537
|
-
if (
|
|
3538
|
-
const
|
|
3539
|
-
|
|
245
|
+
if (a === R.reset) {
|
|
246
|
+
const j = G(l.value);
|
|
247
|
+
S("reset", j), n?.onReset?.(j);
|
|
3540
248
|
return;
|
|
3541
249
|
}
|
|
3542
|
-
if (
|
|
3543
|
-
if ((
|
|
3544
|
-
superRefine:
|
|
3545
|
-
fields: d ?? new Set(
|
|
3546
|
-
}), !
|
|
3547
|
-
const
|
|
3548
|
-
|
|
250
|
+
if (a === R.updated) {
|
|
251
|
+
if ((u.value || n?.continuousValidation || w.continuousValidation) && await h(void 0, {
|
|
252
|
+
superRefine: w.superRefine,
|
|
253
|
+
fields: d ?? new Set(w.validateFields)
|
|
254
|
+
}), !l.value || !w.modelValue || JSON.stringify(l.value) !== JSON.stringify(w.modelValue)) {
|
|
255
|
+
const j = G(l.value);
|
|
256
|
+
S("update:modelValue", j), n?.onUpdate?.(j);
|
|
3549
257
|
}
|
|
3550
|
-
|
|
258
|
+
o.value === R.updated && (o.value = R.unknown);
|
|
3551
259
|
}
|
|
3552
|
-
}),
|
|
3553
|
-
|
|
3554
|
-
}),
|
|
3555
|
-
() =>
|
|
3556
|
-
(
|
|
3557
|
-
|
|
260
|
+
}), q(() => {
|
|
261
|
+
w.readonly !== void 0 && (f.value = w.readonly);
|
|
262
|
+
}), k(
|
|
263
|
+
() => w.readonly,
|
|
264
|
+
(a) => {
|
|
265
|
+
f.value = a;
|
|
3558
266
|
}
|
|
3559
|
-
),
|
|
3560
|
-
|
|
3561
|
-
}),
|
|
3562
|
-
clear:
|
|
3563
|
-
errors:
|
|
3564
|
-
formData:
|
|
267
|
+
), k(f, (a) => {
|
|
268
|
+
a !== w.readonly && S("update:readonly", f.value);
|
|
269
|
+
}), H(t, {
|
|
270
|
+
clear: g,
|
|
271
|
+
errors: x,
|
|
272
|
+
formData: l,
|
|
3565
273
|
ignoreUpdates: m,
|
|
3566
|
-
invalid:
|
|
3567
|
-
readonly:
|
|
3568
|
-
reset:
|
|
3569
|
-
status:
|
|
3570
|
-
stopUpdatesWatch:
|
|
3571
|
-
submit:
|
|
3572
|
-
validate:
|
|
3573
|
-
wrappers:
|
|
274
|
+
invalid: i,
|
|
275
|
+
readonly: f,
|
|
276
|
+
reset: O,
|
|
277
|
+
status: I,
|
|
278
|
+
stopUpdatesWatch: y,
|
|
279
|
+
submit: v,
|
|
280
|
+
validate: h,
|
|
281
|
+
wrappers: r
|
|
3574
282
|
}), {
|
|
3575
|
-
clear:
|
|
3576
|
-
errors:
|
|
3577
|
-
formData:
|
|
283
|
+
clear: g,
|
|
284
|
+
errors: x,
|
|
285
|
+
formData: l,
|
|
3578
286
|
ignoreUpdates: m,
|
|
3579
|
-
invalid:
|
|
3580
|
-
isReadonly:
|
|
3581
|
-
reset:
|
|
3582
|
-
status:
|
|
3583
|
-
stopUpdatesWatch:
|
|
3584
|
-
submit: () =>
|
|
3585
|
-
superRefine:
|
|
3586
|
-
fields: new Set(
|
|
287
|
+
invalid: i,
|
|
288
|
+
isReadonly: f,
|
|
289
|
+
reset: O,
|
|
290
|
+
status: I,
|
|
291
|
+
stopUpdatesWatch: y,
|
|
292
|
+
submit: () => v({
|
|
293
|
+
superRefine: w.superRefine,
|
|
294
|
+
fields: new Set(w.validateFields)
|
|
3587
295
|
}),
|
|
3588
|
-
validate:
|
|
3589
|
-
wrappers:
|
|
296
|
+
validate: h,
|
|
297
|
+
wrappers: r
|
|
3590
298
|
};
|
|
3591
299
|
},
|
|
3592
300
|
render() {
|
|
3593
|
-
const
|
|
3594
|
-
errors:
|
|
3595
|
-
formData:
|
|
3596
|
-
invalid:
|
|
3597
|
-
readonly:
|
|
3598
|
-
status:
|
|
3599
|
-
wrappers:
|
|
3600
|
-
clear:
|
|
301
|
+
const w = () => this.$slots?.default?.({
|
|
302
|
+
errors: x.value,
|
|
303
|
+
formData: l.value,
|
|
304
|
+
invalid: i.value,
|
|
305
|
+
readonly: f.value,
|
|
306
|
+
status: I.value,
|
|
307
|
+
wrappers: r,
|
|
308
|
+
clear: g,
|
|
3601
309
|
ignoreUpdates: m,
|
|
3602
|
-
reset:
|
|
3603
|
-
stopUpdatesWatch:
|
|
3604
|
-
submit:
|
|
3605
|
-
validate:
|
|
310
|
+
reset: O,
|
|
311
|
+
stopUpdatesWatch: y,
|
|
312
|
+
submit: v,
|
|
313
|
+
validate: h
|
|
3606
314
|
}) ?? this.$slots.default;
|
|
3607
|
-
return
|
|
315
|
+
return E(
|
|
3608
316
|
this.tag,
|
|
3609
317
|
{
|
|
3610
|
-
onSubmit:
|
|
3611
|
-
onReset:
|
|
318
|
+
onSubmit: te(this.submit, ["prevent"]),
|
|
319
|
+
onReset: te(this.reset, ["prevent"])
|
|
3612
320
|
},
|
|
3613
|
-
(this.template ??
|
|
3614
|
-
|
|
3615
|
-
|
|
321
|
+
(this.template ?? n?.template) && b ? [
|
|
322
|
+
E(
|
|
323
|
+
b,
|
|
3616
324
|
{
|
|
3617
|
-
schema: this.template ??
|
|
325
|
+
schema: this.template ?? n?.template
|
|
3618
326
|
},
|
|
3619
327
|
{
|
|
3620
|
-
default:
|
|
328
|
+
default: w
|
|
3621
329
|
}
|
|
3622
330
|
)
|
|
3623
331
|
] : {
|
|
3624
|
-
default:
|
|
332
|
+
default: w
|
|
3625
333
|
}
|
|
3626
334
|
);
|
|
3627
335
|
}
|
|
3628
336
|
});
|
|
3629
337
|
return {
|
|
3630
|
-
clear:
|
|
3631
|
-
errors:
|
|
3632
|
-
formData:
|
|
338
|
+
clear: g,
|
|
339
|
+
errors: u,
|
|
340
|
+
formData: l,
|
|
3633
341
|
ignoreUpdates: m,
|
|
3634
|
-
invalid:
|
|
3635
|
-
readonly:
|
|
3636
|
-
reset:
|
|
3637
|
-
status:
|
|
3638
|
-
wrappers:
|
|
3639
|
-
stopUpdatesWatch:
|
|
3640
|
-
submit:
|
|
3641
|
-
validate:
|
|
3642
|
-
VvForm:
|
|
342
|
+
invalid: i,
|
|
343
|
+
readonly: f,
|
|
344
|
+
reset: O,
|
|
345
|
+
status: o,
|
|
346
|
+
wrappers: r,
|
|
347
|
+
stopUpdatesWatch: y,
|
|
348
|
+
submit: v,
|
|
349
|
+
validate: h,
|
|
350
|
+
VvForm: A
|
|
3643
351
|
};
|
|
3644
352
|
}
|
|
3645
|
-
function
|
|
3646
|
-
return
|
|
3647
|
-
}
|
|
3648
|
-
function Sr(r) {
|
|
3649
|
-
return !1;
|
|
3650
|
-
}
|
|
3651
|
-
function dt(r) {
|
|
3652
|
-
return r === null;
|
|
3653
|
-
}
|
|
3654
|
-
function Ot(r) {
|
|
3655
|
-
return typeof r == "object";
|
|
3656
|
-
}
|
|
3657
|
-
function St(r) {
|
|
3658
|
-
return typeof r == "string";
|
|
3659
|
-
}
|
|
3660
|
-
function Oe(r) {
|
|
3661
|
-
return typeof r > "u";
|
|
3662
|
-
}
|
|
3663
|
-
const jr = /^[0-9]+$/, Tr = ["__proto__", "prototype", "constructor"];
|
|
3664
|
-
function he(r, e, t) {
|
|
3665
|
-
const s = Sr() ? t : void 0;
|
|
3666
|
-
if (!Ot(r) || !St(e))
|
|
3667
|
-
return s;
|
|
3668
|
-
const n = jt(e);
|
|
3669
|
-
if (n.length !== 0) {
|
|
3670
|
-
for (const a of n) {
|
|
3671
|
-
if (a === "*")
|
|
3672
|
-
continue;
|
|
3673
|
-
const i = function(o) {
|
|
3674
|
-
return o.map((u) => Oe(u) || dt(u) ? u : Le(u) ? i(u) : u[a]);
|
|
3675
|
-
};
|
|
3676
|
-
if (Le(r) && !jr.test(a) ? r = i(r) : r = r[a], Oe(r) || dt(r))
|
|
3677
|
-
break;
|
|
3678
|
-
}
|
|
3679
|
-
return Oe(r) ? s : r;
|
|
3680
|
-
}
|
|
3681
|
-
}
|
|
3682
|
-
function Be(r, e, t) {
|
|
3683
|
-
if (!Ot(r) || !St(e))
|
|
3684
|
-
return;
|
|
3685
|
-
const s = jt(e);
|
|
3686
|
-
if (s.length === 0)
|
|
3687
|
-
return;
|
|
3688
|
-
const n = s.length;
|
|
3689
|
-
for (let a = 0; a < n; a++) {
|
|
3690
|
-
const i = s[a];
|
|
3691
|
-
if (a === n - 1) {
|
|
3692
|
-
r[i] = t;
|
|
3693
|
-
return;
|
|
3694
|
-
}
|
|
3695
|
-
if (i === "*" && Le(r)) {
|
|
3696
|
-
const o = s.slice(a + 1).join(".");
|
|
3697
|
-
for (const u of r)
|
|
3698
|
-
Be(u, o, t);
|
|
3699
|
-
return;
|
|
3700
|
-
}
|
|
3701
|
-
Oe(r[i]) && (r[i] = {}), r = r[i];
|
|
3702
|
-
}
|
|
3703
|
-
}
|
|
3704
|
-
function jt(r) {
|
|
3705
|
-
const e = r.split(/[.]|(?:\[(\d|\*)\])/).filter((t) => !!t);
|
|
3706
|
-
return e.some((t) => Tr.indexOf(t) !== -1) ? [] : e;
|
|
3707
|
-
}
|
|
3708
|
-
function Nr(r, e, t, s) {
|
|
3709
|
-
return _e({
|
|
353
|
+
function Fe(e, t, n, b) {
|
|
354
|
+
return C({
|
|
3710
355
|
name: "VvFormField",
|
|
3711
356
|
props: {
|
|
3712
357
|
type: {
|
|
3713
358
|
type: String,
|
|
3714
|
-
validator: (
|
|
3715
|
-
default:
|
|
359
|
+
validator: (r) => Object.values(V).includes(r),
|
|
360
|
+
default: V.custom
|
|
3716
361
|
},
|
|
3717
362
|
is: {
|
|
3718
363
|
type: [Object, String],
|
|
@@ -3759,175 +404,175 @@ function Nr(r, e, t, s) {
|
|
|
3759
404
|
"type"
|
|
3760
405
|
],
|
|
3761
406
|
slots: Object,
|
|
3762
|
-
setup(
|
|
3763
|
-
const { props:
|
|
3764
|
-
d && d.fields.value.set(
|
|
3765
|
-
const
|
|
407
|
+
setup(r, { slots: u, emit: o }) {
|
|
408
|
+
const { props: i, name: l } = X(r), f = re(), d = B(t, void 0);
|
|
409
|
+
d && d.fields.value.set(f, r.name);
|
|
410
|
+
const c = B(e), h = D({
|
|
3766
411
|
get() {
|
|
3767
|
-
if (
|
|
3768
|
-
return
|
|
3769
|
-
new Object(
|
|
3770
|
-
String(
|
|
412
|
+
if (c?.formData)
|
|
413
|
+
return L(
|
|
414
|
+
new Object(c.formData.value),
|
|
415
|
+
String(r.name)
|
|
3771
416
|
);
|
|
3772
417
|
},
|
|
3773
|
-
set(
|
|
3774
|
-
|
|
3775
|
-
new Object(
|
|
3776
|
-
String(
|
|
3777
|
-
|
|
3778
|
-
),
|
|
3779
|
-
newValue:
|
|
3780
|
-
formData:
|
|
418
|
+
set(a) {
|
|
419
|
+
c?.formData && (ne(
|
|
420
|
+
new Object(c.formData.value),
|
|
421
|
+
String(r.name),
|
|
422
|
+
a
|
|
423
|
+
), o("update:modelValue", {
|
|
424
|
+
newValue: h.value,
|
|
425
|
+
formData: c?.formData
|
|
3781
426
|
}));
|
|
3782
427
|
}
|
|
3783
428
|
});
|
|
3784
|
-
|
|
3785
|
-
|
|
3786
|
-
}),
|
|
3787
|
-
d && d.fields.value.delete(
|
|
429
|
+
q(() => {
|
|
430
|
+
h.value === void 0 && r.defaultValue !== void 0 && (h.value = r.defaultValue);
|
|
431
|
+
}), U(() => {
|
|
432
|
+
d && d.fields.value.delete(f);
|
|
3788
433
|
});
|
|
3789
|
-
const
|
|
3790
|
-
if (
|
|
3791
|
-
return
|
|
3792
|
-
}),
|
|
3793
|
-
if (
|
|
3794
|
-
|
|
3795
|
-
String(
|
|
3796
|
-
|
|
434
|
+
const g = D(() => {
|
|
435
|
+
if (c?.errors.value)
|
|
436
|
+
return L(c.errors.value, String(r.name));
|
|
437
|
+
}), O = D(() => g.value?._errors), v = D(() => g.value !== void 0), m = k(v, (a) => {
|
|
438
|
+
if (a) {
|
|
439
|
+
o("invalid", g.value), d && d.errors.value.set(
|
|
440
|
+
String(r.name),
|
|
441
|
+
g.value
|
|
3797
442
|
);
|
|
3798
443
|
return;
|
|
3799
444
|
}
|
|
3800
|
-
|
|
3801
|
-
|
|
445
|
+
o("valid", h.value), d && d.errors.value.delete(
|
|
446
|
+
r.name
|
|
3802
447
|
);
|
|
3803
|
-
}),
|
|
3804
|
-
() =>
|
|
448
|
+
}), y = k(
|
|
449
|
+
() => c?.formData,
|
|
3805
450
|
() => {
|
|
3806
|
-
|
|
451
|
+
o("update:formData", c?.formData);
|
|
3807
452
|
},
|
|
3808
453
|
{ deep: !0 }
|
|
3809
454
|
);
|
|
3810
|
-
|
|
3811
|
-
m(),
|
|
455
|
+
U(() => {
|
|
456
|
+
m(), y();
|
|
3812
457
|
});
|
|
3813
|
-
const
|
|
3814
|
-
|
|
3815
|
-
},
|
|
3816
|
-
let
|
|
3817
|
-
return typeof
|
|
3818
|
-
(
|
|
458
|
+
const x = (a) => {
|
|
459
|
+
a instanceof InputEvent && (a = a.target.value), h.value = a;
|
|
460
|
+
}, I = D(() => {
|
|
461
|
+
let a = i.value;
|
|
462
|
+
return typeof a == "function" && (a = a(c?.formData)), Object.keys(a).reduce(
|
|
463
|
+
(j, $) => (j[$] = P(a[$]), j),
|
|
3819
464
|
{}
|
|
3820
465
|
);
|
|
3821
|
-
}),
|
|
3822
|
-
...
|
|
3823
|
-
name:
|
|
3824
|
-
invalid:
|
|
3825
|
-
valid:
|
|
3826
|
-
type: ((
|
|
466
|
+
}), A = D(() => c?.readonly.value || d?.readonly.value ? !0 : I.value.readonly ?? r.readonly), w = D(() => ({
|
|
467
|
+
...I.value,
|
|
468
|
+
name: I.value.name ?? r.name,
|
|
469
|
+
invalid: v.value,
|
|
470
|
+
valid: r.showValid ? !!(!v.value && h.value) : void 0,
|
|
471
|
+
type: ((a) => {
|
|
3827
472
|
if ([
|
|
3828
|
-
|
|
3829
|
-
|
|
3830
|
-
|
|
3831
|
-
|
|
3832
|
-
|
|
3833
|
-
|
|
3834
|
-
|
|
3835
|
-
|
|
3836
|
-
|
|
3837
|
-
|
|
3838
|
-
|
|
3839
|
-
|
|
3840
|
-
|
|
3841
|
-
].includes(
|
|
3842
|
-
return
|
|
3843
|
-
})(
|
|
3844
|
-
invalidLabel:
|
|
3845
|
-
modelValue:
|
|
3846
|
-
readonly:
|
|
3847
|
-
"onUpdate:modelValue":
|
|
473
|
+
V.color,
|
|
474
|
+
V.date,
|
|
475
|
+
V.datetimeLocal,
|
|
476
|
+
V.email,
|
|
477
|
+
V.month,
|
|
478
|
+
V.number,
|
|
479
|
+
V.password,
|
|
480
|
+
V.search,
|
|
481
|
+
V.tel,
|
|
482
|
+
V.text,
|
|
483
|
+
V.time,
|
|
484
|
+
V.url,
|
|
485
|
+
V.week
|
|
486
|
+
].includes(a))
|
|
487
|
+
return a;
|
|
488
|
+
})(r.type),
|
|
489
|
+
invalidLabel: O.value,
|
|
490
|
+
modelValue: h.value,
|
|
491
|
+
readonly: A.value,
|
|
492
|
+
"onUpdate:modelValue": x
|
|
3848
493
|
}));
|
|
3849
|
-
return
|
|
3850
|
-
name:
|
|
3851
|
-
errors:
|
|
3852
|
-
}), { component:
|
|
3853
|
-
if (
|
|
494
|
+
return H(n, {
|
|
495
|
+
name: N(l),
|
|
496
|
+
errors: N(g)
|
|
497
|
+
}), { component: D(() => {
|
|
498
|
+
if (r.type === V.custom)
|
|
3854
499
|
return {
|
|
3855
500
|
render() {
|
|
3856
|
-
return
|
|
3857
|
-
errors:
|
|
3858
|
-
formData:
|
|
3859
|
-
formErrors:
|
|
3860
|
-
invalid:
|
|
3861
|
-
invalidLabel:
|
|
3862
|
-
modelValue:
|
|
3863
|
-
readonly:
|
|
3864
|
-
onUpdate:
|
|
3865
|
-
submit:
|
|
3866
|
-
validate:
|
|
3867
|
-
}) ??
|
|
501
|
+
return u.default?.({
|
|
502
|
+
errors: g.value,
|
|
503
|
+
formData: c?.formData.value,
|
|
504
|
+
formErrors: c?.errors.value,
|
|
505
|
+
invalid: v.value,
|
|
506
|
+
invalidLabel: O.value,
|
|
507
|
+
modelValue: h.value,
|
|
508
|
+
readonly: A.value,
|
|
509
|
+
onUpdate: x,
|
|
510
|
+
submit: c?.submit,
|
|
511
|
+
validate: c?.validate
|
|
512
|
+
}) ?? u.default;
|
|
3868
513
|
}
|
|
3869
514
|
};
|
|
3870
|
-
if (!(
|
|
3871
|
-
let
|
|
3872
|
-
switch (
|
|
3873
|
-
case
|
|
3874
|
-
|
|
515
|
+
if (!(b?.lazyLoad ?? r.lazyLoad)) {
|
|
516
|
+
let a;
|
|
517
|
+
switch (r.type) {
|
|
518
|
+
case V.select:
|
|
519
|
+
a = Z("VvSelect");
|
|
3875
520
|
break;
|
|
3876
|
-
case
|
|
3877
|
-
|
|
521
|
+
case V.checkbox:
|
|
522
|
+
a = Z("VvCheckbox");
|
|
3878
523
|
break;
|
|
3879
|
-
case
|
|
3880
|
-
|
|
524
|
+
case V.radio:
|
|
525
|
+
a = Z("VvRadio");
|
|
3881
526
|
break;
|
|
3882
|
-
case
|
|
3883
|
-
|
|
527
|
+
case V.textarea:
|
|
528
|
+
a = Z("VvTextarea");
|
|
3884
529
|
break;
|
|
3885
|
-
case
|
|
3886
|
-
|
|
530
|
+
case V.radioGroup:
|
|
531
|
+
a = Z("VvRadioGroup");
|
|
3887
532
|
break;
|
|
3888
|
-
case
|
|
3889
|
-
|
|
533
|
+
case V.checkboxGroup:
|
|
534
|
+
a = Z("VvCheckboxGroup");
|
|
3890
535
|
break;
|
|
3891
|
-
case
|
|
3892
|
-
|
|
536
|
+
case V.combobox:
|
|
537
|
+
a = Z("VvCombobox");
|
|
3893
538
|
break;
|
|
3894
539
|
default:
|
|
3895
|
-
|
|
540
|
+
a = Z("VvInputText");
|
|
3896
541
|
}
|
|
3897
|
-
if (typeof
|
|
3898
|
-
return
|
|
542
|
+
if (typeof a != "string")
|
|
543
|
+
return a;
|
|
3899
544
|
console.warn(
|
|
3900
|
-
`[@volverjs/form-vue]: ${
|
|
545
|
+
`[@volverjs/form-vue]: ${a} not found, the component will be loaded asynchronously. To avoid this warning, please set "lazyLoad" option.`
|
|
3901
546
|
);
|
|
3902
547
|
}
|
|
3903
|
-
return
|
|
3904
|
-
switch (
|
|
3905
|
-
case
|
|
548
|
+
return fe(async () => {
|
|
549
|
+
switch (b?.sideEffects && await Promise.resolve(b.sideEffects(r.type)), r.type) {
|
|
550
|
+
case V.textarea:
|
|
3906
551
|
return import("@volverjs/ui-vue/vv-textarea");
|
|
3907
|
-
case
|
|
552
|
+
case V.radio:
|
|
3908
553
|
return import("@volverjs/ui-vue/vv-radio");
|
|
3909
|
-
case
|
|
554
|
+
case V.radioGroup:
|
|
3910
555
|
return import("@volverjs/ui-vue/vv-radio-group");
|
|
3911
|
-
case
|
|
556
|
+
case V.checkbox:
|
|
3912
557
|
return import("@volverjs/ui-vue/vv-checkbox");
|
|
3913
|
-
case
|
|
558
|
+
case V.checkboxGroup:
|
|
3914
559
|
return import("@volverjs/ui-vue/vv-checkbox-group");
|
|
3915
|
-
case
|
|
560
|
+
case V.select:
|
|
3916
561
|
return import("@volverjs/ui-vue/vv-select");
|
|
3917
|
-
case
|
|
562
|
+
case V.combobox:
|
|
3918
563
|
return import("@volverjs/ui-vue/vv-combobox");
|
|
3919
564
|
}
|
|
3920
565
|
return import("@volverjs/ui-vue/vv-input-text");
|
|
3921
566
|
});
|
|
3922
|
-
}), hasProps:
|
|
567
|
+
}), hasProps: w, invalid: v };
|
|
3923
568
|
},
|
|
3924
569
|
render() {
|
|
3925
|
-
return this.is ?
|
|
570
|
+
return this.is ? E(this.is, this.hasProps, this.$slots) : this.type === V.custom ? E(this.component, null, this.$slots) : E(this.component, this.hasProps, this.$slots);
|
|
3926
571
|
}
|
|
3927
572
|
});
|
|
3928
573
|
}
|
|
3929
|
-
function
|
|
3930
|
-
return
|
|
574
|
+
function ke(e, t, n) {
|
|
575
|
+
return C({
|
|
3931
576
|
name: "VvFormFieldsGroup",
|
|
3932
577
|
props: {
|
|
3933
578
|
is: {
|
|
@@ -3970,151 +615,151 @@ function Ir(r, e, t) {
|
|
|
3970
615
|
"is"
|
|
3971
616
|
],
|
|
3972
617
|
slots: Object,
|
|
3973
|
-
setup(
|
|
3974
|
-
const { props:
|
|
3975
|
-
|
|
3976
|
-
|
|
618
|
+
setup(b, { slots: r, emit: u }) {
|
|
619
|
+
const { props: o, names: i, defaultValues: l } = X(b), f = re(), d = D(() => Array.isArray(i.value) ? i.value : Object.values(i.value)), c = D(() => Array.isArray(i.value) ? i.value : Object.keys(i.value)), h = D(() => Array.isArray(i.value) ? i.value.reduce((s, p) => (s[String(p)] = p, s), {}) : i.value), g = D(() => Object.keys(h.value).reduce((s, p) => (s[String(h.value[p])] = p, s), {})), O = B(t, void 0);
|
|
620
|
+
O && d.value.forEach((s) => {
|
|
621
|
+
O.fields.value.set(`${f}-${s}`, s);
|
|
3977
622
|
});
|
|
3978
|
-
const
|
|
623
|
+
const v = B(e), m = D({
|
|
3979
624
|
get() {
|
|
3980
|
-
return
|
|
3981
|
-
new Object(
|
|
3982
|
-
|
|
3983
|
-
),
|
|
625
|
+
return v?.formData ? c.value.reduce((s, p) => (s[p] = L(
|
|
626
|
+
new Object(v.formData.value),
|
|
627
|
+
h.value[p]
|
|
628
|
+
), s), {}) : {};
|
|
3984
629
|
},
|
|
3985
|
-
set(
|
|
3986
|
-
|
|
3987
|
-
|
|
3988
|
-
new Object(
|
|
3989
|
-
|
|
3990
|
-
|
|
630
|
+
set(s) {
|
|
631
|
+
v?.formData && (c.value.forEach((p) => {
|
|
632
|
+
ne(
|
|
633
|
+
new Object(v.formData.value),
|
|
634
|
+
h.value[p],
|
|
635
|
+
s?.[p]
|
|
3991
636
|
);
|
|
3992
|
-
}),
|
|
637
|
+
}), u("update:modelValue", {
|
|
3993
638
|
newValue: m.value,
|
|
3994
|
-
formData:
|
|
639
|
+
formData: v?.formData
|
|
3995
640
|
}));
|
|
3996
641
|
}
|
|
3997
642
|
});
|
|
3998
|
-
|
|
3999
|
-
|
|
4000
|
-
|
|
643
|
+
q(() => {
|
|
644
|
+
l.value && d.value.forEach((s) => {
|
|
645
|
+
l.value?.[s] !== void 0 && m.value[s] === void 0 && (m.value = {
|
|
4001
646
|
...m.value,
|
|
4002
|
-
[
|
|
647
|
+
[s]: l.value?.[s]
|
|
4003
648
|
});
|
|
4004
649
|
});
|
|
4005
|
-
}),
|
|
4006
|
-
|
|
4007
|
-
|
|
4008
|
-
`${
|
|
650
|
+
}), U(() => {
|
|
651
|
+
O && d.value.forEach((s) => {
|
|
652
|
+
O.fields.value.delete(
|
|
653
|
+
`${f}-${s}`
|
|
4009
654
|
);
|
|
4010
655
|
});
|
|
4011
656
|
});
|
|
4012
|
-
const
|
|
4013
|
-
if (!
|
|
657
|
+
const y = D(() => {
|
|
658
|
+
if (!v?.errors.value)
|
|
4014
659
|
return;
|
|
4015
|
-
const
|
|
4016
|
-
if (!
|
|
4017
|
-
return
|
|
4018
|
-
const
|
|
4019
|
-
return
|
|
660
|
+
const s = d.value.reduce((p, F) => {
|
|
661
|
+
if (!v.errors.value)
|
|
662
|
+
return p;
|
|
663
|
+
const ee = L(v.errors.value, String(F));
|
|
664
|
+
return ee === void 0 || (p[String(F)] = ee), p;
|
|
4020
665
|
}, {});
|
|
4021
|
-
if (Object.keys(
|
|
4022
|
-
return
|
|
4023
|
-
}),
|
|
4024
|
-
if (!
|
|
666
|
+
if (Object.keys(s).length !== 0)
|
|
667
|
+
return s;
|
|
668
|
+
}), x = D(() => {
|
|
669
|
+
if (!y.value)
|
|
4025
670
|
return;
|
|
4026
|
-
const
|
|
4027
|
-
if (Object.keys(
|
|
4028
|
-
return
|
|
4029
|
-
}),
|
|
4030
|
-
if (
|
|
4031
|
-
|
|
4032
|
-
if (!
|
|
4033
|
-
|
|
4034
|
-
|
|
671
|
+
const s = Object.keys(y.value).reduce((p, F) => (y.value?.[F] && (p[g.value[F]] = y.value[F]._errors), p), {});
|
|
672
|
+
if (Object.keys(s).length !== 0)
|
|
673
|
+
return s;
|
|
674
|
+
}), I = D(() => y.value !== void 0), A = D(() => c.value.reduce((s, p) => (s[p] = !!y.value?.[g.value[p]], s), {})), w = k(I, () => {
|
|
675
|
+
if (I.value) {
|
|
676
|
+
u("invalid", y.value), O && d.value.forEach((s) => {
|
|
677
|
+
if (!y.value?.[s]) {
|
|
678
|
+
O.errors.value.delete(
|
|
679
|
+
s
|
|
4035
680
|
);
|
|
4036
681
|
return;
|
|
4037
682
|
}
|
|
4038
|
-
|
|
4039
|
-
|
|
4040
|
-
|
|
683
|
+
O.errors.value.set(
|
|
684
|
+
s,
|
|
685
|
+
y.value?.[s]
|
|
4041
686
|
);
|
|
4042
687
|
});
|
|
4043
688
|
return;
|
|
4044
689
|
}
|
|
4045
|
-
|
|
4046
|
-
|
|
4047
|
-
|
|
690
|
+
u("valid", m.value), O && d.value.forEach((s) => {
|
|
691
|
+
O.errors.value.delete(
|
|
692
|
+
s
|
|
4048
693
|
);
|
|
4049
694
|
});
|
|
4050
|
-
}),
|
|
4051
|
-
() =>
|
|
695
|
+
}), S = k(
|
|
696
|
+
() => v?.formData,
|
|
4052
697
|
() => {
|
|
4053
|
-
|
|
698
|
+
u("update:formData", v?.formData);
|
|
4054
699
|
},
|
|
4055
700
|
{ deep: !0 }
|
|
4056
701
|
);
|
|
4057
|
-
|
|
4058
|
-
|
|
702
|
+
U(() => {
|
|
703
|
+
w(), S();
|
|
4059
704
|
});
|
|
4060
|
-
const
|
|
4061
|
-
m.value =
|
|
4062
|
-
},
|
|
4063
|
-
|
|
705
|
+
const a = (s) => {
|
|
706
|
+
m.value = s;
|
|
707
|
+
}, j = (s, p) => {
|
|
708
|
+
p instanceof InputEvent && (p = p.target.value), c.value.includes(s) && (m.value = {
|
|
4064
709
|
...m.value,
|
|
4065
|
-
[
|
|
710
|
+
[s]: p
|
|
4066
711
|
});
|
|
4067
|
-
},
|
|
4068
|
-
let
|
|
4069
|
-
return typeof
|
|
4070
|
-
(
|
|
712
|
+
}, $ = D(() => {
|
|
713
|
+
let s = o.value;
|
|
714
|
+
return typeof s == "function" && (s = s(v?.formData)), Object.keys(s).reduce(
|
|
715
|
+
(p, F) => (p[F] = P(s[F]), p),
|
|
4071
716
|
{}
|
|
4072
717
|
);
|
|
4073
|
-
}),
|
|
4074
|
-
|
|
4075
|
-
},
|
|
4076
|
-
"onUpdate:modelValue":
|
|
4077
|
-
})),
|
|
4078
|
-
...
|
|
4079
|
-
|
|
718
|
+
}), Y = D(() => v?.readonly.value ? !0 : $.value.readonly ?? b.readonly), se = D(() => c.value.reduce((s, p) => (s[`onUpdate:${p}`] = (F) => {
|
|
719
|
+
j(p, F);
|
|
720
|
+
}, s), {
|
|
721
|
+
"onUpdate:modelValue": a
|
|
722
|
+
})), ie = D(() => ({
|
|
723
|
+
...se.value,
|
|
724
|
+
...$.value,
|
|
4080
725
|
...m.value,
|
|
4081
726
|
modelValue: m.value,
|
|
4082
|
-
names:
|
|
4083
|
-
invalid:
|
|
4084
|
-
invalids:
|
|
4085
|
-
valid:
|
|
4086
|
-
invalidLabels:
|
|
4087
|
-
readonly:
|
|
727
|
+
names: $.value.name ?? d.value,
|
|
728
|
+
invalid: I.value,
|
|
729
|
+
invalids: A.value,
|
|
730
|
+
valid: b.showValid ? !!(!I.value && m.value) : void 0,
|
|
731
|
+
invalidLabels: x.value,
|
|
732
|
+
readonly: Y.value
|
|
4088
733
|
}));
|
|
4089
|
-
return
|
|
4090
|
-
names:
|
|
4091
|
-
errors:
|
|
4092
|
-
}), { component:
|
|
734
|
+
return H(n, {
|
|
735
|
+
names: N(i),
|
|
736
|
+
errors: N(y)
|
|
737
|
+
}), { component: D(() => ({
|
|
4093
738
|
render() {
|
|
4094
|
-
return
|
|
4095
|
-
errors:
|
|
4096
|
-
formData:
|
|
4097
|
-
formErrors:
|
|
4098
|
-
invalid:
|
|
4099
|
-
invalids:
|
|
4100
|
-
invalidLabels:
|
|
739
|
+
return r.default?.({
|
|
740
|
+
errors: y.value,
|
|
741
|
+
formData: v?.formData.value,
|
|
742
|
+
formErrors: v?.errors.value,
|
|
743
|
+
invalid: I.value,
|
|
744
|
+
invalids: A.value,
|
|
745
|
+
invalidLabels: x.value,
|
|
4101
746
|
modelValue: m.value,
|
|
4102
|
-
onUpdate:
|
|
4103
|
-
onUpdateField:
|
|
4104
|
-
readonly:
|
|
4105
|
-
submit:
|
|
4106
|
-
validate:
|
|
4107
|
-
}) ??
|
|
747
|
+
onUpdate: a,
|
|
748
|
+
onUpdateField: j,
|
|
749
|
+
readonly: Y.value,
|
|
750
|
+
submit: v?.submit,
|
|
751
|
+
validate: v?.validate
|
|
752
|
+
}) ?? r.default;
|
|
4108
753
|
}
|
|
4109
|
-
})), hasProps:
|
|
754
|
+
})), hasProps: ie, invalid: I };
|
|
4110
755
|
},
|
|
4111
756
|
render() {
|
|
4112
|
-
return this.is ?
|
|
757
|
+
return this.is ? E(this.is, this.hasProps, this.$slots) : E(this.component, null, this.$slots);
|
|
4113
758
|
}
|
|
4114
759
|
});
|
|
4115
760
|
}
|
|
4116
|
-
function
|
|
4117
|
-
return
|
|
761
|
+
function Ne(e, t) {
|
|
762
|
+
return C({
|
|
4118
763
|
name: "VvFormWrapper",
|
|
4119
764
|
props: {
|
|
4120
765
|
name: {
|
|
@@ -4146,75 +791,75 @@ function Cr(r, e) {
|
|
|
4146
791
|
"validateWrapper"
|
|
4147
792
|
],
|
|
4148
793
|
slots: Object,
|
|
4149
|
-
setup(
|
|
4150
|
-
const
|
|
4151
|
-
|
|
4152
|
-
if (
|
|
4153
|
-
|
|
794
|
+
setup(n, { emit: b }) {
|
|
795
|
+
const r = B(e), u = B(t, void 0), o = _(/* @__PURE__ */ new Map()), i = _(/* @__PURE__ */ new Map()), { name: l } = X(n), f = D(() => r?.invalid.value ? i.value.size > 0 : !1);
|
|
796
|
+
k(f, (O) => {
|
|
797
|
+
if (O) {
|
|
798
|
+
b("invalid");
|
|
4154
799
|
return;
|
|
4155
800
|
}
|
|
4156
|
-
|
|
801
|
+
b("valid");
|
|
4157
802
|
});
|
|
4158
|
-
const d =
|
|
4159
|
-
name:
|
|
4160
|
-
errors:
|
|
4161
|
-
invalid:
|
|
4162
|
-
readonly:
|
|
4163
|
-
fields:
|
|
803
|
+
const d = D(() => r?.readonly.value || n.readonly), c = {
|
|
804
|
+
name: N(l),
|
|
805
|
+
errors: i,
|
|
806
|
+
invalid: N(f),
|
|
807
|
+
readonly: N(d),
|
|
808
|
+
fields: o
|
|
4164
809
|
};
|
|
4165
|
-
|
|
4166
|
-
const
|
|
4167
|
-
|
|
4168
|
-
|
|
4169
|
-
(
|
|
4170
|
-
|
|
4171
|
-
|
|
4172
|
-
}),
|
|
4173
|
-
|
|
810
|
+
H(t, c);
|
|
811
|
+
const h = D(() => new Map(o.value));
|
|
812
|
+
k(
|
|
813
|
+
h,
|
|
814
|
+
(O, v) => {
|
|
815
|
+
u?.fields && (v.forEach((m, y) => {
|
|
816
|
+
O.has(y) || u?.fields.value.delete(y);
|
|
817
|
+
}), O.forEach((m, y) => {
|
|
818
|
+
u?.fields.value.has(y) || u?.fields.value.set(y, m);
|
|
4174
819
|
}));
|
|
4175
820
|
},
|
|
4176
821
|
{ deep: !0 }
|
|
4177
|
-
),
|
|
4178
|
-
|
|
4179
|
-
(
|
|
4180
|
-
|
|
4181
|
-
if (
|
|
4182
|
-
const m =
|
|
4183
|
-
m &&
|
|
822
|
+
), k(
|
|
823
|
+
i,
|
|
824
|
+
(O) => {
|
|
825
|
+
u?.errors && o.value.forEach((v) => {
|
|
826
|
+
if (O.has(v) || u.errors.value.delete(v), O.has(v)) {
|
|
827
|
+
const m = O.get(v);
|
|
828
|
+
m && u.errors.value.set(v, m);
|
|
4184
829
|
}
|
|
4185
830
|
});
|
|
4186
831
|
},
|
|
4187
832
|
{ deep: !0 }
|
|
4188
|
-
),
|
|
4189
|
-
if (!
|
|
833
|
+
), q(() => {
|
|
834
|
+
if (!r?.wrappers || !l.value) {
|
|
4190
835
|
console.warn("[@volverjs/form-vue]: Invalid wrapper registration state");
|
|
4191
836
|
return;
|
|
4192
837
|
}
|
|
4193
|
-
if (
|
|
4194
|
-
console.warn(`[@volverjs/form-vue]: wrapper name "${
|
|
838
|
+
if (r.wrappers.has(l.value)) {
|
|
839
|
+
console.warn(`[@volverjs/form-vue]: wrapper name "${l.value}" is already used`);
|
|
4195
840
|
return;
|
|
4196
841
|
}
|
|
4197
|
-
|
|
4198
|
-
}),
|
|
4199
|
-
|
|
842
|
+
r.wrappers.set(l.value, c);
|
|
843
|
+
}), U(() => {
|
|
844
|
+
r?.wrappers && l.value && r.wrappers.delete(l.value);
|
|
4200
845
|
});
|
|
4201
|
-
const
|
|
846
|
+
const g = () => r?.validate(void 0, { fields: new Set(o.value.values()) }) ?? Promise.resolve(!0);
|
|
4202
847
|
return {
|
|
4203
|
-
errors:
|
|
4204
|
-
fields:
|
|
4205
|
-
fieldsErrors:
|
|
4206
|
-
formData:
|
|
4207
|
-
invalid:
|
|
848
|
+
errors: r?.errors,
|
|
849
|
+
fields: o,
|
|
850
|
+
fieldsErrors: i,
|
|
851
|
+
formData: r?.formData,
|
|
852
|
+
invalid: f,
|
|
4208
853
|
readonly: d,
|
|
4209
|
-
clear:
|
|
4210
|
-
reset:
|
|
4211
|
-
submit:
|
|
4212
|
-
validate:
|
|
4213
|
-
validateWrapper:
|
|
854
|
+
clear: r?.clear,
|
|
855
|
+
reset: r?.reset,
|
|
856
|
+
submit: r?.submit,
|
|
857
|
+
validate: r?.validate,
|
|
858
|
+
validateWrapper: g
|
|
4214
859
|
};
|
|
4215
860
|
},
|
|
4216
861
|
render() {
|
|
4217
|
-
const
|
|
862
|
+
const n = () => this.$slots.default?.({
|
|
4218
863
|
errors: this.errors,
|
|
4219
864
|
fieldsErrors: this.fieldsErrors,
|
|
4220
865
|
formData: this.formData,
|
|
@@ -4226,14 +871,14 @@ function Cr(r, e) {
|
|
|
4226
871
|
validate: this.validate,
|
|
4227
872
|
validateWrapper: this.validateWrapper
|
|
4228
873
|
});
|
|
4229
|
-
return this.tag ?
|
|
4230
|
-
default:
|
|
4231
|
-
}) :
|
|
874
|
+
return this.tag ? E(this.tag, null, {
|
|
875
|
+
default: n
|
|
876
|
+
}) : n();
|
|
4232
877
|
}
|
|
4233
878
|
});
|
|
4234
879
|
}
|
|
4235
|
-
function
|
|
4236
|
-
const
|
|
880
|
+
function $e(e, t) {
|
|
881
|
+
const n = C({
|
|
4237
882
|
name: "VvFormTemplate",
|
|
4238
883
|
props: {
|
|
4239
884
|
schema: {
|
|
@@ -4246,174 +891,174 @@ function Er(r, e) {
|
|
|
4246
891
|
}
|
|
4247
892
|
},
|
|
4248
893
|
slots: Object,
|
|
4249
|
-
setup(
|
|
4250
|
-
const
|
|
4251
|
-
if (
|
|
894
|
+
setup(b, { slots: r }) {
|
|
895
|
+
const u = B(e);
|
|
896
|
+
if (u?.formData)
|
|
4252
897
|
return () => {
|
|
4253
|
-
const
|
|
4254
|
-
|
|
4255
|
-
|
|
4256
|
-
) :
|
|
4257
|
-
let
|
|
4258
|
-
const
|
|
4259
|
-
const
|
|
4260
|
-
vvIs:
|
|
4261
|
-
vvName:
|
|
4262
|
-
vvSlots:
|
|
4263
|
-
vvChildren:
|
|
898
|
+
const o = typeof b.schema == "function" ? b.schema(
|
|
899
|
+
u,
|
|
900
|
+
b.scope
|
|
901
|
+
) : b.schema;
|
|
902
|
+
let i;
|
|
903
|
+
const l = o.reduce((f, d) => {
|
|
904
|
+
const c = typeof d == "function" ? d(u, b.scope) : d, {
|
|
905
|
+
vvIs: h,
|
|
906
|
+
vvName: g,
|
|
907
|
+
vvSlots: O,
|
|
908
|
+
vvChildren: v,
|
|
4264
909
|
vvIf: m,
|
|
4265
|
-
vvElseIf:
|
|
4266
|
-
vvType:
|
|
4267
|
-
vvDefaultValue:
|
|
4268
|
-
vvShowValid:
|
|
4269
|
-
vvContent:
|
|
4270
|
-
...
|
|
4271
|
-
} =
|
|
910
|
+
vvElseIf: y,
|
|
911
|
+
vvType: x,
|
|
912
|
+
vvDefaultValue: I,
|
|
913
|
+
vvShowValid: A,
|
|
914
|
+
vvContent: w,
|
|
915
|
+
...S
|
|
916
|
+
} = c;
|
|
4272
917
|
if (m !== void 0) {
|
|
4273
|
-
if (typeof m == "string" ?
|
|
4274
|
-
new Object(
|
|
918
|
+
if (typeof m == "string" ? i = !!L(
|
|
919
|
+
new Object(u.formData.value),
|
|
4275
920
|
m
|
|
4276
|
-
) : typeof m == "function" ?
|
|
4277
|
-
return
|
|
4278
|
-
} else if (
|
|
4279
|
-
if (
|
|
4280
|
-
new Object(
|
|
4281
|
-
|
|
4282
|
-
) : typeof
|
|
4283
|
-
return
|
|
921
|
+
) : typeof m == "function" ? i = P(m(u)) : i = P(m), !i)
|
|
922
|
+
return f;
|
|
923
|
+
} else if (y !== void 0 && i !== void 0) {
|
|
924
|
+
if (i || (typeof y == "string" ? i = !!L(
|
|
925
|
+
new Object(u.formData.value),
|
|
926
|
+
y
|
|
927
|
+
) : typeof y == "function" ? i = P(y(u)) : i = P(y), !i))
|
|
928
|
+
return f;
|
|
4284
929
|
} else
|
|
4285
|
-
|
|
4286
|
-
let
|
|
4287
|
-
return
|
|
4288
|
-
schema:
|
|
4289
|
-
}) :
|
|
4290
|
-
default: (
|
|
4291
|
-
schema:
|
|
4292
|
-
scope:
|
|
930
|
+
i = void 0;
|
|
931
|
+
let a;
|
|
932
|
+
return v && (typeof h == "string" ? a = E(n, {
|
|
933
|
+
schema: v
|
|
934
|
+
}) : a = {
|
|
935
|
+
default: (j) => E(n, {
|
|
936
|
+
schema: v,
|
|
937
|
+
scope: j
|
|
4293
938
|
})
|
|
4294
|
-
}),
|
|
4295
|
-
|
|
4296
|
-
|
|
939
|
+
}), g ? (f.push(
|
|
940
|
+
E(
|
|
941
|
+
t,
|
|
4297
942
|
{
|
|
4298
|
-
name:
|
|
4299
|
-
is:
|
|
4300
|
-
type:
|
|
4301
|
-
defaultValue:
|
|
4302
|
-
showValid:
|
|
4303
|
-
props:
|
|
943
|
+
name: g,
|
|
944
|
+
is: h,
|
|
945
|
+
type: x,
|
|
946
|
+
defaultValue: I,
|
|
947
|
+
showValid: A,
|
|
948
|
+
props: S
|
|
4304
949
|
},
|
|
4305
|
-
|
|
950
|
+
O ?? a ?? w
|
|
4306
951
|
)
|
|
4307
|
-
),
|
|
4308
|
-
|
|
4309
|
-
|
|
4310
|
-
|
|
4311
|
-
|
|
952
|
+
), f) : h ? (f.push(
|
|
953
|
+
E(
|
|
954
|
+
h,
|
|
955
|
+
S,
|
|
956
|
+
O ?? a ?? w
|
|
4312
957
|
)
|
|
4313
|
-
),
|
|
958
|
+
), f) : (a && ("default" in a ? f.push(a.default(b.scope)) : f.push(a)), f);
|
|
4314
959
|
}, []);
|
|
4315
|
-
return
|
|
4316
|
-
|
|
4317
|
-
errors:
|
|
4318
|
-
formData:
|
|
4319
|
-
invalid:
|
|
4320
|
-
status:
|
|
4321
|
-
submit:
|
|
4322
|
-
validate:
|
|
4323
|
-
clear:
|
|
4324
|
-
reset:
|
|
960
|
+
return l.push(
|
|
961
|
+
r?.default?.({
|
|
962
|
+
errors: u?.errors.value,
|
|
963
|
+
formData: u?.formData.value,
|
|
964
|
+
invalid: u?.invalid.value,
|
|
965
|
+
status: u?.status.value,
|
|
966
|
+
submit: u?.submit,
|
|
967
|
+
validate: u?.validate,
|
|
968
|
+
clear: u?.clear,
|
|
969
|
+
reset: u?.reset
|
|
4325
970
|
})
|
|
4326
|
-
),
|
|
971
|
+
), l;
|
|
4327
972
|
};
|
|
4328
973
|
}
|
|
4329
974
|
});
|
|
4330
|
-
return
|
|
975
|
+
return n;
|
|
4331
976
|
}
|
|
4332
|
-
function
|
|
4333
|
-
const
|
|
4334
|
-
|
|
4335
|
-
|
|
4336
|
-
),
|
|
4337
|
-
t,
|
|
4338
|
-
s,
|
|
977
|
+
function T(e, t = {}) {
|
|
978
|
+
const n = Symbol("formInjectionKey"), b = Symbol("formWrapperInjectionKey"), r = Symbol("formFieldInjectionKey"), u = Symbol("formFieldsGroupInjectionKey"), o = Ne(
|
|
979
|
+
n,
|
|
980
|
+
b
|
|
981
|
+
), i = Fe(
|
|
4339
982
|
n,
|
|
4340
|
-
|
|
4341
|
-
|
|
4342
|
-
t
|
|
4343
|
-
|
|
4344
|
-
|
|
4345
|
-
|
|
4346
|
-
|
|
4347
|
-
|
|
4348
|
-
|
|
4349
|
-
|
|
4350
|
-
|
|
983
|
+
b,
|
|
984
|
+
r,
|
|
985
|
+
t
|
|
986
|
+
), l = ke(
|
|
987
|
+
n,
|
|
988
|
+
b,
|
|
989
|
+
u
|
|
990
|
+
), f = $e(n, i), d = /* @__PURE__ */ new Map(), {
|
|
991
|
+
clear: c,
|
|
992
|
+
errors: h,
|
|
993
|
+
formData: g,
|
|
994
|
+
ignoreUpdates: O,
|
|
995
|
+
invalid: v,
|
|
4351
996
|
readonly: m,
|
|
4352
|
-
reset:
|
|
4353
|
-
status:
|
|
4354
|
-
stopUpdatesWatch:
|
|
4355
|
-
submit:
|
|
4356
|
-
validate:
|
|
4357
|
-
VvForm:
|
|
4358
|
-
} =
|
|
997
|
+
reset: y,
|
|
998
|
+
status: x,
|
|
999
|
+
stopUpdatesWatch: I,
|
|
1000
|
+
submit: A,
|
|
1001
|
+
validate: w,
|
|
1002
|
+
VvForm: S
|
|
1003
|
+
} = Ae(e, n, t, f, d);
|
|
4359
1004
|
return {
|
|
4360
|
-
clear:
|
|
4361
|
-
errors:
|
|
4362
|
-
formData:
|
|
4363
|
-
formFieldInjectionKey:
|
|
4364
|
-
formInjectionKey:
|
|
4365
|
-
formWrapperInjectionKey:
|
|
4366
|
-
ignoreUpdates:
|
|
4367
|
-
invalid:
|
|
1005
|
+
clear: c,
|
|
1006
|
+
errors: h,
|
|
1007
|
+
formData: g,
|
|
1008
|
+
formFieldInjectionKey: r,
|
|
1009
|
+
formInjectionKey: n,
|
|
1010
|
+
formWrapperInjectionKey: b,
|
|
1011
|
+
ignoreUpdates: O,
|
|
1012
|
+
invalid: v,
|
|
4368
1013
|
readonly: m,
|
|
4369
|
-
reset:
|
|
4370
|
-
status:
|
|
4371
|
-
stopUpdatesWatch:
|
|
4372
|
-
submit:
|
|
4373
|
-
validate:
|
|
1014
|
+
reset: y,
|
|
1015
|
+
status: x,
|
|
1016
|
+
stopUpdatesWatch: I,
|
|
1017
|
+
submit: A,
|
|
1018
|
+
validate: w,
|
|
4374
1019
|
wrappers: d,
|
|
4375
|
-
VvForm:
|
|
4376
|
-
VvFormField:
|
|
4377
|
-
VvFormFieldsGroup:
|
|
4378
|
-
VvFormTemplate:
|
|
4379
|
-
VvFormWrapper:
|
|
1020
|
+
VvForm: S,
|
|
1021
|
+
VvFormField: i,
|
|
1022
|
+
VvFormFieldsGroup: l,
|
|
1023
|
+
VvFormTemplate: f,
|
|
1024
|
+
VvFormWrapper: o
|
|
4380
1025
|
};
|
|
4381
1026
|
}
|
|
4382
|
-
const
|
|
4383
|
-
function
|
|
4384
|
-
let
|
|
4385
|
-
return
|
|
4386
|
-
...
|
|
4387
|
-
install(
|
|
4388
|
-
|
|
1027
|
+
const le = Symbol("pluginInjectionKey");
|
|
1028
|
+
function Ue(e) {
|
|
1029
|
+
let t = {};
|
|
1030
|
+
return e.schema && (t = T(e.schema, e)), {
|
|
1031
|
+
...t,
|
|
1032
|
+
install(n, { global: b = !1 } = {}) {
|
|
1033
|
+
n.provide(le, e), b && (n.config.globalProperties.$vvForm = e, t?.VvForm && n.component("VvForm", t.VvForm), t?.VvFormWrapper && n.component("VvFormWrapper", t.VvFormWrapper), t?.VvFormField && n.component("VvFormField", t.VvFormField), t?.VvFormFieldsGroup && n.component("VvFormFieldsGroup", t.VvFormFieldsGroup), t?.VvFormTemplate && n.component("VvFormTemplate", t.VvFormTemplate));
|
|
4389
1034
|
}
|
|
4390
1035
|
};
|
|
4391
1036
|
}
|
|
4392
|
-
const
|
|
4393
|
-
function
|
|
4394
|
-
if (
|
|
4395
|
-
return
|
|
4396
|
-
if (!
|
|
4397
|
-
const
|
|
4398
|
-
return
|
|
1037
|
+
const M = /* @__PURE__ */ new Map();
|
|
1038
|
+
function Ce(e, t = {}) {
|
|
1039
|
+
if (t.scope && M.has(t.scope))
|
|
1040
|
+
return M.get(t.scope);
|
|
1041
|
+
if (!ve()) {
|
|
1042
|
+
const b = T(e, t);
|
|
1043
|
+
return t.scope && M.set(t.scope, b), b;
|
|
4399
1044
|
}
|
|
4400
|
-
const
|
|
4401
|
-
|
|
1045
|
+
const n = T(
|
|
1046
|
+
e,
|
|
4402
1047
|
{
|
|
4403
|
-
...
|
|
4404
|
-
...
|
|
1048
|
+
...B(le, {}),
|
|
1049
|
+
...t
|
|
4405
1050
|
}
|
|
4406
1051
|
);
|
|
4407
|
-
return
|
|
1052
|
+
return t.scope && M.set(t.scope, n), n;
|
|
4408
1053
|
}
|
|
4409
|
-
function
|
|
4410
|
-
return
|
|
1054
|
+
function Ke(e, t = {}) {
|
|
1055
|
+
return T(e, t);
|
|
4411
1056
|
}
|
|
4412
1057
|
export {
|
|
4413
|
-
|
|
4414
|
-
|
|
4415
|
-
|
|
4416
|
-
|
|
4417
|
-
|
|
4418
|
-
|
|
1058
|
+
V as FormFieldType,
|
|
1059
|
+
Ue as createForm,
|
|
1060
|
+
J as defaultObjectBySchema,
|
|
1061
|
+
Ke as formType,
|
|
1062
|
+
le as pluginInjectionKey,
|
|
1063
|
+
Ce as useForm
|
|
4419
1064
|
};
|