@volverjs/form-vue 1.0.0 → 1.1.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +33 -9
- package/dist/VvForm.d.ts +29 -30
- package/dist/VvFormField.d.ts +14 -15
- package/dist/VvFormFieldsGroup.d.ts +14 -15
- package/dist/VvFormTemplate.d.ts +3 -4
- package/dist/VvFormWrapper.d.ts +13 -14
- package/dist/index.d.ts +160 -160
- package/dist/index.es.js +3958 -600
- package/dist/index.umd.js +3 -1
- package/dist/types.d.ts +32 -24
- package/dist/utils.d.ts +11 -3
- package/package.json +7 -7
- package/src/VvForm.ts +24 -23
- package/src/VvFormField.ts +9 -8
- package/src/VvFormFieldsGroup.ts +13 -12
- package/src/VvFormTemplate.ts +10 -4
- package/src/VvFormWrapper.ts +8 -7
- package/src/index.ts +3 -8
- package/src/types.ts +57 -25
- package/src/utils.ts +200 -40
package/dist/index.es.js
CHANGED
|
@@ -1,102 +1,3460 @@
|
|
|
1
|
-
import { ref as
|
|
2
|
-
import { watchIgnorable as
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
import { ref as ce, computed as Z, readonly as H, defineComponent as _e, h as F, withModifiers as Ge, toRaw as X, watch as J, isProxy as Ct, onMounted as Re, provide as Ve, toRefs as Fe, useId as ft, inject as re, onBeforeUnmount as me, unref as le, resolveComponent as ee, defineAsyncComponent as Et, getCurrentInstance as At } from "vue";
|
|
2
|
+
import { watchIgnorable as Rt, throttleFilter as Vt } from "@vueuse/core";
|
|
3
|
+
var R = /* @__PURE__ */ ((r) => (r.text = "text", r.number = "number", r.email = "email", r.password = "password", r.tel = "tel", r.url = "url", r.search = "search", r.date = "date", r.time = "time", r.datetimeLocal = "datetime-local", r.month = "month", r.week = "week", r.color = "color", r.select = "select", r.checkbox = "checkbox", r.radio = "radio", r.textarea = "textarea", r.radioGroup = "radioGroup", r.checkboxGroup = "checkboxGroup", r.combobox = "combobox", r.custom = "custom", r))(R || {}), L = /* @__PURE__ */ ((r) => (r.invalid = "invalid", r.valid = "valid", r.submitting = "submitting", r.reset = "reset", r.updated = "updated", r.unknown = "unknown", r))(L || {}), V;
|
|
4
|
+
(function(r) {
|
|
5
|
+
r.assertEqual = (n) => {
|
|
6
|
+
};
|
|
7
|
+
function e(n) {
|
|
8
|
+
}
|
|
9
|
+
r.assertIs = e;
|
|
10
|
+
function t(n) {
|
|
11
|
+
throw new Error();
|
|
12
|
+
}
|
|
13
|
+
r.assertNever = t, r.arrayToEnum = (n) => {
|
|
14
|
+
const a = {};
|
|
15
|
+
for (const i of n)
|
|
16
|
+
a[i] = i;
|
|
17
|
+
return a;
|
|
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.");
|
|
17
332
|
return {
|
|
18
|
-
|
|
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
|
+
}), Object.defineProperty(r, "message", {
|
|
2709
|
+
get() {
|
|
2710
|
+
return JSON.stringify(e, lr, 2);
|
|
2711
|
+
},
|
|
2712
|
+
enumerable: !0
|
|
2713
|
+
// configurable: false,
|
|
2714
|
+
}), Object.defineProperty(r, "toString", {
|
|
2715
|
+
value: () => r.message,
|
|
2716
|
+
enumerable: !1
|
|
2717
|
+
});
|
|
2718
|
+
}, bt = vt("$ZodError", _t), xt = vt("$ZodError", _t, { Parent: Error });
|
|
2719
|
+
function kt(r, e) {
|
|
2720
|
+
const t = function(a) {
|
|
2721
|
+
return a.message;
|
|
2722
|
+
}, s = { _errors: [] }, n = (a) => {
|
|
2723
|
+
for (const i of a.issues)
|
|
2724
|
+
if (i.code === "invalid_union" && i.errors.length)
|
|
2725
|
+
i.errors.map((o) => n({ issues: o }));
|
|
2726
|
+
else if (i.code === "invalid_key")
|
|
2727
|
+
n({ issues: i.issues });
|
|
2728
|
+
else if (i.code === "invalid_element")
|
|
2729
|
+
n({ issues: i.issues });
|
|
2730
|
+
else if (i.path.length === 0)
|
|
2731
|
+
s._errors.push(t(i));
|
|
2732
|
+
else {
|
|
2733
|
+
let o = s, u = 0;
|
|
2734
|
+
for (; u < i.path.length; ) {
|
|
2735
|
+
const l = i.path[u];
|
|
2736
|
+
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++;
|
|
2737
|
+
}
|
|
2738
|
+
}
|
|
2739
|
+
};
|
|
2740
|
+
return n(r), s;
|
|
2741
|
+
}
|
|
2742
|
+
const dr = (r) => (e, t, s) => {
|
|
2743
|
+
const n = s ? { ...s, async: !1 } : { async: !1 }, a = e._zod.run({ value: t, issues: [] }, n);
|
|
2744
|
+
if (a instanceof Promise)
|
|
2745
|
+
throw new or();
|
|
2746
|
+
return a.issues.length ? {
|
|
2747
|
+
success: !1,
|
|
2748
|
+
error: new (r ?? bt)(a.issues.map((i) => gt(i, n, yt())))
|
|
2749
|
+
} : { success: !0, data: a.value };
|
|
2750
|
+
}, fr = /* @__PURE__ */ dr(xt), hr = (r) => async (e, t, s) => {
|
|
2751
|
+
const n = s ? Object.assign(s, { async: !0 }) : { async: !0 };
|
|
2752
|
+
let a = e._zod.run({ value: t, issues: [] }, n);
|
|
2753
|
+
return a instanceof Promise && (a = await a), a.issues.length ? {
|
|
2754
|
+
success: !1,
|
|
2755
|
+
error: new r(a.issues.map((i) => gt(i, n, yt())))
|
|
2756
|
+
} : { success: !0, data: a.value };
|
|
2757
|
+
}, pr = /* @__PURE__ */ hr(xt);
|
|
2758
|
+
class wt {
|
|
2759
|
+
constructor() {
|
|
2760
|
+
this._map = /* @__PURE__ */ new Map(), this._idmap = /* @__PURE__ */ new Map();
|
|
2761
|
+
}
|
|
2762
|
+
add(e, ...t) {
|
|
2763
|
+
const s = t[0];
|
|
2764
|
+
if (this._map.set(e, s), s && typeof s == "object" && "id" in s) {
|
|
2765
|
+
if (this._idmap.has(s.id))
|
|
2766
|
+
throw new Error(`ID ${s.id} already exists in the registry`);
|
|
2767
|
+
this._idmap.set(s.id, e);
|
|
2768
|
+
}
|
|
2769
|
+
return this;
|
|
2770
|
+
}
|
|
2771
|
+
clear() {
|
|
2772
|
+
return this._map = /* @__PURE__ */ new Map(), this._idmap = /* @__PURE__ */ new Map(), this;
|
|
2773
|
+
}
|
|
2774
|
+
remove(e) {
|
|
2775
|
+
const t = this._map.get(e);
|
|
2776
|
+
return t && typeof t == "object" && "id" in t && this._idmap.delete(t.id), this._map.delete(e), this;
|
|
2777
|
+
}
|
|
2778
|
+
get(e) {
|
|
2779
|
+
const t = e._zod.parent;
|
|
2780
|
+
if (t) {
|
|
2781
|
+
const s = { ...this.get(t) ?? {} };
|
|
2782
|
+
return delete s.id, { ...s, ...this._map.get(e) };
|
|
2783
|
+
}
|
|
2784
|
+
return this._map.get(e);
|
|
2785
|
+
}
|
|
2786
|
+
has(e) {
|
|
2787
|
+
return this._map.has(e);
|
|
2788
|
+
}
|
|
2789
|
+
}
|
|
2790
|
+
function mr() {
|
|
2791
|
+
return new wt();
|
|
2792
|
+
}
|
|
2793
|
+
const vr = /* @__PURE__ */ mr();
|
|
2794
|
+
class lt {
|
|
2795
|
+
constructor(e) {
|
|
2796
|
+
this.counter = 0, this.metadataRegistry = e?.metadata ?? vr, this.target = e?.target ?? "draft-2020-12", this.unrepresentable = e?.unrepresentable ?? "throw", this.override = e?.override ?? (() => {
|
|
2797
|
+
}), this.io = e?.io ?? "output", this.seen = /* @__PURE__ */ new Map();
|
|
2798
|
+
}
|
|
2799
|
+
process(e, t = { path: [], schemaPath: [] }) {
|
|
2800
|
+
var s;
|
|
2801
|
+
const n = e._zod.def, a = {
|
|
2802
|
+
guid: "uuid",
|
|
2803
|
+
url: "uri",
|
|
2804
|
+
datetime: "date-time",
|
|
2805
|
+
json_string: "json-string",
|
|
2806
|
+
regex: ""
|
|
2807
|
+
// do not set
|
|
2808
|
+
}, i = this.seen.get(e);
|
|
2809
|
+
if (i)
|
|
2810
|
+
return i.count++, t.schemaPath.includes(e) && (i.cycle = t.path), i.schema;
|
|
2811
|
+
const o = { schema: {}, count: 1, cycle: void 0, path: t.path };
|
|
2812
|
+
this.seen.set(e, o);
|
|
2813
|
+
const u = e._zod.toJSONSchema?.();
|
|
2814
|
+
if (u)
|
|
2815
|
+
o.schema = u;
|
|
2816
|
+
else {
|
|
2817
|
+
const f = {
|
|
2818
|
+
...t,
|
|
2819
|
+
schemaPath: [...t.schemaPath, e],
|
|
2820
|
+
path: t.path
|
|
2821
|
+
}, k = e._zod.parent;
|
|
2822
|
+
if (k)
|
|
2823
|
+
o.ref = k, this.process(k, f), this.seen.get(k).isParent = !0;
|
|
2824
|
+
else {
|
|
2825
|
+
const b = o.schema;
|
|
2826
|
+
switch (n.type) {
|
|
2827
|
+
case "string": {
|
|
2828
|
+
const c = b;
|
|
2829
|
+
c.type = "string";
|
|
2830
|
+
const { minimum: h, maximum: m, format: x, patterns: j, contentEncoding: N } = e._zod.bag;
|
|
2831
|
+
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) {
|
|
2832
|
+
const P = [...j];
|
|
2833
|
+
P.length === 1 ? c.pattern = P[0].source : P.length > 1 && (o.schema.allOf = [
|
|
2834
|
+
...P.map((E) => ({
|
|
2835
|
+
...this.target === "draft-7" ? { type: "string" } : {},
|
|
2836
|
+
pattern: E.source
|
|
2837
|
+
}))
|
|
2838
|
+
]);
|
|
2839
|
+
}
|
|
2840
|
+
break;
|
|
2841
|
+
}
|
|
2842
|
+
case "number": {
|
|
2843
|
+
const c = b, { minimum: h, maximum: m, format: x, multipleOf: j, exclusiveMaximum: N, exclusiveMinimum: P } = e._zod.bag;
|
|
2844
|
+
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);
|
|
2845
|
+
break;
|
|
2846
|
+
}
|
|
2847
|
+
case "boolean": {
|
|
2848
|
+
const c = b;
|
|
2849
|
+
c.type = "boolean";
|
|
2850
|
+
break;
|
|
2851
|
+
}
|
|
2852
|
+
case "bigint": {
|
|
2853
|
+
if (this.unrepresentable === "throw")
|
|
2854
|
+
throw new Error("BigInt cannot be represented in JSON Schema");
|
|
2855
|
+
break;
|
|
2856
|
+
}
|
|
2857
|
+
case "symbol": {
|
|
2858
|
+
if (this.unrepresentable === "throw")
|
|
2859
|
+
throw new Error("Symbols cannot be represented in JSON Schema");
|
|
2860
|
+
break;
|
|
2861
|
+
}
|
|
2862
|
+
case "null": {
|
|
2863
|
+
b.type = "null";
|
|
2864
|
+
break;
|
|
2865
|
+
}
|
|
2866
|
+
case "any":
|
|
2867
|
+
break;
|
|
2868
|
+
case "unknown":
|
|
2869
|
+
break;
|
|
2870
|
+
case "undefined": {
|
|
2871
|
+
if (this.unrepresentable === "throw")
|
|
2872
|
+
throw new Error("Undefined cannot be represented in JSON Schema");
|
|
2873
|
+
break;
|
|
2874
|
+
}
|
|
2875
|
+
case "void": {
|
|
2876
|
+
if (this.unrepresentable === "throw")
|
|
2877
|
+
throw new Error("Void cannot be represented in JSON Schema");
|
|
2878
|
+
break;
|
|
2879
|
+
}
|
|
2880
|
+
case "never": {
|
|
2881
|
+
b.not = {};
|
|
2882
|
+
break;
|
|
2883
|
+
}
|
|
2884
|
+
case "date": {
|
|
2885
|
+
if (this.unrepresentable === "throw")
|
|
2886
|
+
throw new Error("Date cannot be represented in JSON Schema");
|
|
2887
|
+
break;
|
|
2888
|
+
}
|
|
2889
|
+
case "array": {
|
|
2890
|
+
const c = b, { minimum: h, maximum: m } = e._zod.bag;
|
|
2891
|
+
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"] });
|
|
2892
|
+
break;
|
|
2893
|
+
}
|
|
2894
|
+
case "object": {
|
|
2895
|
+
const c = b;
|
|
2896
|
+
c.type = "object", c.properties = {};
|
|
2897
|
+
const h = n.shape;
|
|
2898
|
+
for (const j in h)
|
|
2899
|
+
c.properties[j] = this.process(h[j], {
|
|
2900
|
+
...f,
|
|
2901
|
+
path: [...f.path, "properties", j]
|
|
2902
|
+
});
|
|
2903
|
+
const m = new Set(Object.keys(h)), x = new Set([...m].filter((j) => {
|
|
2904
|
+
const N = n.shape[j]._zod;
|
|
2905
|
+
return this.io === "input" ? N.optin === void 0 : N.optout === void 0;
|
|
2906
|
+
}));
|
|
2907
|
+
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, {
|
|
2908
|
+
...f,
|
|
2909
|
+
path: [...f.path, "additionalProperties"]
|
|
2910
|
+
})) : this.io === "output" && (c.additionalProperties = !1);
|
|
2911
|
+
break;
|
|
2912
|
+
}
|
|
2913
|
+
case "union": {
|
|
2914
|
+
const c = b;
|
|
2915
|
+
c.anyOf = n.options.map((h, m) => this.process(h, {
|
|
2916
|
+
...f,
|
|
2917
|
+
path: [...f.path, "anyOf", m]
|
|
2918
|
+
}));
|
|
2919
|
+
break;
|
|
2920
|
+
}
|
|
2921
|
+
case "intersection": {
|
|
2922
|
+
const c = b, h = this.process(n.left, {
|
|
2923
|
+
...f,
|
|
2924
|
+
path: [...f.path, "allOf", 0]
|
|
2925
|
+
}), m = this.process(n.right, {
|
|
2926
|
+
...f,
|
|
2927
|
+
path: [...f.path, "allOf", 1]
|
|
2928
|
+
}), x = (N) => "allOf" in N && Object.keys(N).length === 1, j = [
|
|
2929
|
+
...x(h) ? h.allOf : [h],
|
|
2930
|
+
...x(m) ? m.allOf : [m]
|
|
2931
|
+
];
|
|
2932
|
+
c.allOf = j;
|
|
2933
|
+
break;
|
|
2934
|
+
}
|
|
2935
|
+
case "tuple": {
|
|
2936
|
+
const c = b;
|
|
2937
|
+
c.type = "array";
|
|
2938
|
+
const h = n.items.map((j, N) => this.process(j, { ...f, path: [...f.path, "prefixItems", N] }));
|
|
2939
|
+
if (this.target === "draft-2020-12" ? c.prefixItems = h : c.items = h, n.rest) {
|
|
2940
|
+
const j = this.process(n.rest, {
|
|
2941
|
+
...f,
|
|
2942
|
+
path: [...f.path, "items"]
|
|
2943
|
+
});
|
|
2944
|
+
this.target === "draft-2020-12" ? c.items = j : c.additionalItems = j;
|
|
2945
|
+
}
|
|
2946
|
+
n.rest && (c.items = this.process(n.rest, {
|
|
2947
|
+
...f,
|
|
2948
|
+
path: [...f.path, "items"]
|
|
2949
|
+
}));
|
|
2950
|
+
const { minimum: m, maximum: x } = e._zod.bag;
|
|
2951
|
+
typeof m == "number" && (c.minItems = m), typeof x == "number" && (c.maxItems = x);
|
|
2952
|
+
break;
|
|
2953
|
+
}
|
|
2954
|
+
case "record": {
|
|
2955
|
+
const c = b;
|
|
2956
|
+
c.type = "object", c.propertyNames = this.process(n.keyType, { ...f, path: [...f.path, "propertyNames"] }), c.additionalProperties = this.process(n.valueType, {
|
|
2957
|
+
...f,
|
|
2958
|
+
path: [...f.path, "additionalProperties"]
|
|
2959
|
+
});
|
|
2960
|
+
break;
|
|
2961
|
+
}
|
|
2962
|
+
case "map": {
|
|
2963
|
+
if (this.unrepresentable === "throw")
|
|
2964
|
+
throw new Error("Map cannot be represented in JSON Schema");
|
|
2965
|
+
break;
|
|
2966
|
+
}
|
|
2967
|
+
case "set": {
|
|
2968
|
+
if (this.unrepresentable === "throw")
|
|
2969
|
+
throw new Error("Set cannot be represented in JSON Schema");
|
|
2970
|
+
break;
|
|
2971
|
+
}
|
|
2972
|
+
case "enum": {
|
|
2973
|
+
const c = b, h = cr(n.entries);
|
|
2974
|
+
h.every((m) => typeof m == "number") && (c.type = "number"), h.every((m) => typeof m == "string") && (c.type = "string"), c.enum = h;
|
|
2975
|
+
break;
|
|
2976
|
+
}
|
|
2977
|
+
case "literal": {
|
|
2978
|
+
const c = b, h = [];
|
|
2979
|
+
for (const m of n.values)
|
|
2980
|
+
if (m === void 0) {
|
|
2981
|
+
if (this.unrepresentable === "throw")
|
|
2982
|
+
throw new Error("Literal `undefined` cannot be represented in JSON Schema");
|
|
2983
|
+
} else if (typeof m == "bigint") {
|
|
2984
|
+
if (this.unrepresentable === "throw")
|
|
2985
|
+
throw new Error("BigInt literals cannot be represented in JSON Schema");
|
|
2986
|
+
h.push(Number(m));
|
|
2987
|
+
} else
|
|
2988
|
+
h.push(m);
|
|
2989
|
+
if (h.length !== 0) if (h.length === 1) {
|
|
2990
|
+
const m = h[0];
|
|
2991
|
+
c.type = m === null ? "null" : typeof m, c.const = m;
|
|
2992
|
+
} else
|
|
2993
|
+
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;
|
|
2994
|
+
break;
|
|
2995
|
+
}
|
|
2996
|
+
case "file": {
|
|
2997
|
+
const c = b, h = {
|
|
2998
|
+
type: "string",
|
|
2999
|
+
format: "binary",
|
|
3000
|
+
contentEncoding: "binary"
|
|
3001
|
+
}, { minimum: m, maximum: x, mime: j } = e._zod.bag;
|
|
3002
|
+
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);
|
|
3003
|
+
break;
|
|
3004
|
+
}
|
|
3005
|
+
case "transform": {
|
|
3006
|
+
if (this.unrepresentable === "throw")
|
|
3007
|
+
throw new Error("Transforms cannot be represented in JSON Schema");
|
|
3008
|
+
break;
|
|
3009
|
+
}
|
|
3010
|
+
case "nullable": {
|
|
3011
|
+
const c = this.process(n.innerType, f);
|
|
3012
|
+
b.anyOf = [c, { type: "null" }];
|
|
3013
|
+
break;
|
|
3014
|
+
}
|
|
3015
|
+
case "nonoptional": {
|
|
3016
|
+
this.process(n.innerType, f), o.ref = n.innerType;
|
|
3017
|
+
break;
|
|
3018
|
+
}
|
|
3019
|
+
case "success": {
|
|
3020
|
+
const c = b;
|
|
3021
|
+
c.type = "boolean";
|
|
3022
|
+
break;
|
|
3023
|
+
}
|
|
3024
|
+
case "default": {
|
|
3025
|
+
this.process(n.innerType, f), o.ref = n.innerType, b.default = JSON.parse(JSON.stringify(n.defaultValue));
|
|
3026
|
+
break;
|
|
3027
|
+
}
|
|
3028
|
+
case "prefault": {
|
|
3029
|
+
this.process(n.innerType, f), o.ref = n.innerType, this.io === "input" && (b._prefault = JSON.parse(JSON.stringify(n.defaultValue)));
|
|
3030
|
+
break;
|
|
3031
|
+
}
|
|
3032
|
+
case "catch": {
|
|
3033
|
+
this.process(n.innerType, f), o.ref = n.innerType;
|
|
3034
|
+
let c;
|
|
3035
|
+
try {
|
|
3036
|
+
c = n.catchValue(void 0);
|
|
3037
|
+
} catch {
|
|
3038
|
+
throw new Error("Dynamic catch values are not supported in JSON Schema");
|
|
3039
|
+
}
|
|
3040
|
+
b.default = c;
|
|
3041
|
+
break;
|
|
3042
|
+
}
|
|
3043
|
+
case "nan": {
|
|
3044
|
+
if (this.unrepresentable === "throw")
|
|
3045
|
+
throw new Error("NaN cannot be represented in JSON Schema");
|
|
3046
|
+
break;
|
|
3047
|
+
}
|
|
3048
|
+
case "template_literal": {
|
|
3049
|
+
const c = b, h = e._zod.pattern;
|
|
3050
|
+
if (!h)
|
|
3051
|
+
throw new Error("Pattern not found in template literal");
|
|
3052
|
+
c.type = "string", c.pattern = h.source;
|
|
3053
|
+
break;
|
|
3054
|
+
}
|
|
3055
|
+
case "pipe": {
|
|
3056
|
+
const c = this.io === "input" ? n.in._zod.def.type === "transform" ? n.out : n.in : n.out;
|
|
3057
|
+
this.process(c, f), o.ref = c;
|
|
3058
|
+
break;
|
|
3059
|
+
}
|
|
3060
|
+
case "readonly": {
|
|
3061
|
+
this.process(n.innerType, f), o.ref = n.innerType, b.readOnly = !0;
|
|
3062
|
+
break;
|
|
3063
|
+
}
|
|
3064
|
+
// passthrough types
|
|
3065
|
+
case "promise": {
|
|
3066
|
+
this.process(n.innerType, f), o.ref = n.innerType;
|
|
3067
|
+
break;
|
|
3068
|
+
}
|
|
3069
|
+
case "optional": {
|
|
3070
|
+
this.process(n.innerType, f), o.ref = n.innerType;
|
|
3071
|
+
break;
|
|
3072
|
+
}
|
|
3073
|
+
case "lazy": {
|
|
3074
|
+
const c = e._zod.innerType;
|
|
3075
|
+
this.process(c, f), o.ref = c;
|
|
3076
|
+
break;
|
|
3077
|
+
}
|
|
3078
|
+
case "custom": {
|
|
3079
|
+
if (this.unrepresentable === "throw")
|
|
3080
|
+
throw new Error("Custom types cannot be represented in JSON Schema");
|
|
3081
|
+
break;
|
|
3082
|
+
}
|
|
3083
|
+
}
|
|
3084
|
+
}
|
|
3085
|
+
}
|
|
3086
|
+
const l = this.metadataRegistry.get(e);
|
|
3087
|
+
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;
|
|
3088
|
+
}
|
|
3089
|
+
emit(e, t) {
|
|
3090
|
+
const s = {
|
|
3091
|
+
cycles: t?.cycles ?? "ref",
|
|
3092
|
+
reused: t?.reused ?? "inline",
|
|
3093
|
+
// unrepresentable: _params?.unrepresentable ?? "throw",
|
|
3094
|
+
// uri: _params?.uri ?? ((id) => `${id}`),
|
|
3095
|
+
external: t?.external ?? void 0
|
|
3096
|
+
}, n = this.seen.get(e);
|
|
3097
|
+
if (!n)
|
|
3098
|
+
throw new Error("Unprocessed schema. This is a bug in Zod.");
|
|
3099
|
+
const a = (d) => {
|
|
3100
|
+
const f = this.target === "draft-2020-12" ? "$defs" : "definitions";
|
|
3101
|
+
if (s.external) {
|
|
3102
|
+
const h = s.external.registry.get(d[0])?.id, m = s.external.uri ?? ((j) => j);
|
|
3103
|
+
if (h)
|
|
3104
|
+
return { ref: m(h) };
|
|
3105
|
+
const x = d[1].defId ?? d[1].schema.id ?? `schema${this.counter++}`;
|
|
3106
|
+
return d[1].defId = x, { defId: x, ref: `${m("__shared")}#/${f}/${x}` };
|
|
3107
|
+
}
|
|
3108
|
+
if (d[1] === n)
|
|
3109
|
+
return { ref: "#" };
|
|
3110
|
+
const b = `#/${f}/`, c = d[1].schema.id ?? `__schema${this.counter++}`;
|
|
3111
|
+
return { defId: c, ref: b + c };
|
|
3112
|
+
}, i = (d) => {
|
|
3113
|
+
if (d[1].schema.$ref)
|
|
3114
|
+
return;
|
|
3115
|
+
const f = d[1], { ref: k, defId: b } = a(d);
|
|
3116
|
+
f.def = { ...f.schema }, b && (f.defId = b);
|
|
3117
|
+
const c = f.schema;
|
|
3118
|
+
for (const h in c)
|
|
3119
|
+
delete c[h];
|
|
3120
|
+
c.$ref = k;
|
|
3121
|
+
};
|
|
3122
|
+
if (s.cycles === "throw")
|
|
3123
|
+
for (const d of this.seen.entries()) {
|
|
3124
|
+
const f = d[1];
|
|
3125
|
+
if (f.cycle)
|
|
3126
|
+
throw new Error(`Cycle detected: #/${f.cycle?.join("/")}/<root>
|
|
3127
|
+
|
|
3128
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`);
|
|
3129
|
+
}
|
|
3130
|
+
for (const d of this.seen.entries()) {
|
|
3131
|
+
const f = d[1];
|
|
3132
|
+
if (e === d[0]) {
|
|
3133
|
+
i(d);
|
|
3134
|
+
continue;
|
|
3135
|
+
}
|
|
3136
|
+
if (s.external) {
|
|
3137
|
+
const b = s.external.registry.get(d[0])?.id;
|
|
3138
|
+
if (e !== d[0] && b) {
|
|
3139
|
+
i(d);
|
|
3140
|
+
continue;
|
|
3141
|
+
}
|
|
3142
|
+
}
|
|
3143
|
+
if (this.metadataRegistry.get(d[0])?.id) {
|
|
3144
|
+
i(d);
|
|
3145
|
+
continue;
|
|
3146
|
+
}
|
|
3147
|
+
if (f.cycle) {
|
|
3148
|
+
i(d);
|
|
3149
|
+
continue;
|
|
3150
|
+
}
|
|
3151
|
+
if (f.count > 1 && s.reused === "ref") {
|
|
3152
|
+
i(d);
|
|
3153
|
+
continue;
|
|
3154
|
+
}
|
|
3155
|
+
}
|
|
3156
|
+
const o = (d, f) => {
|
|
3157
|
+
const k = this.seen.get(d), b = k.def ?? k.schema, c = { ...b };
|
|
3158
|
+
if (k.ref === null)
|
|
3159
|
+
return;
|
|
3160
|
+
const h = k.ref;
|
|
3161
|
+
if (k.ref = null, h) {
|
|
3162
|
+
o(h, f);
|
|
3163
|
+
const m = this.seen.get(h).schema;
|
|
3164
|
+
m.$ref && f.target === "draft-7" ? (b.allOf = b.allOf ?? [], b.allOf.push(m)) : (Object.assign(b, m), Object.assign(b, c));
|
|
3165
|
+
}
|
|
3166
|
+
k.isParent || this.override({
|
|
3167
|
+
zodSchema: d,
|
|
3168
|
+
jsonSchema: b,
|
|
3169
|
+
path: k.path ?? []
|
|
3170
|
+
});
|
|
3171
|
+
};
|
|
3172
|
+
for (const d of [...this.seen.entries()].reverse())
|
|
3173
|
+
o(d[0], { target: this.target });
|
|
3174
|
+
const u = {};
|
|
3175
|
+
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) {
|
|
3176
|
+
const d = s.external.registry.get(e)?.id;
|
|
3177
|
+
if (!d)
|
|
3178
|
+
throw new Error("Schema is missing an `id` property");
|
|
3179
|
+
u.$id = s.external.uri(d);
|
|
3180
|
+
}
|
|
3181
|
+
Object.assign(u, n.def);
|
|
3182
|
+
const l = s.external?.defs ?? {};
|
|
3183
|
+
for (const d of this.seen.entries()) {
|
|
3184
|
+
const f = d[1];
|
|
3185
|
+
f.def && f.defId && (l[f.defId] = f.def);
|
|
3186
|
+
}
|
|
3187
|
+
s.external || Object.keys(l).length > 0 && (this.target === "draft-2020-12" ? u.$defs = l : u.definitions = l);
|
|
3188
|
+
try {
|
|
3189
|
+
return JSON.parse(JSON.stringify(u));
|
|
3190
|
+
} catch {
|
|
3191
|
+
throw new Error("Error converting schema to JSON.");
|
|
3192
|
+
}
|
|
3193
|
+
}
|
|
3194
|
+
}
|
|
3195
|
+
function yr(r, e) {
|
|
3196
|
+
if (r instanceof wt) {
|
|
3197
|
+
const s = new lt(e), n = {};
|
|
3198
|
+
for (const o of r._idmap.entries()) {
|
|
3199
|
+
const [u, l] = o;
|
|
3200
|
+
s.process(l);
|
|
3201
|
+
}
|
|
3202
|
+
const a = {}, i = {
|
|
3203
|
+
registry: r,
|
|
3204
|
+
uri: e?.uri,
|
|
3205
|
+
defs: n
|
|
3206
|
+
};
|
|
3207
|
+
for (const o of r._idmap.entries()) {
|
|
3208
|
+
const [u, l] = o;
|
|
3209
|
+
a[u] = s.emit(l, {
|
|
3210
|
+
...e,
|
|
3211
|
+
external: i
|
|
3212
|
+
});
|
|
3213
|
+
}
|
|
3214
|
+
if (Object.keys(n).length > 0) {
|
|
3215
|
+
const o = s.target === "draft-2020-12" ? "$defs" : "definitions";
|
|
3216
|
+
a.__shared = {
|
|
3217
|
+
[o]: n
|
|
3218
|
+
};
|
|
3219
|
+
}
|
|
3220
|
+
return { schemas: a };
|
|
3221
|
+
}
|
|
3222
|
+
const t = new lt(e);
|
|
3223
|
+
return t.process(r), t.emit(r, e);
|
|
3224
|
+
}
|
|
3225
|
+
function z(r, e) {
|
|
3226
|
+
const t = e ?? { seen: /* @__PURE__ */ new Set() };
|
|
3227
|
+
if (t.seen.has(r))
|
|
3228
|
+
return !1;
|
|
3229
|
+
t.seen.add(r);
|
|
3230
|
+
const n = r._zod.def;
|
|
3231
|
+
switch (n.type) {
|
|
3232
|
+
case "string":
|
|
3233
|
+
case "number":
|
|
3234
|
+
case "bigint":
|
|
3235
|
+
case "boolean":
|
|
3236
|
+
case "date":
|
|
3237
|
+
case "symbol":
|
|
3238
|
+
case "undefined":
|
|
3239
|
+
case "null":
|
|
3240
|
+
case "any":
|
|
3241
|
+
case "unknown":
|
|
3242
|
+
case "never":
|
|
3243
|
+
case "void":
|
|
3244
|
+
case "literal":
|
|
3245
|
+
case "enum":
|
|
3246
|
+
case "nan":
|
|
3247
|
+
case "file":
|
|
3248
|
+
case "template_literal":
|
|
3249
|
+
return !1;
|
|
3250
|
+
case "array":
|
|
3251
|
+
return z(n.element, t);
|
|
3252
|
+
case "object": {
|
|
3253
|
+
for (const a in n.shape)
|
|
3254
|
+
if (z(n.shape[a], t))
|
|
3255
|
+
return !0;
|
|
3256
|
+
return !1;
|
|
3257
|
+
}
|
|
3258
|
+
case "union": {
|
|
3259
|
+
for (const a of n.options)
|
|
3260
|
+
if (z(a, t))
|
|
3261
|
+
return !0;
|
|
3262
|
+
return !1;
|
|
3263
|
+
}
|
|
3264
|
+
case "intersection":
|
|
3265
|
+
return z(n.left, t) || z(n.right, t);
|
|
3266
|
+
case "tuple": {
|
|
3267
|
+
for (const a of n.items)
|
|
3268
|
+
if (z(a, t))
|
|
3269
|
+
return !0;
|
|
3270
|
+
return !!(n.rest && z(n.rest, t));
|
|
3271
|
+
}
|
|
3272
|
+
case "record":
|
|
3273
|
+
return z(n.keyType, t) || z(n.valueType, t);
|
|
3274
|
+
case "map":
|
|
3275
|
+
return z(n.keyType, t) || z(n.valueType, t);
|
|
3276
|
+
case "set":
|
|
3277
|
+
return z(n.valueType, t);
|
|
3278
|
+
// inner types
|
|
3279
|
+
case "promise":
|
|
3280
|
+
case "optional":
|
|
3281
|
+
case "nonoptional":
|
|
3282
|
+
case "nullable":
|
|
3283
|
+
case "readonly":
|
|
3284
|
+
return z(n.innerType, t);
|
|
3285
|
+
case "lazy":
|
|
3286
|
+
return z(n.getter(), t);
|
|
3287
|
+
case "default":
|
|
3288
|
+
return z(n.innerType, t);
|
|
3289
|
+
case "prefault":
|
|
3290
|
+
return z(n.innerType, t);
|
|
3291
|
+
case "custom":
|
|
3292
|
+
return !1;
|
|
3293
|
+
case "transform":
|
|
3294
|
+
return !0;
|
|
3295
|
+
case "pipe":
|
|
3296
|
+
return z(n.in, t) || z(n.out, t);
|
|
3297
|
+
case "success":
|
|
3298
|
+
return !1;
|
|
3299
|
+
case "catch":
|
|
3300
|
+
return !1;
|
|
3301
|
+
}
|
|
3302
|
+
throw new Error(`Unknown schema type: ${n.type}`);
|
|
3303
|
+
}
|
|
3304
|
+
const xe = (r) => {
|
|
3305
|
+
let e = r;
|
|
3306
|
+
for (; e instanceof se; )
|
|
3307
|
+
e = e.innerType();
|
|
3308
|
+
return e instanceof G && (e = e._def.innerType), e;
|
|
3309
|
+
}, gr = (r) => {
|
|
3310
|
+
let e = r;
|
|
3311
|
+
for (; e instanceof se; )
|
|
3312
|
+
e = e.innerType();
|
|
3313
|
+
return e instanceof G || e instanceof ae;
|
|
3314
|
+
};
|
|
3315
|
+
function _r(r) {
|
|
3316
|
+
return Array.isArray(r) ? "array" : r === null ? "null" : typeof r;
|
|
3317
|
+
}
|
|
3318
|
+
function br(r, e) {
|
|
3319
|
+
const t = _r(r);
|
|
3320
|
+
return e.type ? e.type === t || e.type === "integer" && t === "number" && Number.isInteger(r) : !0;
|
|
3321
|
+
}
|
|
3322
|
+
function ue(r, e) {
|
|
3323
|
+
if (r.anyOf && Array.isArray(r.anyOf)) {
|
|
3324
|
+
if (e !== void 0) {
|
|
3325
|
+
for (const i of r.anyOf)
|
|
3326
|
+
if (br(e, i))
|
|
3327
|
+
return ue(i, e);
|
|
3328
|
+
for (const i of r.anyOf) {
|
|
3329
|
+
const o = i;
|
|
3330
|
+
if (!o.type || o.type === "object")
|
|
3331
|
+
return ue(o, e);
|
|
3332
|
+
}
|
|
3333
|
+
}
|
|
3334
|
+
return ue(r.anyOf[0], e);
|
|
3335
|
+
}
|
|
3336
|
+
if (r.type !== "object" || !r.properties)
|
|
3337
|
+
switch (r.type) {
|
|
3338
|
+
case "string":
|
|
3339
|
+
return typeof e == "string" ? e : r.default;
|
|
3340
|
+
case "number":
|
|
3341
|
+
case "integer":
|
|
3342
|
+
return typeof e == "number" ? e : r.default;
|
|
3343
|
+
case "boolean":
|
|
3344
|
+
return typeof e == "boolean" ? e : r.default;
|
|
3345
|
+
case "null":
|
|
3346
|
+
return e === null ? e : r.default;
|
|
3347
|
+
case "array":
|
|
3348
|
+
return Array.isArray(e) && r.items ? e.map((i) => ue(r.items, i)) : r.default;
|
|
3349
|
+
default:
|
|
3350
|
+
return r.default;
|
|
3351
|
+
}
|
|
3352
|
+
const t = r.properties, n = e && typeof e == "object" && !Array.isArray(e) ? e : void 0, a = {};
|
|
3353
|
+
for (const i in t) {
|
|
3354
|
+
const o = n?.[i];
|
|
3355
|
+
a[i] = ue(t[i], o);
|
|
3356
|
+
}
|
|
3357
|
+
if (n && r.additionalProperties !== !1) {
|
|
3358
|
+
const i = new Set(Object.keys(t));
|
|
3359
|
+
for (const [o, u] of Object.entries(n))
|
|
3360
|
+
i.has(o) || (a[o] = u);
|
|
3361
|
+
}
|
|
3362
|
+
return a;
|
|
3363
|
+
}
|
|
3364
|
+
const Ze = (r) => "_zod" in r;
|
|
3365
|
+
function we(r, e = {}) {
|
|
3366
|
+
if (Ze(r)) {
|
|
3367
|
+
const n = yr(r);
|
|
3368
|
+
if (n.type !== "object" || !n.properties)
|
|
3369
|
+
return e;
|
|
3370
|
+
const a = fr(r, e);
|
|
3371
|
+
return ue(n, a.success ? a.data : e);
|
|
3372
|
+
}
|
|
3373
|
+
const t = xe(r);
|
|
3374
|
+
return t instanceof $ ? {
|
|
3375
|
+
...(t instanceof $ ? t._def.unknownKeys === "passthrough" : !1) ? e : {},
|
|
19
3376
|
...Object.fromEntries(
|
|
20
|
-
Object.entries(
|
|
21
|
-
([
|
|
22
|
-
const
|
|
23
|
-
let
|
|
24
|
-
if (
|
|
25
|
-
return [
|
|
26
|
-
if (
|
|
27
|
-
return [
|
|
28
|
-
if (
|
|
29
|
-
const
|
|
30
|
-
if (
|
|
31
|
-
return [
|
|
3377
|
+
("shape" in t ? Object.entries(t.shape) : []).map(
|
|
3378
|
+
([n, a]) => {
|
|
3379
|
+
const i = e[n], o = gr(a);
|
|
3380
|
+
let u = xe(a), l;
|
|
3381
|
+
if (u instanceof Ee && (l = u._def.defaultValue(), u = u._def.innerType), i === null && u instanceof ae)
|
|
3382
|
+
return [n, i];
|
|
3383
|
+
if (i == null && o)
|
|
3384
|
+
return [n, l];
|
|
3385
|
+
if (u instanceof I) {
|
|
3386
|
+
const d = a.safeParse(i);
|
|
3387
|
+
if (d.success)
|
|
3388
|
+
return [n, d.data ?? l];
|
|
32
3389
|
}
|
|
33
|
-
if (
|
|
34
|
-
const
|
|
35
|
-
if (
|
|
3390
|
+
if (u instanceof W && Array.isArray(i) && i.length) {
|
|
3391
|
+
const d = xe(u._def.type);
|
|
3392
|
+
if (d instanceof $)
|
|
36
3393
|
return [
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
(
|
|
40
|
-
|
|
41
|
-
|
|
3394
|
+
n,
|
|
3395
|
+
i.map(
|
|
3396
|
+
(f) => we(
|
|
3397
|
+
d,
|
|
3398
|
+
f && typeof f == "object" ? f : void 0
|
|
42
3399
|
)
|
|
43
3400
|
)
|
|
44
3401
|
];
|
|
45
3402
|
}
|
|
46
|
-
if (
|
|
47
|
-
const
|
|
48
|
-
if (
|
|
49
|
-
return [
|
|
3403
|
+
if (u instanceof Ie && i) {
|
|
3404
|
+
const d = xe(u._def.valueType);
|
|
3405
|
+
if (d instanceof $)
|
|
3406
|
+
return [n, Object.keys(i).reduce((f, k) => (f[k] = we(d, i[k]), f), {})];
|
|
50
3407
|
}
|
|
51
|
-
return
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
3408
|
+
return u instanceof $ ? [
|
|
3409
|
+
n,
|
|
3410
|
+
we(
|
|
3411
|
+
u,
|
|
3412
|
+
i && typeof i == "object" ? i : l
|
|
56
3413
|
)
|
|
57
|
-
] : [
|
|
3414
|
+
] : [n, l];
|
|
58
3415
|
}
|
|
59
3416
|
)
|
|
60
3417
|
)
|
|
61
|
-
};
|
|
3418
|
+
} : e;
|
|
62
3419
|
}
|
|
63
|
-
|
|
64
|
-
|
|
3420
|
+
const xr = (r, e) => Ze(r) ? pr(r, e) : r.safeParseAsync(e), kr = (r, e) => Ze(r) ? kt(e) : e.format(), wr = (r, e) => Ze(r) ? kt(new bt(e)) : new q(e).format();
|
|
3421
|
+
function Or(r, e, t, s, n) {
|
|
3422
|
+
const a = ce(), i = ce(), o = Z(() => i.value === L.invalid), u = ce(), l = ce(!1);
|
|
65
3423
|
let d;
|
|
66
|
-
const
|
|
67
|
-
const
|
|
68
|
-
if (
|
|
69
|
-
const
|
|
70
|
-
return new
|
|
3424
|
+
const f = (E) => {
|
|
3425
|
+
const D = we(r, E);
|
|
3426
|
+
if (t?.class) {
|
|
3427
|
+
const g = t.class;
|
|
3428
|
+
return new g(D);
|
|
71
3429
|
}
|
|
72
|
-
return
|
|
73
|
-
},
|
|
74
|
-
if (d =
|
|
3430
|
+
return D;
|
|
3431
|
+
}, k = async (E = u.value, D) => {
|
|
3432
|
+
if (d = D?.fields, l.value)
|
|
75
3433
|
return !0;
|
|
76
|
-
const
|
|
77
|
-
if (!
|
|
78
|
-
if (
|
|
79
|
-
return
|
|
80
|
-
const
|
|
81
|
-
(
|
|
3434
|
+
const g = await xr(r, E);
|
|
3435
|
+
if (!g.success) {
|
|
3436
|
+
if (i.value = L.invalid, !d?.size)
|
|
3437
|
+
return a.value = kr(r, g.error), !1;
|
|
3438
|
+
const A = g.error.issues.filter(
|
|
3439
|
+
(Q) => d?.has(Q.path.join("."))
|
|
82
3440
|
);
|
|
83
|
-
return
|
|
3441
|
+
return A.length ? (a.value = wr(r, A), !1) : (a.value = void 0, !0);
|
|
84
3442
|
}
|
|
85
|
-
return
|
|
86
|
-
},
|
|
87
|
-
|
|
88
|
-
},
|
|
89
|
-
|
|
90
|
-
},
|
|
91
|
-
|
|
3443
|
+
return a.value = void 0, i.value = L.valid, u.value = f(g.data), !0;
|
|
3444
|
+
}, b = () => {
|
|
3445
|
+
a.value = void 0, i.value = void 0, d = void 0;
|
|
3446
|
+
}, c = () => {
|
|
3447
|
+
u.value = f(), b(), i.value = L.reset;
|
|
3448
|
+
}, h = async (E) => l.value || !await k(void 0, E) ? !1 : (i.value = L.submitting, !0), { ignoreUpdates: m, stop: x } = Rt(
|
|
3449
|
+
u,
|
|
92
3450
|
() => {
|
|
93
|
-
|
|
3451
|
+
i.value = L.updated;
|
|
94
3452
|
},
|
|
95
3453
|
{
|
|
96
3454
|
deep: !0,
|
|
97
|
-
eventFilter:
|
|
3455
|
+
eventFilter: Vt(t?.updateThrottle ?? 500)
|
|
98
3456
|
}
|
|
99
|
-
),
|
|
3457
|
+
), j = H(a), N = H(i), P = _e({
|
|
100
3458
|
name: "VvForm",
|
|
101
3459
|
props: {
|
|
102
3460
|
continuousValidation: {
|
|
@@ -109,7 +3467,7 @@ function je(e, i, a, v, n) {
|
|
|
109
3467
|
},
|
|
110
3468
|
readonly: {
|
|
111
3469
|
type: Boolean,
|
|
112
|
-
default:
|
|
3470
|
+
default: t?.readonly
|
|
113
3471
|
},
|
|
114
3472
|
tag: {
|
|
115
3473
|
type: String,
|
|
@@ -150,215 +3508,215 @@ function je(e, i, a, v, n) {
|
|
|
150
3508
|
"reset"
|
|
151
3509
|
],
|
|
152
3510
|
slots: Object,
|
|
153
|
-
setup(
|
|
154
|
-
return
|
|
155
|
-
() =>
|
|
156
|
-
(
|
|
157
|
-
if (
|
|
158
|
-
const
|
|
159
|
-
if (JSON.stringify(
|
|
3511
|
+
setup(E, { emit: D }) {
|
|
3512
|
+
return u.value = f(X(E.modelValue)), J(
|
|
3513
|
+
() => E.modelValue,
|
|
3514
|
+
(g) => {
|
|
3515
|
+
if (g) {
|
|
3516
|
+
const A = Ct(g) ? X(g) : g;
|
|
3517
|
+
if (JSON.stringify(A) === JSON.stringify(X(u.value)))
|
|
160
3518
|
return;
|
|
161
|
-
|
|
3519
|
+
u.value = typeof A?.clone == "function" ? A.clone() : JSON.parse(JSON.stringify(A));
|
|
162
3520
|
}
|
|
163
3521
|
},
|
|
164
3522
|
{ deep: !0 }
|
|
165
|
-
),
|
|
166
|
-
if (
|
|
167
|
-
const
|
|
168
|
-
|
|
169
|
-
|
|
3523
|
+
), J(i, async (g) => {
|
|
3524
|
+
if (g === L.invalid) {
|
|
3525
|
+
const A = X(a.value);
|
|
3526
|
+
D("invalid", A), t?.onInvalid?.(
|
|
3527
|
+
A
|
|
170
3528
|
);
|
|
171
3529
|
return;
|
|
172
3530
|
}
|
|
173
|
-
if (
|
|
174
|
-
const
|
|
175
|
-
|
|
3531
|
+
if (g === L.valid) {
|
|
3532
|
+
const A = X(u.value);
|
|
3533
|
+
D("valid", A), t?.onValid?.(A), D("update:modelValue", A), t?.onUpdate?.(A);
|
|
176
3534
|
return;
|
|
177
3535
|
}
|
|
178
|
-
if (
|
|
179
|
-
const
|
|
180
|
-
|
|
3536
|
+
if (g === L.submitting) {
|
|
3537
|
+
const A = X(u.value);
|
|
3538
|
+
D("submit", A), t?.onSubmit?.(A);
|
|
181
3539
|
return;
|
|
182
3540
|
}
|
|
183
|
-
if (
|
|
184
|
-
const
|
|
185
|
-
|
|
3541
|
+
if (g === L.reset) {
|
|
3542
|
+
const A = X(u.value);
|
|
3543
|
+
D("reset", A), t?.onReset?.(A);
|
|
186
3544
|
return;
|
|
187
3545
|
}
|
|
188
|
-
if (
|
|
189
|
-
if ((
|
|
190
|
-
superRefine:
|
|
191
|
-
fields: d ?? new Set(
|
|
192
|
-
}), !
|
|
193
|
-
const
|
|
194
|
-
|
|
3546
|
+
if (g === L.updated) {
|
|
3547
|
+
if ((a.value || t?.continuousValidation || E.continuousValidation) && await k(void 0, {
|
|
3548
|
+
superRefine: E.superRefine,
|
|
3549
|
+
fields: d ?? new Set(E.validateFields)
|
|
3550
|
+
}), !u.value || !E.modelValue || JSON.stringify(u.value) !== JSON.stringify(E.modelValue)) {
|
|
3551
|
+
const A = X(u.value);
|
|
3552
|
+
D("update:modelValue", A), t?.onUpdate?.(A);
|
|
195
3553
|
}
|
|
196
|
-
|
|
3554
|
+
i.value === L.updated && (i.value = L.unknown);
|
|
197
3555
|
}
|
|
198
|
-
}),
|
|
199
|
-
|
|
200
|
-
}),
|
|
201
|
-
() =>
|
|
202
|
-
(
|
|
203
|
-
|
|
3556
|
+
}), Re(() => {
|
|
3557
|
+
E.readonly !== void 0 && (l.value = E.readonly);
|
|
3558
|
+
}), J(
|
|
3559
|
+
() => E.readonly,
|
|
3560
|
+
(g) => {
|
|
3561
|
+
l.value = g;
|
|
204
3562
|
}
|
|
205
|
-
),
|
|
206
|
-
|
|
207
|
-
}),
|
|
208
|
-
clear:
|
|
209
|
-
errors:
|
|
210
|
-
formData:
|
|
211
|
-
ignoreUpdates:
|
|
3563
|
+
), J(l, (g) => {
|
|
3564
|
+
g !== E.readonly && D("update:readonly", l.value);
|
|
3565
|
+
}), Ve(e, {
|
|
3566
|
+
clear: b,
|
|
3567
|
+
errors: j,
|
|
3568
|
+
formData: u,
|
|
3569
|
+
ignoreUpdates: m,
|
|
212
3570
|
invalid: o,
|
|
213
|
-
readonly:
|
|
214
|
-
reset:
|
|
215
|
-
status:
|
|
216
|
-
stopUpdatesWatch:
|
|
217
|
-
submit:
|
|
218
|
-
validate:
|
|
3571
|
+
readonly: l,
|
|
3572
|
+
reset: c,
|
|
3573
|
+
status: N,
|
|
3574
|
+
stopUpdatesWatch: x,
|
|
3575
|
+
submit: h,
|
|
3576
|
+
validate: k,
|
|
219
3577
|
wrappers: n
|
|
220
3578
|
}), {
|
|
221
|
-
clear:
|
|
222
|
-
errors:
|
|
223
|
-
formData:
|
|
224
|
-
ignoreUpdates:
|
|
3579
|
+
clear: b,
|
|
3580
|
+
errors: j,
|
|
3581
|
+
formData: u,
|
|
3582
|
+
ignoreUpdates: m,
|
|
225
3583
|
invalid: o,
|
|
226
|
-
isReadonly:
|
|
227
|
-
reset:
|
|
228
|
-
status:
|
|
229
|
-
stopUpdatesWatch:
|
|
230
|
-
submit: () =>
|
|
231
|
-
superRefine:
|
|
232
|
-
fields: new Set(
|
|
3584
|
+
isReadonly: l,
|
|
3585
|
+
reset: c,
|
|
3586
|
+
status: N,
|
|
3587
|
+
stopUpdatesWatch: x,
|
|
3588
|
+
submit: () => h({
|
|
3589
|
+
superRefine: E.superRefine,
|
|
3590
|
+
fields: new Set(E.validateFields)
|
|
233
3591
|
}),
|
|
234
|
-
validate:
|
|
3592
|
+
validate: k,
|
|
235
3593
|
wrappers: n
|
|
236
3594
|
};
|
|
237
3595
|
},
|
|
238
3596
|
render() {
|
|
239
|
-
const
|
|
240
|
-
errors:
|
|
241
|
-
formData:
|
|
3597
|
+
const E = () => this.$slots?.default?.({
|
|
3598
|
+
errors: j.value,
|
|
3599
|
+
formData: u.value,
|
|
242
3600
|
invalid: o.value,
|
|
243
|
-
readonly:
|
|
244
|
-
status:
|
|
3601
|
+
readonly: l.value,
|
|
3602
|
+
status: N.value,
|
|
245
3603
|
wrappers: n,
|
|
246
|
-
clear:
|
|
247
|
-
ignoreUpdates:
|
|
248
|
-
reset:
|
|
249
|
-
stopUpdatesWatch:
|
|
250
|
-
submit:
|
|
251
|
-
validate:
|
|
3604
|
+
clear: b,
|
|
3605
|
+
ignoreUpdates: m,
|
|
3606
|
+
reset: c,
|
|
3607
|
+
stopUpdatesWatch: x,
|
|
3608
|
+
submit: h,
|
|
3609
|
+
validate: k
|
|
252
3610
|
}) ?? this.$slots.default;
|
|
253
3611
|
return F(
|
|
254
3612
|
this.tag,
|
|
255
3613
|
{
|
|
256
|
-
onSubmit:
|
|
257
|
-
onReset:
|
|
3614
|
+
onSubmit: Ge(this.submit, ["prevent"]),
|
|
3615
|
+
onReset: Ge(this.reset, ["prevent"])
|
|
258
3616
|
},
|
|
259
|
-
(this.template ??
|
|
3617
|
+
(this.template ?? t?.template) && s ? [
|
|
260
3618
|
F(
|
|
261
|
-
|
|
3619
|
+
s,
|
|
262
3620
|
{
|
|
263
|
-
schema: this.template ??
|
|
3621
|
+
schema: this.template ?? t?.template
|
|
264
3622
|
},
|
|
265
3623
|
{
|
|
266
|
-
default:
|
|
3624
|
+
default: E
|
|
267
3625
|
}
|
|
268
3626
|
)
|
|
269
3627
|
] : {
|
|
270
|
-
default:
|
|
3628
|
+
default: E
|
|
271
3629
|
}
|
|
272
3630
|
);
|
|
273
3631
|
}
|
|
274
3632
|
});
|
|
275
3633
|
return {
|
|
276
|
-
clear:
|
|
277
|
-
errors:
|
|
278
|
-
formData:
|
|
279
|
-
ignoreUpdates:
|
|
3634
|
+
clear: b,
|
|
3635
|
+
errors: a,
|
|
3636
|
+
formData: u,
|
|
3637
|
+
ignoreUpdates: m,
|
|
280
3638
|
invalid: o,
|
|
281
|
-
readonly:
|
|
282
|
-
reset:
|
|
283
|
-
status:
|
|
3639
|
+
readonly: l,
|
|
3640
|
+
reset: c,
|
|
3641
|
+
status: i,
|
|
284
3642
|
wrappers: n,
|
|
285
|
-
stopUpdatesWatch:
|
|
286
|
-
submit:
|
|
287
|
-
validate:
|
|
288
|
-
VvForm:
|
|
3643
|
+
stopUpdatesWatch: x,
|
|
3644
|
+
submit: h,
|
|
3645
|
+
validate: k,
|
|
3646
|
+
VvForm: P
|
|
289
3647
|
};
|
|
290
3648
|
}
|
|
291
|
-
function
|
|
292
|
-
return Array.isArray(
|
|
3649
|
+
function Le(r) {
|
|
3650
|
+
return Array.isArray(r);
|
|
293
3651
|
}
|
|
294
|
-
function
|
|
3652
|
+
function Sr(r) {
|
|
295
3653
|
return !1;
|
|
296
3654
|
}
|
|
297
|
-
function
|
|
298
|
-
return
|
|
3655
|
+
function dt(r) {
|
|
3656
|
+
return r === null;
|
|
299
3657
|
}
|
|
300
|
-
function
|
|
301
|
-
return typeof
|
|
3658
|
+
function Ot(r) {
|
|
3659
|
+
return typeof r == "object";
|
|
302
3660
|
}
|
|
303
|
-
function
|
|
304
|
-
return typeof
|
|
3661
|
+
function St(r) {
|
|
3662
|
+
return typeof r == "string";
|
|
305
3663
|
}
|
|
306
|
-
function
|
|
307
|
-
return typeof
|
|
3664
|
+
function Oe(r) {
|
|
3665
|
+
return typeof r > "u";
|
|
308
3666
|
}
|
|
309
|
-
const
|
|
310
|
-
function
|
|
311
|
-
const
|
|
312
|
-
if (!
|
|
313
|
-
return
|
|
314
|
-
const n =
|
|
3667
|
+
const jr = /^[0-9]+$/, Tr = ["__proto__", "prototype", "constructor"];
|
|
3668
|
+
function he(r, e, t) {
|
|
3669
|
+
const s = Sr() ? t : void 0;
|
|
3670
|
+
if (!Ot(r) || !St(e))
|
|
3671
|
+
return s;
|
|
3672
|
+
const n = jt(e);
|
|
315
3673
|
if (n.length !== 0) {
|
|
316
|
-
for (const
|
|
317
|
-
if (
|
|
3674
|
+
for (const a of n) {
|
|
3675
|
+
if (a === "*")
|
|
318
3676
|
continue;
|
|
319
|
-
const
|
|
320
|
-
return o.map((
|
|
3677
|
+
const i = function(o) {
|
|
3678
|
+
return o.map((u) => Oe(u) || dt(u) ? u : Le(u) ? i(u) : u[a]);
|
|
321
3679
|
};
|
|
322
|
-
if (
|
|
3680
|
+
if (Le(r) && !jr.test(a) ? r = i(r) : r = r[a], Oe(r) || dt(r))
|
|
323
3681
|
break;
|
|
324
3682
|
}
|
|
325
|
-
return
|
|
3683
|
+
return Oe(r) ? s : r;
|
|
326
3684
|
}
|
|
327
3685
|
}
|
|
328
|
-
function
|
|
329
|
-
if (!
|
|
3686
|
+
function Be(r, e, t) {
|
|
3687
|
+
if (!Ot(r) || !St(e))
|
|
330
3688
|
return;
|
|
331
|
-
const
|
|
332
|
-
if (
|
|
3689
|
+
const s = jt(e);
|
|
3690
|
+
if (s.length === 0)
|
|
333
3691
|
return;
|
|
334
|
-
const n =
|
|
335
|
-
for (let
|
|
336
|
-
const
|
|
337
|
-
if (
|
|
338
|
-
|
|
3692
|
+
const n = s.length;
|
|
3693
|
+
for (let a = 0; a < n; a++) {
|
|
3694
|
+
const i = s[a];
|
|
3695
|
+
if (a === n - 1) {
|
|
3696
|
+
r[i] = t;
|
|
339
3697
|
return;
|
|
340
3698
|
}
|
|
341
|
-
if (
|
|
342
|
-
const o =
|
|
343
|
-
for (const
|
|
344
|
-
|
|
3699
|
+
if (i === "*" && Le(r)) {
|
|
3700
|
+
const o = s.slice(a + 1).join(".");
|
|
3701
|
+
for (const u of r)
|
|
3702
|
+
Be(u, o, t);
|
|
345
3703
|
return;
|
|
346
3704
|
}
|
|
347
|
-
|
|
3705
|
+
Oe(r[i]) && (r[i] = {}), r = r[i];
|
|
348
3706
|
}
|
|
349
3707
|
}
|
|
350
|
-
function
|
|
351
|
-
const
|
|
352
|
-
return
|
|
3708
|
+
function jt(r) {
|
|
3709
|
+
const e = r.split(/[.]|(?:\[(\d|\*)\])/).filter((t) => !!t);
|
|
3710
|
+
return e.some((t) => Tr.indexOf(t) !== -1) ? [] : e;
|
|
353
3711
|
}
|
|
354
|
-
function
|
|
355
|
-
return
|
|
3712
|
+
function Nr(r, e, t, s) {
|
|
3713
|
+
return _e({
|
|
356
3714
|
name: "VvFormField",
|
|
357
3715
|
props: {
|
|
358
3716
|
type: {
|
|
359
3717
|
type: String,
|
|
360
|
-
validator: (n) => Object.values(
|
|
361
|
-
default:
|
|
3718
|
+
validator: (n) => Object.values(R).includes(n),
|
|
3719
|
+
default: R.custom
|
|
362
3720
|
},
|
|
363
3721
|
is: {
|
|
364
3722
|
type: [Object, String],
|
|
@@ -405,175 +3763,175 @@ function xe(e, i, a, v) {
|
|
|
405
3763
|
"type"
|
|
406
3764
|
],
|
|
407
3765
|
slots: Object,
|
|
408
|
-
setup(n, { slots:
|
|
409
|
-
const { props: o, name:
|
|
410
|
-
d && d.fields.value.set(
|
|
411
|
-
const
|
|
3766
|
+
setup(n, { slots: a, emit: i }) {
|
|
3767
|
+
const { props: o, name: u } = Fe(n), l = ft(), d = re(e, void 0);
|
|
3768
|
+
d && d.fields.value.set(l, n.name);
|
|
3769
|
+
const f = re(r), k = Z({
|
|
412
3770
|
get() {
|
|
413
|
-
if (
|
|
414
|
-
return
|
|
415
|
-
new Object(
|
|
3771
|
+
if (f?.formData)
|
|
3772
|
+
return he(
|
|
3773
|
+
new Object(f.formData.value),
|
|
416
3774
|
String(n.name)
|
|
417
3775
|
);
|
|
418
3776
|
},
|
|
419
|
-
set(
|
|
420
|
-
|
|
421
|
-
new Object(
|
|
3777
|
+
set(g) {
|
|
3778
|
+
f?.formData && (Be(
|
|
3779
|
+
new Object(f.formData.value),
|
|
422
3780
|
String(n.name),
|
|
423
|
-
|
|
424
|
-
),
|
|
425
|
-
newValue:
|
|
426
|
-
formData:
|
|
3781
|
+
g
|
|
3782
|
+
), i("update:modelValue", {
|
|
3783
|
+
newValue: k.value,
|
|
3784
|
+
formData: f?.formData
|
|
427
3785
|
}));
|
|
428
3786
|
}
|
|
429
3787
|
});
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
}),
|
|
433
|
-
d && d.fields.value.delete(
|
|
3788
|
+
Re(() => {
|
|
3789
|
+
k.value === void 0 && n.defaultValue !== void 0 && (k.value = n.defaultValue);
|
|
3790
|
+
}), me(() => {
|
|
3791
|
+
d && d.fields.value.delete(l);
|
|
434
3792
|
});
|
|
435
|
-
const
|
|
436
|
-
if (
|
|
437
|
-
return
|
|
438
|
-
}),
|
|
439
|
-
if (
|
|
440
|
-
|
|
3793
|
+
const b = Z(() => {
|
|
3794
|
+
if (f?.errors.value)
|
|
3795
|
+
return he(f.errors.value, String(n.name));
|
|
3796
|
+
}), c = Z(() => b.value?._errors), h = Z(() => b.value !== void 0), m = J(h, (g) => {
|
|
3797
|
+
if (g) {
|
|
3798
|
+
i("invalid", b.value), d && d.errors.value.set(
|
|
441
3799
|
String(n.name),
|
|
442
|
-
|
|
3800
|
+
b.value
|
|
443
3801
|
);
|
|
444
3802
|
return;
|
|
445
3803
|
}
|
|
446
|
-
|
|
3804
|
+
i("valid", k.value), d && d.errors.value.delete(
|
|
447
3805
|
n.name
|
|
448
3806
|
);
|
|
449
|
-
}),
|
|
450
|
-
() =>
|
|
3807
|
+
}), x = J(
|
|
3808
|
+
() => f?.formData,
|
|
451
3809
|
() => {
|
|
452
|
-
|
|
3810
|
+
i("update:formData", f?.formData);
|
|
453
3811
|
},
|
|
454
3812
|
{ deep: !0 }
|
|
455
3813
|
);
|
|
456
|
-
|
|
457
|
-
|
|
3814
|
+
me(() => {
|
|
3815
|
+
m(), x();
|
|
458
3816
|
});
|
|
459
|
-
const
|
|
460
|
-
|
|
461
|
-
},
|
|
462
|
-
let
|
|
463
|
-
return typeof
|
|
464
|
-
(
|
|
3817
|
+
const j = (g) => {
|
|
3818
|
+
g instanceof InputEvent && (g = g.target.value), k.value = g;
|
|
3819
|
+
}, N = Z(() => {
|
|
3820
|
+
let g = o.value;
|
|
3821
|
+
return typeof g == "function" && (g = g(f?.formData)), Object.keys(g).reduce(
|
|
3822
|
+
(A, Q) => (A[Q] = le(g[Q]), A),
|
|
465
3823
|
{}
|
|
466
3824
|
);
|
|
467
|
-
}),
|
|
468
|
-
...
|
|
469
|
-
name:
|
|
470
|
-
invalid:
|
|
471
|
-
valid: n.showValid ? !!(!
|
|
472
|
-
type: ((
|
|
3825
|
+
}), P = Z(() => f?.readonly.value || d?.readonly.value ? !0 : N.value.readonly ?? n.readonly), E = Z(() => ({
|
|
3826
|
+
...N.value,
|
|
3827
|
+
name: N.value.name ?? n.name,
|
|
3828
|
+
invalid: h.value,
|
|
3829
|
+
valid: n.showValid ? !!(!h.value && k.value) : void 0,
|
|
3830
|
+
type: ((g) => {
|
|
473
3831
|
if ([
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
].includes(
|
|
488
|
-
return
|
|
3832
|
+
R.color,
|
|
3833
|
+
R.date,
|
|
3834
|
+
R.datetimeLocal,
|
|
3835
|
+
R.email,
|
|
3836
|
+
R.month,
|
|
3837
|
+
R.number,
|
|
3838
|
+
R.password,
|
|
3839
|
+
R.search,
|
|
3840
|
+
R.tel,
|
|
3841
|
+
R.text,
|
|
3842
|
+
R.time,
|
|
3843
|
+
R.url,
|
|
3844
|
+
R.week
|
|
3845
|
+
].includes(g))
|
|
3846
|
+
return g;
|
|
489
3847
|
})(n.type),
|
|
490
|
-
invalidLabel:
|
|
491
|
-
modelValue:
|
|
492
|
-
readonly:
|
|
493
|
-
"onUpdate:modelValue":
|
|
3848
|
+
invalidLabel: c.value,
|
|
3849
|
+
modelValue: k.value,
|
|
3850
|
+
readonly: P.value,
|
|
3851
|
+
"onUpdate:modelValue": j
|
|
494
3852
|
}));
|
|
495
|
-
return
|
|
496
|
-
name:
|
|
497
|
-
errors:
|
|
498
|
-
}), { component:
|
|
499
|
-
if (n.type ===
|
|
3853
|
+
return Ve(t, {
|
|
3854
|
+
name: H(u),
|
|
3855
|
+
errors: H(b)
|
|
3856
|
+
}), { component: Z(() => {
|
|
3857
|
+
if (n.type === R.custom)
|
|
500
3858
|
return {
|
|
501
3859
|
render() {
|
|
502
|
-
return
|
|
503
|
-
errors:
|
|
504
|
-
formData:
|
|
505
|
-
formErrors:
|
|
506
|
-
invalid:
|
|
507
|
-
invalidLabel:
|
|
508
|
-
modelValue:
|
|
509
|
-
readonly:
|
|
510
|
-
onUpdate:
|
|
511
|
-
submit:
|
|
512
|
-
validate:
|
|
513
|
-
}) ??
|
|
3860
|
+
return a.default?.({
|
|
3861
|
+
errors: b.value,
|
|
3862
|
+
formData: f?.formData.value,
|
|
3863
|
+
formErrors: f?.errors.value,
|
|
3864
|
+
invalid: h.value,
|
|
3865
|
+
invalidLabel: c.value,
|
|
3866
|
+
modelValue: k.value,
|
|
3867
|
+
readonly: P.value,
|
|
3868
|
+
onUpdate: j,
|
|
3869
|
+
submit: f?.submit,
|
|
3870
|
+
validate: f?.validate
|
|
3871
|
+
}) ?? a.default;
|
|
514
3872
|
}
|
|
515
3873
|
};
|
|
516
|
-
if (!(
|
|
517
|
-
let
|
|
3874
|
+
if (!(s?.lazyLoad ?? n.lazyLoad)) {
|
|
3875
|
+
let g;
|
|
518
3876
|
switch (n.type) {
|
|
519
|
-
case
|
|
520
|
-
|
|
3877
|
+
case R.select:
|
|
3878
|
+
g = ee("VvSelect");
|
|
521
3879
|
break;
|
|
522
|
-
case
|
|
523
|
-
|
|
3880
|
+
case R.checkbox:
|
|
3881
|
+
g = ee("VvCheckbox");
|
|
524
3882
|
break;
|
|
525
|
-
case
|
|
526
|
-
|
|
3883
|
+
case R.radio:
|
|
3884
|
+
g = ee("VvRadio");
|
|
527
3885
|
break;
|
|
528
|
-
case
|
|
529
|
-
|
|
3886
|
+
case R.textarea:
|
|
3887
|
+
g = ee("VvTextarea");
|
|
530
3888
|
break;
|
|
531
|
-
case
|
|
532
|
-
|
|
3889
|
+
case R.radioGroup:
|
|
3890
|
+
g = ee("VvRadioGroup");
|
|
533
3891
|
break;
|
|
534
|
-
case
|
|
535
|
-
|
|
3892
|
+
case R.checkboxGroup:
|
|
3893
|
+
g = ee("VvCheckboxGroup");
|
|
536
3894
|
break;
|
|
537
|
-
case
|
|
538
|
-
|
|
3895
|
+
case R.combobox:
|
|
3896
|
+
g = ee("VvCombobox");
|
|
539
3897
|
break;
|
|
540
3898
|
default:
|
|
541
|
-
|
|
3899
|
+
g = ee("VvInputText");
|
|
542
3900
|
}
|
|
543
|
-
if (typeof
|
|
544
|
-
return
|
|
3901
|
+
if (typeof g != "string")
|
|
3902
|
+
return g;
|
|
545
3903
|
console.warn(
|
|
546
|
-
`[@volverjs/form-vue]: ${
|
|
3904
|
+
`[@volverjs/form-vue]: ${g} not found, the component will be loaded asynchronously. To avoid this warning, please set "lazyLoad" option.`
|
|
547
3905
|
);
|
|
548
3906
|
}
|
|
549
|
-
return
|
|
550
|
-
switch (
|
|
551
|
-
case
|
|
3907
|
+
return Et(async () => {
|
|
3908
|
+
switch (s?.sideEffects && await Promise.resolve(s.sideEffects(n.type)), n.type) {
|
|
3909
|
+
case R.textarea:
|
|
552
3910
|
return import("@volverjs/ui-vue/vv-textarea");
|
|
553
|
-
case
|
|
3911
|
+
case R.radio:
|
|
554
3912
|
return import("@volverjs/ui-vue/vv-radio");
|
|
555
|
-
case
|
|
3913
|
+
case R.radioGroup:
|
|
556
3914
|
return import("@volverjs/ui-vue/vv-radio-group");
|
|
557
|
-
case
|
|
3915
|
+
case R.checkbox:
|
|
558
3916
|
return import("@volverjs/ui-vue/vv-checkbox");
|
|
559
|
-
case
|
|
3917
|
+
case R.checkboxGroup:
|
|
560
3918
|
return import("@volverjs/ui-vue/vv-checkbox-group");
|
|
561
|
-
case
|
|
3919
|
+
case R.select:
|
|
562
3920
|
return import("@volverjs/ui-vue/vv-select");
|
|
563
|
-
case
|
|
3921
|
+
case R.combobox:
|
|
564
3922
|
return import("@volverjs/ui-vue/vv-combobox");
|
|
565
3923
|
}
|
|
566
3924
|
return import("@volverjs/ui-vue/vv-input-text");
|
|
567
3925
|
});
|
|
568
|
-
}), hasProps:
|
|
3926
|
+
}), hasProps: E, invalid: h };
|
|
569
3927
|
},
|
|
570
3928
|
render() {
|
|
571
|
-
return this.is ? F(this.is, this.hasProps, this.$slots) : this.type ===
|
|
3929
|
+
return this.is ? F(this.is, this.hasProps, this.$slots) : this.type === R.custom ? F(this.component, null, this.$slots) : F(this.component, this.hasProps, this.$slots);
|
|
572
3930
|
}
|
|
573
3931
|
});
|
|
574
3932
|
}
|
|
575
|
-
function
|
|
576
|
-
return
|
|
3933
|
+
function Ir(r, e, t) {
|
|
3934
|
+
return _e({
|
|
577
3935
|
name: "VvFormFieldsGroup",
|
|
578
3936
|
props: {
|
|
579
3937
|
is: {
|
|
@@ -616,150 +3974,150 @@ function Ie(e, i, a) {
|
|
|
616
3974
|
"is"
|
|
617
3975
|
],
|
|
618
3976
|
slots: Object,
|
|
619
|
-
setup(
|
|
620
|
-
const { props:
|
|
621
|
-
|
|
622
|
-
|
|
3977
|
+
setup(s, { slots: n, emit: a }) {
|
|
3978
|
+
const { props: i, names: o, defaultValues: u } = Fe(s), l = ft(), d = Z(() => Array.isArray(o.value) ? o.value : Object.values(o.value)), f = Z(() => Array.isArray(o.value) ? o.value : Object.keys(o.value)), k = Z(() => Array.isArray(o.value) ? o.value.reduce((w, C) => (w[String(C)] = C, w), {}) : o.value), b = Z(() => Object.keys(k.value).reduce((w, C) => (w[String(k.value[C])] = C, w), {})), c = re(e, void 0);
|
|
3979
|
+
c && d.value.forEach((w) => {
|
|
3980
|
+
c.fields.value.set(`${l}-${w}`, w);
|
|
623
3981
|
});
|
|
624
|
-
const
|
|
3982
|
+
const h = re(r), m = Z({
|
|
625
3983
|
get() {
|
|
626
|
-
return
|
|
627
|
-
new Object(
|
|
628
|
-
|
|
629
|
-
),
|
|
3984
|
+
return h?.formData ? f.value.reduce((w, C) => (w[C] = he(
|
|
3985
|
+
new Object(h.formData.value),
|
|
3986
|
+
k.value[C]
|
|
3987
|
+
), w), {}) : {};
|
|
630
3988
|
},
|
|
631
|
-
set(
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
new Object(
|
|
635
|
-
|
|
636
|
-
|
|
3989
|
+
set(w) {
|
|
3990
|
+
h?.formData && (f.value.forEach((C) => {
|
|
3991
|
+
Be(
|
|
3992
|
+
new Object(h.formData.value),
|
|
3993
|
+
k.value[C],
|
|
3994
|
+
w?.[C]
|
|
637
3995
|
);
|
|
638
|
-
}),
|
|
639
|
-
newValue:
|
|
640
|
-
formData:
|
|
3996
|
+
}), a("update:modelValue", {
|
|
3997
|
+
newValue: m.value,
|
|
3998
|
+
formData: h?.formData
|
|
641
3999
|
}));
|
|
642
4000
|
}
|
|
643
4001
|
});
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
...
|
|
648
|
-
[
|
|
4002
|
+
Re(() => {
|
|
4003
|
+
u.value && d.value.forEach((w) => {
|
|
4004
|
+
u.value?.[w] !== void 0 && m.value[w] === void 0 && (m.value = {
|
|
4005
|
+
...m.value,
|
|
4006
|
+
[w]: u.value?.[w]
|
|
649
4007
|
});
|
|
650
4008
|
});
|
|
651
|
-
}),
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
`${
|
|
4009
|
+
}), me(() => {
|
|
4010
|
+
c && d.value.forEach((w) => {
|
|
4011
|
+
c.fields.value.delete(
|
|
4012
|
+
`${l}-${w}`
|
|
655
4013
|
);
|
|
656
4014
|
});
|
|
657
4015
|
});
|
|
658
|
-
const
|
|
659
|
-
if (!
|
|
4016
|
+
const x = Z(() => {
|
|
4017
|
+
if (!h?.errors.value)
|
|
660
4018
|
return;
|
|
661
|
-
const
|
|
662
|
-
if (!
|
|
663
|
-
return
|
|
664
|
-
const
|
|
665
|
-
return
|
|
4019
|
+
const w = d.value.reduce((C, B) => {
|
|
4020
|
+
if (!h.errors.value)
|
|
4021
|
+
return C;
|
|
4022
|
+
const We = he(h.errors.value, String(B));
|
|
4023
|
+
return We === void 0 || (C[String(B)] = We), C;
|
|
666
4024
|
}, {});
|
|
667
|
-
if (Object.keys(
|
|
668
|
-
return
|
|
669
|
-
}),
|
|
670
|
-
if (!
|
|
4025
|
+
if (Object.keys(w).length !== 0)
|
|
4026
|
+
return w;
|
|
4027
|
+
}), j = Z(() => {
|
|
4028
|
+
if (!x.value)
|
|
671
4029
|
return;
|
|
672
|
-
const
|
|
673
|
-
if (Object.keys(
|
|
674
|
-
return
|
|
675
|
-
}),
|
|
676
|
-
if (
|
|
677
|
-
|
|
678
|
-
if (!
|
|
679
|
-
|
|
680
|
-
|
|
4030
|
+
const w = Object.keys(x.value).reduce((C, B) => (x.value?.[B] && (C[b.value[B]] = x.value[B]._errors), C), {});
|
|
4031
|
+
if (Object.keys(w).length !== 0)
|
|
4032
|
+
return w;
|
|
4033
|
+
}), N = Z(() => x.value !== void 0), P = Z(() => f.value.reduce((w, C) => (w[C] = !!x.value?.[b.value[C]], w), {})), E = J(N, () => {
|
|
4034
|
+
if (N.value) {
|
|
4035
|
+
a("invalid", x.value), c && d.value.forEach((w) => {
|
|
4036
|
+
if (!x.value?.[w]) {
|
|
4037
|
+
c.errors.value.delete(
|
|
4038
|
+
w
|
|
681
4039
|
);
|
|
682
4040
|
return;
|
|
683
4041
|
}
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
4042
|
+
c.errors.value.set(
|
|
4043
|
+
w,
|
|
4044
|
+
x.value?.[w]
|
|
687
4045
|
);
|
|
688
4046
|
});
|
|
689
4047
|
return;
|
|
690
4048
|
}
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
4049
|
+
a("valid", m.value), c && d.value.forEach((w) => {
|
|
4050
|
+
c.errors.value.delete(
|
|
4051
|
+
w
|
|
694
4052
|
);
|
|
695
4053
|
});
|
|
696
|
-
}),
|
|
697
|
-
() =>
|
|
4054
|
+
}), D = J(
|
|
4055
|
+
() => h?.formData,
|
|
698
4056
|
() => {
|
|
699
|
-
|
|
4057
|
+
a("update:formData", h?.formData);
|
|
700
4058
|
},
|
|
701
4059
|
{ deep: !0 }
|
|
702
4060
|
);
|
|
703
|
-
|
|
704
|
-
|
|
4061
|
+
me(() => {
|
|
4062
|
+
E(), D();
|
|
705
4063
|
});
|
|
706
|
-
const
|
|
707
|
-
|
|
708
|
-
},
|
|
709
|
-
|
|
710
|
-
...
|
|
711
|
-
[
|
|
4064
|
+
const g = (w) => {
|
|
4065
|
+
m.value = w;
|
|
4066
|
+
}, A = (w, C) => {
|
|
4067
|
+
C instanceof InputEvent && (C = C.target.value), f.value.includes(w) && (m.value = {
|
|
4068
|
+
...m.value,
|
|
4069
|
+
[w]: C
|
|
712
4070
|
});
|
|
713
|
-
},
|
|
714
|
-
let
|
|
715
|
-
return typeof
|
|
716
|
-
(
|
|
4071
|
+
}, Q = Z(() => {
|
|
4072
|
+
let w = i.value;
|
|
4073
|
+
return typeof w == "function" && (w = w(h?.formData)), Object.keys(w).reduce(
|
|
4074
|
+
(C, B) => (C[B] = le(w[B]), C),
|
|
717
4075
|
{}
|
|
718
4076
|
);
|
|
719
|
-
}),
|
|
720
|
-
|
|
721
|
-
},
|
|
722
|
-
"onUpdate:modelValue":
|
|
723
|
-
})),
|
|
724
|
-
...
|
|
725
|
-
|
|
726
|
-
names:
|
|
727
|
-
invalid:
|
|
728
|
-
invalids:
|
|
729
|
-
valid:
|
|
730
|
-
invalidLabels:
|
|
731
|
-
modelValue:
|
|
732
|
-
readonly:
|
|
4077
|
+
}), Je = Z(() => h?.readonly.value ? !0 : Q.value.readonly ?? s.readonly), Nt = Z(() => f.value.reduce((w, C) => (w[`onUpdate:${C}`] = (B) => {
|
|
4078
|
+
A(C, B);
|
|
4079
|
+
}, w), {
|
|
4080
|
+
"onUpdate:modelValue": g
|
|
4081
|
+
})), It = Z(() => ({
|
|
4082
|
+
...Nt.value,
|
|
4083
|
+
...Q.value,
|
|
4084
|
+
names: Q.value.name ?? d.value,
|
|
4085
|
+
invalid: N.value,
|
|
4086
|
+
invalids: P.value,
|
|
4087
|
+
valid: s.showValid ? !!(!N.value && m.value) : void 0,
|
|
4088
|
+
invalidLabels: j.value,
|
|
4089
|
+
modelValue: m.value,
|
|
4090
|
+
readonly: Je.value
|
|
733
4091
|
}));
|
|
734
|
-
return
|
|
735
|
-
names:
|
|
736
|
-
errors:
|
|
737
|
-
}), { component:
|
|
4092
|
+
return Ve(t, {
|
|
4093
|
+
names: H(o),
|
|
4094
|
+
errors: H(x)
|
|
4095
|
+
}), { component: Z(() => ({
|
|
738
4096
|
render() {
|
|
739
4097
|
return n.default?.({
|
|
740
|
-
errors:
|
|
741
|
-
formData:
|
|
742
|
-
formErrors:
|
|
743
|
-
invalid:
|
|
744
|
-
invalids:
|
|
745
|
-
invalidLabels:
|
|
746
|
-
modelValue:
|
|
747
|
-
onUpdate:
|
|
748
|
-
onUpdateField:
|
|
749
|
-
readonly:
|
|
750
|
-
submit:
|
|
751
|
-
validate:
|
|
4098
|
+
errors: x.value,
|
|
4099
|
+
formData: h?.formData.value,
|
|
4100
|
+
formErrors: h?.errors.value,
|
|
4101
|
+
invalid: N.value,
|
|
4102
|
+
invalids: P.value,
|
|
4103
|
+
invalidLabels: j.value,
|
|
4104
|
+
modelValue: m.value,
|
|
4105
|
+
onUpdate: g,
|
|
4106
|
+
onUpdateField: A,
|
|
4107
|
+
readonly: Je.value,
|
|
4108
|
+
submit: h?.submit,
|
|
4109
|
+
validate: h?.validate
|
|
752
4110
|
}) ?? n.default;
|
|
753
4111
|
}
|
|
754
|
-
})), hasProps:
|
|
4112
|
+
})), hasProps: It, invalid: N };
|
|
755
4113
|
},
|
|
756
4114
|
render() {
|
|
757
4115
|
return this.is ? F(this.is, this.hasProps, this.$slots) : F(this.component, null, this.$slots);
|
|
758
4116
|
}
|
|
759
4117
|
});
|
|
760
4118
|
}
|
|
761
|
-
function
|
|
762
|
-
return
|
|
4119
|
+
function Cr(r, e) {
|
|
4120
|
+
return _e({
|
|
763
4121
|
name: "VvFormWrapper",
|
|
764
4122
|
props: {
|
|
765
4123
|
name: {
|
|
@@ -791,75 +4149,75 @@ function Fe(e, i) {
|
|
|
791
4149
|
"validateWrapper"
|
|
792
4150
|
],
|
|
793
4151
|
slots: Object,
|
|
794
|
-
setup(
|
|
795
|
-
const n =
|
|
796
|
-
|
|
797
|
-
if (
|
|
798
|
-
|
|
4152
|
+
setup(t, { emit: s }) {
|
|
4153
|
+
const n = re(r), a = re(e, void 0), i = ce(/* @__PURE__ */ new Map()), o = ce(/* @__PURE__ */ new Map()), { name: u } = Fe(t), l = Z(() => n?.invalid.value ? o.value.size > 0 : !1);
|
|
4154
|
+
J(l, (c) => {
|
|
4155
|
+
if (c) {
|
|
4156
|
+
s("invalid");
|
|
799
4157
|
return;
|
|
800
4158
|
}
|
|
801
|
-
|
|
4159
|
+
s("valid");
|
|
802
4160
|
});
|
|
803
|
-
const d =
|
|
804
|
-
name:
|
|
4161
|
+
const d = Z(() => n?.readonly.value || t.readonly), f = {
|
|
4162
|
+
name: H(u),
|
|
805
4163
|
errors: o,
|
|
806
|
-
invalid:
|
|
807
|
-
readonly:
|
|
808
|
-
fields:
|
|
4164
|
+
invalid: H(l),
|
|
4165
|
+
readonly: H(d),
|
|
4166
|
+
fields: i
|
|
809
4167
|
};
|
|
810
|
-
|
|
811
|
-
const
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
(
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
}),
|
|
818
|
-
|
|
4168
|
+
Ve(e, f);
|
|
4169
|
+
const k = Z(() => new Map(i.value));
|
|
4170
|
+
J(
|
|
4171
|
+
k,
|
|
4172
|
+
(c, h) => {
|
|
4173
|
+
a?.fields && (h.forEach((m, x) => {
|
|
4174
|
+
c.has(x) || a?.fields.value.delete(x);
|
|
4175
|
+
}), c.forEach((m, x) => {
|
|
4176
|
+
a?.fields.value.has(x) || a?.fields.value.set(x, m);
|
|
819
4177
|
}));
|
|
820
4178
|
},
|
|
821
4179
|
{ deep: !0 }
|
|
822
|
-
),
|
|
4180
|
+
), J(
|
|
823
4181
|
o,
|
|
824
|
-
(
|
|
825
|
-
|
|
826
|
-
if (
|
|
827
|
-
const
|
|
828
|
-
|
|
4182
|
+
(c) => {
|
|
4183
|
+
a?.errors && i.value.forEach((h) => {
|
|
4184
|
+
if (c.has(h) || a.errors.value.delete(h), c.has(h)) {
|
|
4185
|
+
const m = c.get(h);
|
|
4186
|
+
m && a.errors.value.set(h, m);
|
|
829
4187
|
}
|
|
830
4188
|
});
|
|
831
4189
|
},
|
|
832
4190
|
{ deep: !0 }
|
|
833
|
-
),
|
|
834
|
-
if (!n?.wrappers || !
|
|
4191
|
+
), Re(() => {
|
|
4192
|
+
if (!n?.wrappers || !u.value) {
|
|
835
4193
|
console.warn("[@volverjs/form-vue]: Invalid wrapper registration state");
|
|
836
4194
|
return;
|
|
837
4195
|
}
|
|
838
|
-
if (n.wrappers.has(
|
|
839
|
-
console.warn(`[@volverjs/form-vue]: wrapper name "${
|
|
4196
|
+
if (n.wrappers.has(u.value)) {
|
|
4197
|
+
console.warn(`[@volverjs/form-vue]: wrapper name "${u.value}" is already used`);
|
|
840
4198
|
return;
|
|
841
4199
|
}
|
|
842
|
-
n.wrappers.set(
|
|
843
|
-
}),
|
|
844
|
-
n?.wrappers &&
|
|
4200
|
+
n.wrappers.set(u.value, f);
|
|
4201
|
+
}), me(() => {
|
|
4202
|
+
n?.wrappers && u.value && n.wrappers.delete(u.value);
|
|
845
4203
|
});
|
|
846
|
-
const
|
|
4204
|
+
const b = () => n?.validate(void 0, { fields: new Set(i.value.values()) }) ?? Promise.resolve(!0);
|
|
847
4205
|
return {
|
|
848
4206
|
errors: n?.errors,
|
|
849
|
-
fields:
|
|
4207
|
+
fields: i,
|
|
850
4208
|
fieldsErrors: o,
|
|
851
4209
|
formData: n?.formData,
|
|
852
|
-
invalid:
|
|
4210
|
+
invalid: l,
|
|
853
4211
|
readonly: d,
|
|
854
4212
|
clear: n?.clear,
|
|
855
4213
|
reset: n?.reset,
|
|
856
4214
|
submit: n?.submit,
|
|
857
4215
|
validate: n?.validate,
|
|
858
|
-
validateWrapper:
|
|
4216
|
+
validateWrapper: b
|
|
859
4217
|
};
|
|
860
4218
|
},
|
|
861
4219
|
render() {
|
|
862
|
-
const
|
|
4220
|
+
const t = () => this.$slots.default?.({
|
|
863
4221
|
errors: this.errors,
|
|
864
4222
|
fieldsErrors: this.fieldsErrors,
|
|
865
4223
|
formData: this.formData,
|
|
@@ -872,13 +4230,13 @@ function Fe(e, i) {
|
|
|
872
4230
|
validateWrapper: this.validateWrapper
|
|
873
4231
|
});
|
|
874
4232
|
return this.tag ? F(this.tag, null, {
|
|
875
|
-
default:
|
|
876
|
-
}) :
|
|
4233
|
+
default: t
|
|
4234
|
+
}) : t();
|
|
877
4235
|
}
|
|
878
4236
|
});
|
|
879
4237
|
}
|
|
880
|
-
function
|
|
881
|
-
const
|
|
4238
|
+
function Er(r, e) {
|
|
4239
|
+
const t = _e({
|
|
882
4240
|
name: "VvFormTemplate",
|
|
883
4241
|
props: {
|
|
884
4242
|
schema: {
|
|
@@ -891,174 +4249,174 @@ function ke(e, i) {
|
|
|
891
4249
|
}
|
|
892
4250
|
},
|
|
893
4251
|
slots: Object,
|
|
894
|
-
setup(
|
|
895
|
-
const
|
|
896
|
-
if (
|
|
4252
|
+
setup(s, { slots: n }) {
|
|
4253
|
+
const a = re(r);
|
|
4254
|
+
if (a?.formData)
|
|
897
4255
|
return () => {
|
|
898
|
-
const
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
) :
|
|
4256
|
+
const i = typeof s.schema == "function" ? s.schema(
|
|
4257
|
+
a,
|
|
4258
|
+
s.scope
|
|
4259
|
+
) : s.schema;
|
|
902
4260
|
let o;
|
|
903
|
-
const
|
|
904
|
-
const
|
|
905
|
-
vvIs:
|
|
906
|
-
vvName:
|
|
907
|
-
vvSlots:
|
|
908
|
-
vvChildren:
|
|
909
|
-
vvIf:
|
|
910
|
-
vvElseIf:
|
|
911
|
-
vvType:
|
|
912
|
-
vvDefaultValue:
|
|
913
|
-
vvShowValid:
|
|
914
|
-
vvContent:
|
|
915
|
-
...
|
|
916
|
-
} =
|
|
917
|
-
if (
|
|
918
|
-
if (typeof
|
|
919
|
-
new Object(
|
|
920
|
-
|
|
921
|
-
) : typeof
|
|
922
|
-
return
|
|
923
|
-
} else if (
|
|
924
|
-
if (o || (typeof
|
|
925
|
-
new Object(
|
|
926
|
-
|
|
927
|
-
) : typeof
|
|
928
|
-
return
|
|
4261
|
+
const u = i.reduce((l, d) => {
|
|
4262
|
+
const f = typeof d == "function" ? d(a, s.scope) : d, {
|
|
4263
|
+
vvIs: k,
|
|
4264
|
+
vvName: b,
|
|
4265
|
+
vvSlots: c,
|
|
4266
|
+
vvChildren: h,
|
|
4267
|
+
vvIf: m,
|
|
4268
|
+
vvElseIf: x,
|
|
4269
|
+
vvType: j,
|
|
4270
|
+
vvDefaultValue: N,
|
|
4271
|
+
vvShowValid: P,
|
|
4272
|
+
vvContent: E,
|
|
4273
|
+
...D
|
|
4274
|
+
} = f;
|
|
4275
|
+
if (m !== void 0) {
|
|
4276
|
+
if (typeof m == "string" ? o = !!he(
|
|
4277
|
+
new Object(a.formData.value),
|
|
4278
|
+
m
|
|
4279
|
+
) : typeof m == "function" ? o = le(m(a)) : o = le(m), !o)
|
|
4280
|
+
return l;
|
|
4281
|
+
} else if (x !== void 0 && o !== void 0) {
|
|
4282
|
+
if (o || (typeof x == "string" ? o = !!he(
|
|
4283
|
+
new Object(a.formData.value),
|
|
4284
|
+
x
|
|
4285
|
+
) : typeof x == "function" ? o = le(x(a)) : o = le(x), !o))
|
|
4286
|
+
return l;
|
|
929
4287
|
} else
|
|
930
4288
|
o = void 0;
|
|
931
|
-
let
|
|
932
|
-
return
|
|
933
|
-
schema:
|
|
934
|
-
}) :
|
|
935
|
-
default: (
|
|
936
|
-
schema:
|
|
937
|
-
scope:
|
|
4289
|
+
let g;
|
|
4290
|
+
return h && (typeof k == "string" ? g = F(t, {
|
|
4291
|
+
schema: h
|
|
4292
|
+
}) : g = {
|
|
4293
|
+
default: (A) => F(t, {
|
|
4294
|
+
schema: h,
|
|
4295
|
+
scope: A
|
|
938
4296
|
})
|
|
939
|
-
}),
|
|
4297
|
+
}), b ? (l.push(
|
|
940
4298
|
F(
|
|
941
|
-
|
|
4299
|
+
e,
|
|
942
4300
|
{
|
|
943
|
-
name:
|
|
944
|
-
is:
|
|
945
|
-
type:
|
|
946
|
-
defaultValue:
|
|
947
|
-
showValid:
|
|
948
|
-
props:
|
|
4301
|
+
name: b,
|
|
4302
|
+
is: k,
|
|
4303
|
+
type: j,
|
|
4304
|
+
defaultValue: N,
|
|
4305
|
+
showValid: P,
|
|
4306
|
+
props: D
|
|
949
4307
|
},
|
|
950
|
-
|
|
4308
|
+
c ?? g ?? E
|
|
951
4309
|
)
|
|
952
|
-
),
|
|
4310
|
+
), l) : k ? (l.push(
|
|
953
4311
|
F(
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
4312
|
+
k,
|
|
4313
|
+
D,
|
|
4314
|
+
c ?? g ?? E
|
|
957
4315
|
)
|
|
958
|
-
),
|
|
4316
|
+
), l) : (g && ("default" in g ? l.push(g.default(s.scope)) : l.push(g)), l);
|
|
959
4317
|
}, []);
|
|
960
|
-
return
|
|
4318
|
+
return u.push(
|
|
961
4319
|
n?.default?.({
|
|
962
|
-
errors:
|
|
963
|
-
formData:
|
|
964
|
-
invalid:
|
|
965
|
-
status:
|
|
966
|
-
submit:
|
|
967
|
-
validate:
|
|
968
|
-
clear:
|
|
969
|
-
reset:
|
|
4320
|
+
errors: a?.errors.value,
|
|
4321
|
+
formData: a?.formData.value,
|
|
4322
|
+
invalid: a?.invalid.value,
|
|
4323
|
+
status: a?.status.value,
|
|
4324
|
+
submit: a?.submit,
|
|
4325
|
+
validate: a?.validate,
|
|
4326
|
+
clear: a?.clear,
|
|
4327
|
+
reset: a?.reset
|
|
970
4328
|
})
|
|
971
|
-
),
|
|
4329
|
+
), u;
|
|
972
4330
|
};
|
|
973
4331
|
}
|
|
974
4332
|
});
|
|
975
|
-
return
|
|
4333
|
+
return t;
|
|
976
4334
|
}
|
|
977
|
-
function
|
|
978
|
-
const
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
), o =
|
|
982
|
-
|
|
983
|
-
|
|
4335
|
+
function Ae(r, e = {}) {
|
|
4336
|
+
const t = Symbol("formInjectionKey"), s = Symbol("formWrapperInjectionKey"), n = Symbol("formFieldInjectionKey"), a = Symbol("formFieldsGroupInjectionKey"), i = Cr(
|
|
4337
|
+
t,
|
|
4338
|
+
s
|
|
4339
|
+
), o = Nr(
|
|
4340
|
+
t,
|
|
4341
|
+
s,
|
|
984
4342
|
n,
|
|
985
|
-
|
|
986
|
-
),
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
),
|
|
991
|
-
clear:
|
|
992
|
-
errors:
|
|
993
|
-
formData:
|
|
994
|
-
ignoreUpdates:
|
|
995
|
-
invalid:
|
|
996
|
-
readonly:
|
|
997
|
-
reset:
|
|
998
|
-
status:
|
|
999
|
-
stopUpdatesWatch:
|
|
1000
|
-
submit:
|
|
1001
|
-
validate:
|
|
1002
|
-
VvForm:
|
|
1003
|
-
} =
|
|
4343
|
+
e
|
|
4344
|
+
), u = Ir(
|
|
4345
|
+
t,
|
|
4346
|
+
s,
|
|
4347
|
+
a
|
|
4348
|
+
), l = Er(t, o), d = /* @__PURE__ */ new Map(), {
|
|
4349
|
+
clear: f,
|
|
4350
|
+
errors: k,
|
|
4351
|
+
formData: b,
|
|
4352
|
+
ignoreUpdates: c,
|
|
4353
|
+
invalid: h,
|
|
4354
|
+
readonly: m,
|
|
4355
|
+
reset: x,
|
|
4356
|
+
status: j,
|
|
4357
|
+
stopUpdatesWatch: N,
|
|
4358
|
+
submit: P,
|
|
4359
|
+
validate: E,
|
|
4360
|
+
VvForm: D
|
|
4361
|
+
} = Or(r, t, e, l, d);
|
|
1004
4362
|
return {
|
|
1005
|
-
clear:
|
|
1006
|
-
errors:
|
|
1007
|
-
formData:
|
|
4363
|
+
clear: f,
|
|
4364
|
+
errors: k,
|
|
4365
|
+
formData: b,
|
|
1008
4366
|
formFieldInjectionKey: n,
|
|
1009
|
-
formInjectionKey:
|
|
1010
|
-
formWrapperInjectionKey:
|
|
1011
|
-
ignoreUpdates:
|
|
1012
|
-
invalid:
|
|
1013
|
-
readonly:
|
|
1014
|
-
reset:
|
|
1015
|
-
status:
|
|
1016
|
-
stopUpdatesWatch:
|
|
1017
|
-
submit:
|
|
1018
|
-
validate:
|
|
4367
|
+
formInjectionKey: t,
|
|
4368
|
+
formWrapperInjectionKey: s,
|
|
4369
|
+
ignoreUpdates: c,
|
|
4370
|
+
invalid: h,
|
|
4371
|
+
readonly: m,
|
|
4372
|
+
reset: x,
|
|
4373
|
+
status: j,
|
|
4374
|
+
stopUpdatesWatch: N,
|
|
4375
|
+
submit: P,
|
|
4376
|
+
validate: E,
|
|
1019
4377
|
wrappers: d,
|
|
1020
|
-
VvForm:
|
|
4378
|
+
VvForm: D,
|
|
1021
4379
|
VvFormField: o,
|
|
1022
|
-
VvFormFieldsGroup:
|
|
1023
|
-
VvFormTemplate:
|
|
1024
|
-
VvFormWrapper:
|
|
4380
|
+
VvFormFieldsGroup: u,
|
|
4381
|
+
VvFormTemplate: l,
|
|
4382
|
+
VvFormWrapper: i
|
|
1025
4383
|
};
|
|
1026
4384
|
}
|
|
1027
|
-
const
|
|
1028
|
-
function
|
|
1029
|
-
let
|
|
1030
|
-
return
|
|
1031
|
-
...
|
|
1032
|
-
install(
|
|
1033
|
-
|
|
4385
|
+
const Tt = Symbol("pluginInjectionKey");
|
|
4386
|
+
function Zr(r) {
|
|
4387
|
+
let e = {};
|
|
4388
|
+
return r.schema && (e = Ae(r.schema, r)), {
|
|
4389
|
+
...e,
|
|
4390
|
+
install(t, { global: s = !1 } = {}) {
|
|
4391
|
+
t.provide(Tt, r), s && (t.config.globalProperties.$vvForm = r, e?.VvForm && t.component("VvForm", e.VvForm), e?.VvFormWrapper && t.component("VvFormWrapper", e.VvFormWrapper), e?.VvFormField && t.component("VvFormField", e.VvFormField), e?.VvFormFieldsGroup && t.component("VvFormFieldsGroup", e.VvFormFieldsGroup), e?.VvFormTemplate && t.component("VvFormTemplate", e.VvFormTemplate));
|
|
1034
4392
|
}
|
|
1035
4393
|
};
|
|
1036
4394
|
}
|
|
1037
|
-
const
|
|
1038
|
-
function
|
|
1039
|
-
if (
|
|
1040
|
-
return
|
|
1041
|
-
if (!
|
|
1042
|
-
const
|
|
1043
|
-
return
|
|
4395
|
+
const ke = /* @__PURE__ */ new Map();
|
|
4396
|
+
function $r(r, e = {}) {
|
|
4397
|
+
if (e.scope && ke.has(e.scope))
|
|
4398
|
+
return ke.get(e.scope);
|
|
4399
|
+
if (!At()) {
|
|
4400
|
+
const s = Ae(r, e);
|
|
4401
|
+
return e.scope && ke.set(e.scope, s), s;
|
|
1044
4402
|
}
|
|
1045
|
-
const
|
|
1046
|
-
|
|
4403
|
+
const t = Ae(
|
|
4404
|
+
r,
|
|
1047
4405
|
{
|
|
1048
|
-
...
|
|
1049
|
-
...
|
|
4406
|
+
...re(Tt, {}),
|
|
4407
|
+
...e
|
|
1050
4408
|
}
|
|
1051
4409
|
);
|
|
1052
|
-
return
|
|
4410
|
+
return e.scope && ke.set(e.scope, t), t;
|
|
1053
4411
|
}
|
|
1054
|
-
function
|
|
1055
|
-
return
|
|
4412
|
+
function Pr(r, e = {}) {
|
|
4413
|
+
return Ae(r, e);
|
|
1056
4414
|
}
|
|
1057
4415
|
export {
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
4416
|
+
R as FormFieldType,
|
|
4417
|
+
Zr as createForm,
|
|
4418
|
+
we as defaultObjectBySchema,
|
|
4419
|
+
Pr as formType,
|
|
4420
|
+
Tt as pluginInjectionKey,
|
|
4421
|
+
$r as useForm
|
|
1064
4422
|
};
|