@akinon/akival 0.0.1 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js DELETED
@@ -1,2026 +0,0 @@
1
- function Le(n) {
2
- return n && n.__esModule && Object.prototype.hasOwnProperty.call(n, "default") ? n.default : n;
3
- }
4
- function S(n) {
5
- this._maxSize = n, this.clear();
6
- }
7
- S.prototype.clear = function() {
8
- this._size = 0, this._values = /* @__PURE__ */ Object.create(null);
9
- };
10
- S.prototype.get = function(n) {
11
- return this._values[n];
12
- };
13
- S.prototype.set = function(n, e) {
14
- return this._size >= this._maxSize && this.clear(), n in this._values || this._size++, this._values[n] = e;
15
- };
16
- var qe = /[^.^\]^[]+|(?=\[\]|\.\.)/g, $e = /^\d+$/, Ze = /^\d/, Ye = /[~`!#$%\^&*+=\-\[\]\\';,/{}|\\":<>\?]/g, Ge = /^\s*(['"]?)(.*?)(\1)\s*$/, ee = 512, ve = new S(ee), we = new S(ee), _e = new S(ee), k = {
17
- Cache: S,
18
- split: K,
19
- normalizePath: X,
20
- setter: function(n) {
21
- var e = X(n);
22
- return we.get(n) || we.set(n, function(r, s) {
23
- for (var i = 0, u = e.length, a = r; i < u - 1; ) {
24
- var l = e[i];
25
- if (l === "__proto__" || l === "constructor" || l === "prototype")
26
- return r;
27
- a = a[e[i++]];
28
- }
29
- a[e[i]] = s;
30
- });
31
- },
32
- getter: function(n, e) {
33
- var t = X(n);
34
- return _e.get(n) || _e.set(n, function(s) {
35
- for (var i = 0, u = t.length; i < u; )
36
- if (s != null || !e)
37
- s = s[t[i++]];
38
- else
39
- return;
40
- return s;
41
- });
42
- },
43
- join: function(n) {
44
- return n.reduce(function(e, t) {
45
- return e + (te(t) || $e.test(t) ? "[" + t + "]" : (e ? "." : "") + t);
46
- }, "");
47
- },
48
- forEach: function(n, e, t) {
49
- Xe(Array.isArray(n) ? n : K(n), e, t);
50
- }
51
- };
52
- function X(n) {
53
- return ve.get(n) || ve.set(
54
- n,
55
- K(n).map(function(e) {
56
- return e.replace(Ge, "$2");
57
- })
58
- );
59
- }
60
- function K(n) {
61
- return n.match(qe) || [""];
62
- }
63
- function Xe(n, e, t) {
64
- var r = n.length, s, i, u, a;
65
- for (i = 0; i < r; i++)
66
- s = n[i], s && (Be(s) && (s = '"' + s + '"'), a = te(s), u = !a && /^\d+$/.test(s), e.call(t, s, a, u, i, n));
67
- }
68
- function te(n) {
69
- return typeof n == "string" && n && ["'", '"'].indexOf(n.charAt(0)) !== -1;
70
- }
71
- function He(n) {
72
- return n.match(Ze) && !n.match($e);
73
- }
74
- function Ke(n) {
75
- return Ye.test(n);
76
- }
77
- function Be(n) {
78
- return !te(n) && (He(n) || Ke(n));
79
- }
80
- const Je = /[A-Z\xc0-\xd6\xd8-\xde]?[a-z\xdf-\xf6\xf8-\xff]+(?:['’](?:d|ll|m|re|s|t|ve))?(?=[\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000]|[A-Z\xc0-\xd6\xd8-\xde]|$)|(?:[A-Z\xc0-\xd6\xd8-\xde]|[^\ud800-\udfff\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\d+\u2700-\u27bfa-z\xdf-\xf6\xf8-\xffA-Z\xc0-\xd6\xd8-\xde])+(?:['’](?:D|LL|M|RE|S|T|VE))?(?=[\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000]|[A-Z\xc0-\xd6\xd8-\xde](?:[a-z\xdf-\xf6\xf8-\xff]|[^\ud800-\udfff\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\d+\u2700-\u27bfa-z\xdf-\xf6\xf8-\xffA-Z\xc0-\xd6\xd8-\xde])|$)|[A-Z\xc0-\xd6\xd8-\xde]?(?:[a-z\xdf-\xf6\xf8-\xff]|[^\ud800-\udfff\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\d+\u2700-\u27bfa-z\xdf-\xf6\xf8-\xffA-Z\xc0-\xd6\xd8-\xde])+(?:['’](?:d|ll|m|re|s|t|ve))?|[A-Z\xc0-\xd6\xd8-\xde]+(?:['’](?:D|LL|M|RE|S|T|VE))?|\d*(?:1ST|2ND|3RD|(?![123])\dTH)(?=\b|[a-z_])|\d*(?:1st|2nd|3rd|(?![123])\dth)(?=\b|[A-Z_])|\d+|(?:[\u2700-\u27bf]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff])[\ufe0e\ufe0f]?(?:[\u0300-\u036f\ufe20-\ufe2f\u20d0-\u20ff]|\ud83c[\udffb-\udfff])?(?:\u200d(?:[^\ud800-\udfff]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff])[\ufe0e\ufe0f]?(?:[\u0300-\u036f\ufe20-\ufe2f\u20d0-\u20ff]|\ud83c[\udffb-\udfff])?)*/g, L = (n) => n.match(Je) || [], q = (n) => n[0].toUpperCase() + n.slice(1), re = (n, e) => L(n).join(e).toLowerCase(), Oe = (n) => L(n).reduce(
81
- (e, t) => `${e}${e ? t[0].toUpperCase() + t.slice(1).toLowerCase() : t.toLowerCase()}`,
82
- ""
83
- ), Qe = (n) => q(Oe(n)), We = (n) => re(n, "_"), et = (n) => re(n, "-"), tt = (n) => q(re(n, " ")), rt = (n) => L(n).map(q).join(" ");
84
- var H = {
85
- words: L,
86
- upperFirst: q,
87
- camelCase: Oe,
88
- pascalCase: Qe,
89
- snakeCase: We,
90
- kebabCase: et,
91
- sentenceCase: tt,
92
- titleCase: rt
93
- }, ne = { exports: {} };
94
- ne.exports = function(n) {
95
- return ke(nt(n), n);
96
- };
97
- ne.exports.array = ke;
98
- function ke(n, e) {
99
- var t = n.length, r = new Array(t), s = {}, i = t, u = st(e), a = it(n);
100
- for (e.forEach(function(o) {
101
- if (!a.has(o[0]) || !a.has(o[1]))
102
- throw new Error("Unknown node. There is an unknown node in the supplied edges.");
103
- }); i--; )
104
- s[i] || l(n[i], i, /* @__PURE__ */ new Set());
105
- return r;
106
- function l(o, f, c) {
107
- if (c.has(o)) {
108
- var h;
109
- try {
110
- h = ", node was:" + JSON.stringify(o);
111
- } catch {
112
- h = "";
113
- }
114
- throw new Error("Cyclic dependency" + h);
115
- }
116
- if (!a.has(o))
117
- throw new Error("Found unknown node. Make sure to provided all involved nodes. Unknown node: " + JSON.stringify(o));
118
- if (!s[f]) {
119
- s[f] = !0;
120
- var d = u.get(o) || /* @__PURE__ */ new Set();
121
- if (d = Array.from(d), f = d.length) {
122
- c.add(o);
123
- do {
124
- var x = d[--f];
125
- l(x, a.get(x), c);
126
- } while (f);
127
- c.delete(o);
128
- }
129
- r[--t] = o;
130
- }
131
- }
132
- }
133
- function nt(n) {
134
- for (var e = /* @__PURE__ */ new Set(), t = 0, r = n.length; t < r; t++) {
135
- var s = n[t];
136
- e.add(s[0]), e.add(s[1]);
137
- }
138
- return Array.from(e);
139
- }
140
- function st(n) {
141
- for (var e = /* @__PURE__ */ new Map(), t = 0, r = n.length; t < r; t++) {
142
- var s = n[t];
143
- e.has(s[0]) || e.set(s[0], /* @__PURE__ */ new Set()), e.has(s[1]) || e.set(s[1], /* @__PURE__ */ new Set()), e.get(s[0]).add(s[1]);
144
- }
145
- return e;
146
- }
147
- function it(n) {
148
- for (var e = /* @__PURE__ */ new Map(), t = 0, r = n.length; t < r; t++)
149
- e.set(n[t], t);
150
- return e;
151
- }
152
- var ut = ne.exports;
153
- const at = /* @__PURE__ */ Le(ut), lt = Object.prototype.toString, ot = Error.prototype.toString, ct = RegExp.prototype.toString, ft = typeof Symbol < "u" ? Symbol.prototype.toString : () => "", ht = /^Symbol\((.*)\)(.*)$/;
154
- function dt(n) {
155
- return n != +n ? "NaN" : n === 0 && 1 / n < 0 ? "-0" : "" + n;
156
- }
157
- function Te(n, e = !1) {
158
- if (n == null || n === !0 || n === !1)
159
- return "" + n;
160
- const t = typeof n;
161
- if (t === "number")
162
- return dt(n);
163
- if (t === "string")
164
- return e ? `"${n}"` : n;
165
- if (t === "function")
166
- return "[Function " + (n.name || "anonymous") + "]";
167
- if (t === "symbol")
168
- return ft.call(n).replace(ht, "Symbol($1)");
169
- const r = lt.call(n).slice(8, -1);
170
- return r === "Date" ? isNaN(n.getTime()) ? "" + n : n.toISOString(n) : r === "Error" || n instanceof Error ? "[" + ot.call(n) + "]" : r === "RegExp" ? ct.call(n) : null;
171
- }
172
- function _(n, e) {
173
- let t = Te(n, e);
174
- return t !== null ? t : JSON.stringify(n, function(r, s) {
175
- let i = Te(this[r], e);
176
- return i !== null ? i : s;
177
- }, 2);
178
- }
179
- function Se(n) {
180
- return n == null ? [] : [].concat(n);
181
- }
182
- let Ae, pt = /\$\{\s*(\w+)\s*\}/g;
183
- Ae = Symbol.toStringTag;
184
- class y extends Error {
185
- static formatError(e, t) {
186
- const r = t.label || t.path || "this";
187
- return r !== t.path && (t = Object.assign({}, t, {
188
- path: r
189
- })), typeof e == "string" ? e.replace(pt, (s, i) => _(t[i])) : typeof e == "function" ? e(t) : e;
190
- }
191
- static isError(e) {
192
- return e && e.name === "ValidationError";
193
- }
194
- constructor(e, t, r, s, i) {
195
- super(), this.value = void 0, this.path = void 0, this.type = void 0, this.errors = void 0, this.params = void 0, this.inner = void 0, this[Ae] = "Error", this.name = "ValidationError", this.value = t, this.path = r, this.type = s, this.errors = [], this.inner = [], Se(e).forEach((u) => {
196
- if (y.isError(u)) {
197
- this.errors.push(...u.errors);
198
- const a = u.inner.length ? u.inner : [u];
199
- this.inner.push(...a);
200
- } else
201
- this.errors.push(u);
202
- }), this.message = this.errors.length > 1 ? `${this.errors.length} errors occurred` : this.errors[0], !i && Error.captureStackTrace && Error.captureStackTrace(this, y);
203
- }
204
- }
205
- let w = {
206
- default: "${path} is invalid",
207
- required: "${path} is a required field",
208
- defined: "${path} must be defined",
209
- notNull: "${path} cannot be null",
210
- oneOf: "${path} must be one of the following values: ${values}",
211
- notOneOf: "${path} must not be one of the following values: ${values}",
212
- notType: ({
213
- path: n,
214
- type: e,
215
- value: t,
216
- originalValue: r
217
- }) => {
218
- const s = r != null && r !== t ? ` (cast from the value \`${_(r, !0)}\`).` : ".";
219
- return e !== "mixed" ? `${n} must be a \`${e}\` type, but the final value was: \`${_(t, !0)}\`` + s : `${n} must match the configured type. The validated value was: \`${_(t, !0)}\`` + s;
220
- }
221
- }, g = {
222
- length: "${path} must be exactly ${length} characters",
223
- min: "${path} must be at least ${min} characters",
224
- max: "${path} must be at most ${max} characters",
225
- matches: '${path} must match the following: "${regex}"',
226
- email: "${path} must be a valid email",
227
- url: "${path} must be a valid URL",
228
- uuid: "${path} must be a valid UUID",
229
- trim: "${path} must be a trimmed string",
230
- lowercase: "${path} must be a lowercase string",
231
- uppercase: "${path} must be a upper case string"
232
- }, E = {
233
- min: "${path} must be greater than or equal to ${min}",
234
- max: "${path} must be less than or equal to ${max}",
235
- lessThan: "${path} must be less than ${less}",
236
- moreThan: "${path} must be greater than ${more}",
237
- positive: "${path} must be a positive number",
238
- negative: "${path} must be a negative number",
239
- integer: "${path} must be an integer"
240
- }, B = {
241
- min: "${path} field must be later than ${min}",
242
- max: "${path} field must be at earlier than ${max}"
243
- }, J = {
244
- isValue: "${path} field must be ${value}"
245
- }, Q = {
246
- noUnknown: "${path} field has unspecified keys: ${unknown}"
247
- }, P = {
248
- min: "${path} field must have at least ${min} items",
249
- max: "${path} field must have less than or equal to ${max} items",
250
- length: "${path} must have ${length} items"
251
- }, De = {
252
- notType: (n) => {
253
- const {
254
- path: e,
255
- value: t,
256
- spec: r
257
- } = n, s = r.types.length;
258
- if (Array.isArray(t)) {
259
- if (t.length < s)
260
- return `${e} tuple value has too few items, expected a length of ${s} but got ${t.length} for value: \`${_(t, !0)}\``;
261
- if (t.length > s)
262
- return `${e} tuple value has too many items, expected a length of ${s} but got ${t.length} for value: \`${_(t, !0)}\``;
263
- }
264
- return y.formatError(w.notType, n);
265
- }
266
- };
267
- var je = Object.assign(/* @__PURE__ */ Object.create(null), {
268
- mixed: w,
269
- string: g,
270
- number: E,
271
- date: B,
272
- object: Q,
273
- array: P,
274
- boolean: J,
275
- tuple: De
276
- });
277
- const A = (n) => n && n.__isYupSchema__;
278
- class I {
279
- static fromOptions(e, t) {
280
- if (!t.then && !t.otherwise)
281
- throw new TypeError("either `then:` or `otherwise:` is required for `when()` conditions");
282
- let {
283
- is: r,
284
- then: s,
285
- otherwise: i
286
- } = t, u = typeof r == "function" ? r : (...a) => a.every((l) => l === r);
287
- return new I(e, (a, l) => {
288
- var o;
289
- let f = u(...a) ? s : i;
290
- return (o = f == null ? void 0 : f(l)) != null ? o : l;
291
- });
292
- }
293
- constructor(e, t) {
294
- this.fn = void 0, this.refs = e, this.refs = e, this.fn = t;
295
- }
296
- resolve(e, t) {
297
- let r = this.refs.map((i) => (
298
- // TODO: ? operator here?
299
- i.getValue(t == null ? void 0 : t.value, t == null ? void 0 : t.parent, t == null ? void 0 : t.context)
300
- )), s = this.fn(r, e, t);
301
- if (s === void 0 || // @ts-ignore this can be base
302
- s === e)
303
- return e;
304
- if (!A(s))
305
- throw new TypeError("conditions must return a schema object");
306
- return s.resolve(t);
307
- }
308
- }
309
- const M = {
310
- context: "$",
311
- value: "."
312
- };
313
- function mt(n, e) {
314
- return new $(n, e);
315
- }
316
- class $ {
317
- constructor(e, t = {}) {
318
- if (this.key = void 0, this.isContext = void 0, this.isValue = void 0, this.isSibling = void 0, this.path = void 0, this.getter = void 0, this.map = void 0, typeof e != "string")
319
- throw new TypeError("ref must be a string, got: " + e);
320
- if (this.key = e.trim(), e === "")
321
- throw new TypeError("ref must be a non-empty string");
322
- this.isContext = this.key[0] === M.context, this.isValue = this.key[0] === M.value, this.isSibling = !this.isContext && !this.isValue;
323
- let r = this.isContext ? M.context : this.isValue ? M.value : "";
324
- this.path = this.key.slice(r.length), this.getter = this.path && k.getter(this.path, !0), this.map = t.map;
325
- }
326
- getValue(e, t, r) {
327
- let s = this.isContext ? r : this.isValue ? e : t;
328
- return this.getter && (s = this.getter(s || {})), this.map && (s = this.map(s)), s;
329
- }
330
- /**
331
- *
332
- * @param {*} value
333
- * @param {Object} options
334
- * @param {Object=} options.context
335
- * @param {Object=} options.parent
336
- */
337
- cast(e, t) {
338
- return this.getValue(e, t == null ? void 0 : t.parent, t == null ? void 0 : t.context);
339
- }
340
- resolve() {
341
- return this;
342
- }
343
- describe() {
344
- return {
345
- type: "ref",
346
- key: this.key
347
- };
348
- }
349
- toString() {
350
- return `Ref(${this.key})`;
351
- }
352
- static isRef(e) {
353
- return e && e.__isYupRef;
354
- }
355
- }
356
- $.prototype.__isYupRef = !0;
357
- const v = (n) => n == null;
358
- function j(n) {
359
- function e({
360
- value: t,
361
- path: r = "",
362
- options: s,
363
- originalValue: i,
364
- schema: u
365
- }, a, l) {
366
- const {
367
- name: o,
368
- test: f,
369
- params: c,
370
- message: h,
371
- skipAbsent: d
372
- } = n;
373
- let {
374
- parent: x,
375
- context: b,
376
- abortEarly: F = u.spec.abortEarly,
377
- disableStackTrace: z = u.spec.disableStackTrace
378
- } = s;
379
- function O(p) {
380
- return $.isRef(p) ? p.getValue(t, x, b) : p;
381
- }
382
- function pe(p = {}) {
383
- var be;
384
- const D = Object.assign({
385
- value: t,
386
- originalValue: i,
387
- label: u.spec.label,
388
- path: p.path || r,
389
- spec: u.spec
390
- }, c, p.params);
391
- for (const ge of Object.keys(D))
392
- D[ge] = O(D[ge]);
393
- const xe = new y(y.formatError(p.message || h, D), t, D.path, p.type || o, (be = p.disableStackTrace) != null ? be : z);
394
- return xe.params = D, xe;
395
- }
396
- const Z = F ? a : l;
397
- let Y = {
398
- path: r,
399
- parent: x,
400
- type: o,
401
- from: s.from,
402
- createError: pe,
403
- resolve: O,
404
- options: s,
405
- originalValue: i,
406
- schema: u
407
- };
408
- const G = (p) => {
409
- y.isError(p) ? Z(p) : p ? l(null) : Z(pe());
410
- }, me = (p) => {
411
- y.isError(p) ? Z(p) : a(p);
412
- };
413
- if (d && v(t))
414
- return G(!0);
415
- let V;
416
- try {
417
- var ye;
418
- if (V = f.call(Y, t, Y), typeof ((ye = V) == null ? void 0 : ye.then) == "function") {
419
- if (s.sync)
420
- throw new Error(`Validation test of type: "${Y.type}" returned a Promise during a synchronous validate. This test will finish after the validate call has returned`);
421
- return Promise.resolve(V).then(G, me);
422
- }
423
- } catch (p) {
424
- me(p);
425
- return;
426
- }
427
- G(V);
428
- }
429
- return e.OPTIONS = n, e;
430
- }
431
- function se(n, e, t, r = t) {
432
- let s, i, u;
433
- return e ? (k.forEach(e, (a, l, o) => {
434
- let f = l ? a.slice(1, a.length - 1) : a;
435
- n = n.resolve({
436
- context: r,
437
- parent: s,
438
- value: t
439
- });
440
- let c = n.type === "tuple", h = o ? parseInt(f, 10) : 0;
441
- if (n.innerType || c) {
442
- if (c && !o)
443
- throw new Error(`Yup.reach cannot implicitly index into a tuple type. the path part "${u}" must contain an index to the tuple element, e.g. "${u}[0]"`);
444
- if (t && h >= t.length)
445
- throw new Error(`Yup.reach cannot resolve an array item at index: ${a}, in the path: ${e}. because there is no value at that index. `);
446
- s = t, t = t && t[h], n = c ? n.spec.types[h] : n.innerType;
447
- }
448
- if (!o) {
449
- if (!n.fields || !n.fields[f])
450
- throw new Error(`The schema does not contain the path: ${e}. (failed at: ${u} which is a type: "${n.type}")`);
451
- s = t, t = t && t[f], n = n.fields[f];
452
- }
453
- i = f, u = l ? "[" + a + "]" : "." + a;
454
- }), {
455
- schema: n,
456
- parent: s,
457
- parentPath: i
458
- }) : {
459
- parent: s,
460
- parentPath: e,
461
- schema: n
462
- };
463
- }
464
- function yt(n, e, t, r) {
465
- return se(n, e, t, r).schema;
466
- }
467
- class U extends Set {
468
- describe() {
469
- const e = [];
470
- for (const t of this.values())
471
- e.push($.isRef(t) ? t.describe() : t);
472
- return e;
473
- }
474
- resolveAll(e) {
475
- let t = [];
476
- for (const r of this.values())
477
- t.push(e(r));
478
- return t;
479
- }
480
- clone() {
481
- return new U(this.values());
482
- }
483
- merge(e, t) {
484
- const r = this.clone();
485
- return e.forEach((s) => r.add(s)), t.forEach((s) => r.delete(s)), r;
486
- }
487
- }
488
- function C(n, e = /* @__PURE__ */ new Map()) {
489
- if (A(n) || !n || typeof n != "object")
490
- return n;
491
- if (e.has(n))
492
- return e.get(n);
493
- let t;
494
- if (n instanceof Date)
495
- t = new Date(n.getTime()), e.set(n, t);
496
- else if (n instanceof RegExp)
497
- t = new RegExp(n), e.set(n, t);
498
- else if (Array.isArray(n)) {
499
- t = new Array(n.length), e.set(n, t);
500
- for (let r = 0; r < n.length; r++)
501
- t[r] = C(n[r], e);
502
- } else if (n instanceof Map) {
503
- t = /* @__PURE__ */ new Map(), e.set(n, t);
504
- for (const [r, s] of n.entries())
505
- t.set(r, C(s, e));
506
- } else if (n instanceof Set) {
507
- t = /* @__PURE__ */ new Set(), e.set(n, t);
508
- for (const r of n)
509
- t.add(C(r, e));
510
- } else if (n instanceof Object) {
511
- t = {}, e.set(n, t);
512
- for (const [r, s] of Object.entries(n))
513
- t[r] = C(s, e);
514
- } else
515
- throw Error(`Unable to clone ${n}`);
516
- return t;
517
- }
518
- class m {
519
- constructor(e) {
520
- this.type = void 0, this.deps = [], this.tests = void 0, this.transforms = void 0, this.conditions = [], this._mutate = void 0, this.internalTests = {}, this._whitelist = new U(), this._blacklist = new U(), this.exclusiveTests = /* @__PURE__ */ Object.create(null), this._typeCheck = void 0, this.spec = void 0, this.tests = [], this.transforms = [], this.withMutation(() => {
521
- this.typeError(w.notType);
522
- }), this.type = e.type, this._typeCheck = e.check, this.spec = Object.assign({
523
- strip: !1,
524
- strict: !1,
525
- abortEarly: !0,
526
- recursive: !0,
527
- disableStackTrace: !1,
528
- nullable: !1,
529
- optional: !0,
530
- coerce: !0
531
- }, e == null ? void 0 : e.spec), this.withMutation((t) => {
532
- t.nonNullable();
533
- });
534
- }
535
- // TODO: remove
536
- get _type() {
537
- return this.type;
538
- }
539
- clone(e) {
540
- if (this._mutate)
541
- return e && Object.assign(this.spec, e), this;
542
- const t = Object.create(Object.getPrototypeOf(this));
543
- return t.type = this.type, t._typeCheck = this._typeCheck, t._whitelist = this._whitelist.clone(), t._blacklist = this._blacklist.clone(), t.internalTests = Object.assign({}, this.internalTests), t.exclusiveTests = Object.assign({}, this.exclusiveTests), t.deps = [...this.deps], t.conditions = [...this.conditions], t.tests = [...this.tests], t.transforms = [...this.transforms], t.spec = C(Object.assign({}, this.spec, e)), t;
544
- }
545
- label(e) {
546
- let t = this.clone();
547
- return t.spec.label = e, t;
548
- }
549
- meta(...e) {
550
- if (e.length === 0)
551
- return this.spec.meta;
552
- let t = this.clone();
553
- return t.spec.meta = Object.assign(t.spec.meta || {}, e[0]), t;
554
- }
555
- withMutation(e) {
556
- let t = this._mutate;
557
- this._mutate = !0;
558
- let r = e(this);
559
- return this._mutate = t, r;
560
- }
561
- concat(e) {
562
- if (!e || e === this)
563
- return this;
564
- if (e.type !== this.type && this.type !== "mixed")
565
- throw new TypeError(`You cannot \`concat()\` schema's of different types: ${this.type} and ${e.type}`);
566
- let t = this, r = e.clone();
567
- const s = Object.assign({}, t.spec, r.spec);
568
- return r.spec = s, r.internalTests = Object.assign({}, t.internalTests, r.internalTests), r._whitelist = t._whitelist.merge(e._whitelist, e._blacklist), r._blacklist = t._blacklist.merge(e._blacklist, e._whitelist), r.tests = t.tests, r.exclusiveTests = t.exclusiveTests, r.withMutation((i) => {
569
- e.tests.forEach((u) => {
570
- i.test(u.OPTIONS);
571
- });
572
- }), r.transforms = [...t.transforms, ...r.transforms], r;
573
- }
574
- isType(e) {
575
- return e == null ? !!(this.spec.nullable && e === null || this.spec.optional && e === void 0) : this._typeCheck(e);
576
- }
577
- resolve(e) {
578
- let t = this;
579
- if (t.conditions.length) {
580
- let r = t.conditions;
581
- t = t.clone(), t.conditions = [], t = r.reduce((s, i) => i.resolve(s, e), t), t = t.resolve(e);
582
- }
583
- return t;
584
- }
585
- resolveOptions(e) {
586
- var t, r, s, i;
587
- return Object.assign({}, e, {
588
- from: e.from || [],
589
- strict: (t = e.strict) != null ? t : this.spec.strict,
590
- abortEarly: (r = e.abortEarly) != null ? r : this.spec.abortEarly,
591
- recursive: (s = e.recursive) != null ? s : this.spec.recursive,
592
- disableStackTrace: (i = e.disableStackTrace) != null ? i : this.spec.disableStackTrace
593
- });
594
- }
595
- /**
596
- * Run the configured transform pipeline over an input value.
597
- */
598
- cast(e, t = {}) {
599
- let r = this.resolve(Object.assign({
600
- value: e
601
- }, t)), s = t.assert === "ignore-optionality", i = r._cast(e, t);
602
- if (t.assert !== !1 && !r.isType(i)) {
603
- if (s && v(i))
604
- return i;
605
- let u = _(e), a = _(i);
606
- throw new TypeError(`The value of ${t.path || "field"} could not be cast to a value that satisfies the schema type: "${r.type}".
607
-
608
- attempted value: ${u}
609
- ` + (a !== u ? `result of cast: ${a}` : ""));
610
- }
611
- return i;
612
- }
613
- _cast(e, t) {
614
- let r = e === void 0 ? e : this.transforms.reduce((s, i) => i.call(this, s, e, this), e);
615
- return r === void 0 && (r = this.getDefault(t)), r;
616
- }
617
- _validate(e, t = {}, r, s) {
618
- let {
619
- path: i,
620
- originalValue: u = e,
621
- strict: a = this.spec.strict
622
- } = t, l = e;
623
- a || (l = this._cast(l, Object.assign({
624
- assert: !1
625
- }, t)));
626
- let o = [];
627
- for (let f of Object.values(this.internalTests))
628
- f && o.push(f);
629
- this.runTests({
630
- path: i,
631
- value: l,
632
- originalValue: u,
633
- options: t,
634
- tests: o
635
- }, r, (f) => {
636
- if (f.length)
637
- return s(f, l);
638
- this.runTests({
639
- path: i,
640
- value: l,
641
- originalValue: u,
642
- options: t,
643
- tests: this.tests
644
- }, r, s);
645
- });
646
- }
647
- /**
648
- * Executes a set of validations, either schema, produced Tests or a nested
649
- * schema validate result.
650
- */
651
- runTests(e, t, r) {
652
- let s = !1, {
653
- tests: i,
654
- value: u,
655
- originalValue: a,
656
- path: l,
657
- options: o
658
- } = e, f = (b) => {
659
- s || (s = !0, t(b, u));
660
- }, c = (b) => {
661
- s || (s = !0, r(b, u));
662
- }, h = i.length, d = [];
663
- if (!h)
664
- return c([]);
665
- let x = {
666
- value: u,
667
- originalValue: a,
668
- path: l,
669
- options: o,
670
- schema: this
671
- };
672
- for (let b = 0; b < i.length; b++) {
673
- const F = i[b];
674
- F(x, f, function(O) {
675
- O && (Array.isArray(O) ? d.push(...O) : d.push(O)), --h <= 0 && c(d);
676
- });
677
- }
678
- }
679
- asNestedTest({
680
- key: e,
681
- index: t,
682
- parent: r,
683
- parentPath: s,
684
- originalParent: i,
685
- options: u
686
- }) {
687
- const a = e ?? t;
688
- if (a == null)
689
- throw TypeError("Must include `key` or `index` for nested validations");
690
- const l = typeof a == "number";
691
- let o = r[a];
692
- const f = Object.assign({}, u, {
693
- // Nested validations fields are always strict:
694
- // 1. parent isn't strict so the casting will also have cast inner values
695
- // 2. parent is strict in which case the nested values weren't cast either
696
- strict: !0,
697
- parent: r,
698
- value: o,
699
- originalValue: i[a],
700
- // FIXME: tests depend on `index` being passed around deeply,
701
- // we should not let the options.key/index bleed through
702
- key: void 0,
703
- // index: undefined,
704
- [l ? "index" : "key"]: a,
705
- path: l || a.includes(".") ? `${s || ""}[${o ? a : `"${a}"`}]` : (s ? `${s}.` : "") + e
706
- });
707
- return (c, h, d) => this.resolve(f)._validate(o, f, h, d);
708
- }
709
- validate(e, t) {
710
- var r;
711
- let s = this.resolve(Object.assign({}, t, {
712
- value: e
713
- })), i = (r = t == null ? void 0 : t.disableStackTrace) != null ? r : s.spec.disableStackTrace;
714
- return new Promise((u, a) => s._validate(e, t, (l, o) => {
715
- y.isError(l) && (l.value = o), a(l);
716
- }, (l, o) => {
717
- l.length ? a(new y(l, o, void 0, void 0, i)) : u(o);
718
- }));
719
- }
720
- validateSync(e, t) {
721
- var r;
722
- let s = this.resolve(Object.assign({}, t, {
723
- value: e
724
- })), i, u = (r = t == null ? void 0 : t.disableStackTrace) != null ? r : s.spec.disableStackTrace;
725
- return s._validate(e, Object.assign({}, t, {
726
- sync: !0
727
- }), (a, l) => {
728
- throw y.isError(a) && (a.value = l), a;
729
- }, (a, l) => {
730
- if (a.length)
731
- throw new y(a, e, void 0, void 0, u);
732
- i = l;
733
- }), i;
734
- }
735
- isValid(e, t) {
736
- return this.validate(e, t).then(() => !0, (r) => {
737
- if (y.isError(r))
738
- return !1;
739
- throw r;
740
- });
741
- }
742
- isValidSync(e, t) {
743
- try {
744
- return this.validateSync(e, t), !0;
745
- } catch (r) {
746
- if (y.isError(r))
747
- return !1;
748
- throw r;
749
- }
750
- }
751
- _getDefault(e) {
752
- let t = this.spec.default;
753
- return t == null ? t : typeof t == "function" ? t.call(this, e) : C(t);
754
- }
755
- getDefault(e) {
756
- return this.resolve(e || {})._getDefault(e);
757
- }
758
- default(e) {
759
- return arguments.length === 0 ? this._getDefault() : this.clone({
760
- default: e
761
- });
762
- }
763
- strict(e = !0) {
764
- return this.clone({
765
- strict: e
766
- });
767
- }
768
- nullability(e, t) {
769
- const r = this.clone({
770
- nullable: e
771
- });
772
- return r.internalTests.nullable = j({
773
- message: t,
774
- name: "nullable",
775
- test(s) {
776
- return s === null ? this.schema.spec.nullable : !0;
777
- }
778
- }), r;
779
- }
780
- optionality(e, t) {
781
- const r = this.clone({
782
- optional: e
783
- });
784
- return r.internalTests.optionality = j({
785
- message: t,
786
- name: "optionality",
787
- test(s) {
788
- return s === void 0 ? this.schema.spec.optional : !0;
789
- }
790
- }), r;
791
- }
792
- optional() {
793
- return this.optionality(!0);
794
- }
795
- defined(e = w.defined) {
796
- return this.optionality(!1, e);
797
- }
798
- nullable() {
799
- return this.nullability(!0);
800
- }
801
- nonNullable(e = w.notNull) {
802
- return this.nullability(!1, e);
803
- }
804
- required(e = w.required) {
805
- return this.clone().withMutation((t) => t.nonNullable(e).defined(e));
806
- }
807
- notRequired() {
808
- return this.clone().withMutation((e) => e.nullable().optional());
809
- }
810
- transform(e) {
811
- let t = this.clone();
812
- return t.transforms.push(e), t;
813
- }
814
- /**
815
- * Adds a test function to the schema's queue of tests.
816
- * tests can be exclusive or non-exclusive.
817
- *
818
- * - exclusive tests, will replace any existing tests of the same name.
819
- * - non-exclusive: can be stacked
820
- *
821
- * If a non-exclusive test is added to a schema with an exclusive test of the same name
822
- * the exclusive test is removed and further tests of the same name will be stacked.
823
- *
824
- * If an exclusive test is added to a schema with non-exclusive tests of the same name
825
- * the previous tests are removed and further tests of the same name will replace each other.
826
- */
827
- test(...e) {
828
- let t;
829
- if (e.length === 1 ? typeof e[0] == "function" ? t = {
830
- test: e[0]
831
- } : t = e[0] : e.length === 2 ? t = {
832
- name: e[0],
833
- test: e[1]
834
- } : t = {
835
- name: e[0],
836
- message: e[1],
837
- test: e[2]
838
- }, t.message === void 0 && (t.message = w.default), typeof t.test != "function")
839
- throw new TypeError("`test` is a required parameters");
840
- let r = this.clone(), s = j(t), i = t.exclusive || t.name && r.exclusiveTests[t.name] === !0;
841
- if (t.exclusive && !t.name)
842
- throw new TypeError("Exclusive tests must provide a unique `name` identifying the test");
843
- return t.name && (r.exclusiveTests[t.name] = !!t.exclusive), r.tests = r.tests.filter((u) => !(u.OPTIONS.name === t.name && (i || u.OPTIONS.test === s.OPTIONS.test))), r.tests.push(s), r;
844
- }
845
- when(e, t) {
846
- !Array.isArray(e) && typeof e != "string" && (t = e, e = ".");
847
- let r = this.clone(), s = Se(e).map((i) => new $(i));
848
- return s.forEach((i) => {
849
- i.isSibling && r.deps.push(i.key);
850
- }), r.conditions.push(typeof t == "function" ? new I(s, t) : I.fromOptions(s, t)), r;
851
- }
852
- typeError(e) {
853
- let t = this.clone();
854
- return t.internalTests.typeError = j({
855
- message: e,
856
- name: "typeError",
857
- skipAbsent: !0,
858
- test(r) {
859
- return this.schema._typeCheck(r) ? !0 : this.createError({
860
- params: {
861
- type: this.schema.type
862
- }
863
- });
864
- }
865
- }), t;
866
- }
867
- oneOf(e, t = w.oneOf) {
868
- let r = this.clone();
869
- return e.forEach((s) => {
870
- r._whitelist.add(s), r._blacklist.delete(s);
871
- }), r.internalTests.whiteList = j({
872
- message: t,
873
- name: "oneOf",
874
- skipAbsent: !0,
875
- test(s) {
876
- let i = this.schema._whitelist, u = i.resolveAll(this.resolve);
877
- return u.includes(s) ? !0 : this.createError({
878
- params: {
879
- values: Array.from(i).join(", "),
880
- resolved: u
881
- }
882
- });
883
- }
884
- }), r;
885
- }
886
- notOneOf(e, t = w.notOneOf) {
887
- let r = this.clone();
888
- return e.forEach((s) => {
889
- r._blacklist.add(s), r._whitelist.delete(s);
890
- }), r.internalTests.blacklist = j({
891
- message: t,
892
- name: "notOneOf",
893
- test(s) {
894
- let i = this.schema._blacklist, u = i.resolveAll(this.resolve);
895
- return u.includes(s) ? this.createError({
896
- params: {
897
- values: Array.from(i).join(", "),
898
- resolved: u
899
- }
900
- }) : !0;
901
- }
902
- }), r;
903
- }
904
- strip(e = !0) {
905
- let t = this.clone();
906
- return t.spec.strip = e, t;
907
- }
908
- /**
909
- * Return a serialized description of the schema including validations, flags, types etc.
910
- *
911
- * @param options Provide any needed context for resolving runtime schema alterations (lazy, when conditions, etc).
912
- */
913
- describe(e) {
914
- const t = (e ? this.resolve(e) : this).clone(), {
915
- label: r,
916
- meta: s,
917
- optional: i,
918
- nullable: u
919
- } = t.spec;
920
- return {
921
- meta: s,
922
- label: r,
923
- optional: i,
924
- nullable: u,
925
- default: t.getDefault(e),
926
- type: t.type,
927
- oneOf: t._whitelist.describe(),
928
- notOneOf: t._blacklist.describe(),
929
- tests: t.tests.map((l) => ({
930
- name: l.OPTIONS.name,
931
- params: l.OPTIONS.params
932
- })).filter((l, o, f) => f.findIndex((c) => c.name === l.name) === o)
933
- };
934
- }
935
- }
936
- m.prototype.__isYupSchema__ = !0;
937
- for (const n of ["validate", "validateSync"])
938
- m.prototype[`${n}At`] = function(e, t, r = {}) {
939
- const {
940
- parent: s,
941
- parentPath: i,
942
- schema: u
943
- } = se(this, e, t, r.context);
944
- return u[n](s && s[i], Object.assign({}, r, {
945
- parent: s,
946
- path: e
947
- }));
948
- };
949
- for (const n of ["equals", "is"])
950
- m.prototype[n] = m.prototype.oneOf;
951
- for (const n of ["not", "nope"])
952
- m.prototype[n] = m.prototype.notOneOf;
953
- const bt = () => !0;
954
- function Ce(n) {
955
- return new ie(n);
956
- }
957
- class ie extends m {
958
- constructor(e) {
959
- super(typeof e == "function" ? {
960
- type: "mixed",
961
- check: e
962
- } : Object.assign({
963
- type: "mixed",
964
- check: bt
965
- }, e));
966
- }
967
- }
968
- Ce.prototype = ie.prototype;
969
- function W() {
970
- return new ue();
971
- }
972
- class ue extends m {
973
- constructor() {
974
- super({
975
- type: "boolean",
976
- check(e) {
977
- return e instanceof Boolean && (e = e.valueOf()), typeof e == "boolean";
978
- }
979
- }), this.withMutation(() => {
980
- this.transform((e, t, r) => {
981
- if (r.spec.coerce && !r.isType(e)) {
982
- if (/^(true|1)$/i.test(String(e)))
983
- return !0;
984
- if (/^(false|0)$/i.test(String(e)))
985
- return !1;
986
- }
987
- return e;
988
- });
989
- });
990
- }
991
- isTrue(e = J.isValue) {
992
- return this.test({
993
- message: e,
994
- name: "is-value",
995
- exclusive: !0,
996
- params: {
997
- value: "true"
998
- },
999
- test(t) {
1000
- return v(t) || t === !0;
1001
- }
1002
- });
1003
- }
1004
- isFalse(e = J.isValue) {
1005
- return this.test({
1006
- message: e,
1007
- name: "is-value",
1008
- exclusive: !0,
1009
- params: {
1010
- value: "false"
1011
- },
1012
- test(t) {
1013
- return v(t) || t === !1;
1014
- }
1015
- });
1016
- }
1017
- default(e) {
1018
- return super.default(e);
1019
- }
1020
- defined(e) {
1021
- return super.defined(e);
1022
- }
1023
- optional() {
1024
- return super.optional();
1025
- }
1026
- required(e) {
1027
- return super.required(e);
1028
- }
1029
- notRequired() {
1030
- return super.notRequired();
1031
- }
1032
- nullable() {
1033
- return super.nullable();
1034
- }
1035
- nonNullable(e) {
1036
- return super.nonNullable(e);
1037
- }
1038
- strip(e) {
1039
- return super.strip(e);
1040
- }
1041
- }
1042
- W.prototype = ue.prototype;
1043
- let xt = (
1044
- // eslint-disable-next-line
1045
- /^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/
1046
- ), gt = (
1047
- // eslint-disable-next-line
1048
- /^((https?|ftp):)?\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i
1049
- ), vt = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i, wt = (n) => v(n) || n === n.trim(), _t = {}.toString();
1050
- function Ne() {
1051
- return new ae();
1052
- }
1053
- class ae extends m {
1054
- constructor() {
1055
- super({
1056
- type: "string",
1057
- check(e) {
1058
- return e instanceof String && (e = e.valueOf()), typeof e == "string";
1059
- }
1060
- }), this.withMutation(() => {
1061
- this.transform((e, t, r) => {
1062
- if (!r.spec.coerce || r.isType(e) || Array.isArray(e))
1063
- return e;
1064
- const s = e != null && e.toString ? e.toString() : e;
1065
- return s === _t ? e : s;
1066
- });
1067
- });
1068
- }
1069
- required(e) {
1070
- return super.required(e).withMutation((t) => t.test({
1071
- message: e || w.required,
1072
- name: "required",
1073
- skipAbsent: !0,
1074
- test: (r) => !!r.length
1075
- }));
1076
- }
1077
- notRequired() {
1078
- return super.notRequired().withMutation((e) => (e.tests = e.tests.filter((t) => t.OPTIONS.name !== "required"), e));
1079
- }
1080
- length(e, t = g.length) {
1081
- return this.test({
1082
- message: t,
1083
- name: "length",
1084
- exclusive: !0,
1085
- params: {
1086
- length: e
1087
- },
1088
- skipAbsent: !0,
1089
- test(r) {
1090
- return r.length === this.resolve(e);
1091
- }
1092
- });
1093
- }
1094
- min(e, t = g.min) {
1095
- return this.test({
1096
- message: t,
1097
- name: "min",
1098
- exclusive: !0,
1099
- params: {
1100
- min: e
1101
- },
1102
- skipAbsent: !0,
1103
- test(r) {
1104
- return r.length >= this.resolve(e);
1105
- }
1106
- });
1107
- }
1108
- max(e, t = g.max) {
1109
- return this.test({
1110
- name: "max",
1111
- exclusive: !0,
1112
- message: t,
1113
- params: {
1114
- max: e
1115
- },
1116
- skipAbsent: !0,
1117
- test(r) {
1118
- return r.length <= this.resolve(e);
1119
- }
1120
- });
1121
- }
1122
- matches(e, t) {
1123
- let r = !1, s, i;
1124
- return t && (typeof t == "object" ? {
1125
- excludeEmptyString: r = !1,
1126
- message: s,
1127
- name: i
1128
- } = t : s = t), this.test({
1129
- name: i || "matches",
1130
- message: s || g.matches,
1131
- params: {
1132
- regex: e
1133
- },
1134
- skipAbsent: !0,
1135
- test: (u) => u === "" && r || u.search(e) !== -1
1136
- });
1137
- }
1138
- email(e = g.email) {
1139
- return this.matches(xt, {
1140
- name: "email",
1141
- message: e,
1142
- excludeEmptyString: !0
1143
- });
1144
- }
1145
- url(e = g.url) {
1146
- return this.matches(gt, {
1147
- name: "url",
1148
- message: e,
1149
- excludeEmptyString: !0
1150
- });
1151
- }
1152
- uuid(e = g.uuid) {
1153
- return this.matches(vt, {
1154
- name: "uuid",
1155
- message: e,
1156
- excludeEmptyString: !1
1157
- });
1158
- }
1159
- //-- transforms --
1160
- ensure() {
1161
- return this.default("").transform((e) => e === null ? "" : e);
1162
- }
1163
- trim(e = g.trim) {
1164
- return this.transform((t) => t != null ? t.trim() : t).test({
1165
- message: e,
1166
- name: "trim",
1167
- test: wt
1168
- });
1169
- }
1170
- lowercase(e = g.lowercase) {
1171
- return this.transform((t) => v(t) ? t : t.toLowerCase()).test({
1172
- message: e,
1173
- name: "string_case",
1174
- exclusive: !0,
1175
- skipAbsent: !0,
1176
- test: (t) => v(t) || t === t.toLowerCase()
1177
- });
1178
- }
1179
- uppercase(e = g.uppercase) {
1180
- return this.transform((t) => v(t) ? t : t.toUpperCase()).test({
1181
- message: e,
1182
- name: "string_case",
1183
- exclusive: !0,
1184
- skipAbsent: !0,
1185
- test: (t) => v(t) || t === t.toUpperCase()
1186
- });
1187
- }
1188
- }
1189
- Ne.prototype = ae.prototype;
1190
- let Tt = (n) => n != +n;
1191
- function ze() {
1192
- return new le();
1193
- }
1194
- class le extends m {
1195
- constructor() {
1196
- super({
1197
- type: "number",
1198
- check(e) {
1199
- return e instanceof Number && (e = e.valueOf()), typeof e == "number" && !Tt(e);
1200
- }
1201
- }), this.withMutation(() => {
1202
- this.transform((e, t, r) => {
1203
- if (!r.spec.coerce)
1204
- return e;
1205
- let s = e;
1206
- if (typeof s == "string") {
1207
- if (s = s.replace(/\s/g, ""), s === "")
1208
- return NaN;
1209
- s = +s;
1210
- }
1211
- return r.isType(s) || s === null ? s : parseFloat(s);
1212
- });
1213
- });
1214
- }
1215
- min(e, t = E.min) {
1216
- return this.test({
1217
- message: t,
1218
- name: "min",
1219
- exclusive: !0,
1220
- params: {
1221
- min: e
1222
- },
1223
- skipAbsent: !0,
1224
- test(r) {
1225
- return r >= this.resolve(e);
1226
- }
1227
- });
1228
- }
1229
- max(e, t = E.max) {
1230
- return this.test({
1231
- message: t,
1232
- name: "max",
1233
- exclusive: !0,
1234
- params: {
1235
- max: e
1236
- },
1237
- skipAbsent: !0,
1238
- test(r) {
1239
- return r <= this.resolve(e);
1240
- }
1241
- });
1242
- }
1243
- lessThan(e, t = E.lessThan) {
1244
- return this.test({
1245
- message: t,
1246
- name: "max",
1247
- exclusive: !0,
1248
- params: {
1249
- less: e
1250
- },
1251
- skipAbsent: !0,
1252
- test(r) {
1253
- return r < this.resolve(e);
1254
- }
1255
- });
1256
- }
1257
- moreThan(e, t = E.moreThan) {
1258
- return this.test({
1259
- message: t,
1260
- name: "min",
1261
- exclusive: !0,
1262
- params: {
1263
- more: e
1264
- },
1265
- skipAbsent: !0,
1266
- test(r) {
1267
- return r > this.resolve(e);
1268
- }
1269
- });
1270
- }
1271
- positive(e = E.positive) {
1272
- return this.moreThan(0, e);
1273
- }
1274
- negative(e = E.negative) {
1275
- return this.lessThan(0, e);
1276
- }
1277
- integer(e = E.integer) {
1278
- return this.test({
1279
- name: "integer",
1280
- message: e,
1281
- skipAbsent: !0,
1282
- test: (t) => Number.isInteger(t)
1283
- });
1284
- }
1285
- truncate() {
1286
- return this.transform((e) => v(e) ? e : e | 0);
1287
- }
1288
- round(e) {
1289
- var t;
1290
- let r = ["ceil", "floor", "round", "trunc"];
1291
- if (e = ((t = e) == null ? void 0 : t.toLowerCase()) || "round", e === "trunc")
1292
- return this.truncate();
1293
- if (r.indexOf(e.toLowerCase()) === -1)
1294
- throw new TypeError("Only valid options for round() are: " + r.join(", "));
1295
- return this.transform((s) => v(s) ? s : Math[e](s));
1296
- }
1297
- }
1298
- ze.prototype = le.prototype;
1299
- const Ft = /^(\d{4}|[+-]\d{6})(?:-?(\d{2})(?:-?(\d{2}))?)?(?:[ T]?(\d{2}):?(\d{2})(?::?(\d{2})(?:[,.](\d{1,}))?)?(?:(Z)|([+-])(\d{2})(?::?(\d{2}))?)?)?$/;
1300
- function T(n, e = 0) {
1301
- return Number(n) || e;
1302
- }
1303
- function Et(n) {
1304
- const e = Ft.exec(n);
1305
- if (!e)
1306
- return Date.parse ? Date.parse(n) : Number.NaN;
1307
- const t = {
1308
- year: T(e[1]),
1309
- month: T(e[2], 1) - 1,
1310
- day: T(e[3], 1),
1311
- hour: T(e[4]),
1312
- minute: T(e[5]),
1313
- second: T(e[6]),
1314
- millisecond: e[7] ? (
1315
- // allow arbitrary sub-second precision beyond milliseconds
1316
- T(e[7].substring(0, 3))
1317
- ) : 0,
1318
- z: e[8] || void 0,
1319
- plusMinus: e[9] || void 0,
1320
- hourOffset: T(e[10]),
1321
- minuteOffset: T(e[11])
1322
- };
1323
- if (t.z === void 0 && t.plusMinus === void 0)
1324
- return new Date(t.year, t.month, t.day, t.hour, t.minute, t.second, t.millisecond).valueOf();
1325
- let r = 0;
1326
- return t.z !== "Z" && t.plusMinus !== void 0 && (r = t.hourOffset * 60 + t.minuteOffset, t.plusMinus === "+" && (r = 0 - r)), Date.UTC(t.year, t.month, t.day, t.hour, t.minute + r, t.second, t.millisecond);
1327
- }
1328
- let Ve = /* @__PURE__ */ new Date(""), $t = (n) => Object.prototype.toString.call(n) === "[object Date]";
1329
- function oe() {
1330
- return new N();
1331
- }
1332
- class N extends m {
1333
- constructor() {
1334
- super({
1335
- type: "date",
1336
- check(e) {
1337
- return $t(e) && !isNaN(e.getTime());
1338
- }
1339
- }), this.withMutation(() => {
1340
- this.transform((e, t, r) => !r.spec.coerce || r.isType(e) || e === null ? e : (e = Et(e), isNaN(e) ? N.INVALID_DATE : new Date(e)));
1341
- });
1342
- }
1343
- prepareParam(e, t) {
1344
- let r;
1345
- if ($.isRef(e))
1346
- r = e;
1347
- else {
1348
- let s = this.cast(e);
1349
- if (!this._typeCheck(s))
1350
- throw new TypeError(`\`${t}\` must be a Date or a value that can be \`cast()\` to a Date`);
1351
- r = s;
1352
- }
1353
- return r;
1354
- }
1355
- min(e, t = B.min) {
1356
- let r = this.prepareParam(e, "min");
1357
- return this.test({
1358
- message: t,
1359
- name: "min",
1360
- exclusive: !0,
1361
- params: {
1362
- min: e
1363
- },
1364
- skipAbsent: !0,
1365
- test(s) {
1366
- return s >= this.resolve(r);
1367
- }
1368
- });
1369
- }
1370
- max(e, t = B.max) {
1371
- let r = this.prepareParam(e, "max");
1372
- return this.test({
1373
- message: t,
1374
- name: "max",
1375
- exclusive: !0,
1376
- params: {
1377
- max: e
1378
- },
1379
- skipAbsent: !0,
1380
- test(s) {
1381
- return s <= this.resolve(r);
1382
- }
1383
- });
1384
- }
1385
- }
1386
- N.INVALID_DATE = Ve;
1387
- oe.prototype = N.prototype;
1388
- oe.INVALID_DATE = Ve;
1389
- function Ot(n, e = []) {
1390
- let t = [], r = /* @__PURE__ */ new Set(), s = new Set(e.map(([u, a]) => `${u}-${a}`));
1391
- function i(u, a) {
1392
- let l = k.split(u)[0];
1393
- r.add(l), s.has(`${a}-${l}`) || t.push([a, l]);
1394
- }
1395
- for (const u of Object.keys(n)) {
1396
- let a = n[u];
1397
- r.add(u), $.isRef(a) && a.isSibling ? i(a.path, u) : A(a) && "deps" in a && a.deps.forEach((l) => i(l, u));
1398
- }
1399
- return at.array(Array.from(r), t).reverse();
1400
- }
1401
- function Fe(n, e) {
1402
- let t = 1 / 0;
1403
- return n.some((r, s) => {
1404
- var i;
1405
- if ((i = e.path) != null && i.includes(r))
1406
- return t = s, !0;
1407
- }), t;
1408
- }
1409
- function Me(n) {
1410
- return (e, t) => Fe(n, e) - Fe(n, t);
1411
- }
1412
- const Pe = (n, e, t) => {
1413
- if (typeof n != "string")
1414
- return n;
1415
- let r = n;
1416
- try {
1417
- r = JSON.parse(n);
1418
- } catch {
1419
- }
1420
- return t.isType(r) ? r : n;
1421
- };
1422
- function R(n) {
1423
- if ("fields" in n) {
1424
- const e = {};
1425
- for (const [t, r] of Object.entries(n.fields))
1426
- e[t] = R(r);
1427
- return n.setFields(e);
1428
- }
1429
- if (n.type === "array") {
1430
- const e = n.optional();
1431
- return e.innerType && (e.innerType = R(e.innerType)), e;
1432
- }
1433
- return n.type === "tuple" ? n.optional().clone({
1434
- types: n.spec.types.map(R)
1435
- }) : "optional" in n ? n.optional() : n;
1436
- }
1437
- const kt = (n, e) => {
1438
- const t = [...k.normalizePath(e)];
1439
- if (t.length === 1)
1440
- return t[0] in n;
1441
- let r = t.pop(), s = k.getter(k.join(t), !0)(n);
1442
- return !!(s && r in s);
1443
- };
1444
- let Ee = (n) => Object.prototype.toString.call(n) === "[object Object]";
1445
- function St(n, e) {
1446
- let t = Object.keys(n.fields);
1447
- return Object.keys(e).filter((r) => t.indexOf(r) === -1);
1448
- }
1449
- const At = Me([]);
1450
- function Re(n) {
1451
- return new ce(n);
1452
- }
1453
- class ce extends m {
1454
- constructor(e) {
1455
- super({
1456
- type: "object",
1457
- check(t) {
1458
- return Ee(t) || typeof t == "function";
1459
- }
1460
- }), this.fields = /* @__PURE__ */ Object.create(null), this._sortErrors = At, this._nodes = [], this._excludedEdges = [], this.withMutation(() => {
1461
- e && this.shape(e);
1462
- });
1463
- }
1464
- _cast(e, t = {}) {
1465
- var r;
1466
- let s = super._cast(e, t);
1467
- if (s === void 0)
1468
- return this.getDefault(t);
1469
- if (!this._typeCheck(s))
1470
- return s;
1471
- let i = this.fields, u = (r = t.stripUnknown) != null ? r : this.spec.noUnknown, a = [].concat(this._nodes, Object.keys(s).filter((c) => !this._nodes.includes(c))), l = {}, o = Object.assign({}, t, {
1472
- parent: l,
1473
- __validating: t.__validating || !1
1474
- }), f = !1;
1475
- for (const c of a) {
1476
- let h = i[c], d = c in s;
1477
- if (h) {
1478
- let x, b = s[c];
1479
- o.path = (t.path ? `${t.path}.` : "") + c, h = h.resolve({
1480
- value: b,
1481
- context: t.context,
1482
- parent: l
1483
- });
1484
- let F = h instanceof m ? h.spec : void 0, z = F == null ? void 0 : F.strict;
1485
- if (F != null && F.strip) {
1486
- f = f || c in s;
1487
- continue;
1488
- }
1489
- x = !t.__validating || !z ? (
1490
- // TODO: use _cast, this is double resolving
1491
- h.cast(s[c], o)
1492
- ) : s[c], x !== void 0 && (l[c] = x);
1493
- } else
1494
- d && !u && (l[c] = s[c]);
1495
- (d !== c in l || l[c] !== s[c]) && (f = !0);
1496
- }
1497
- return f ? l : s;
1498
- }
1499
- _validate(e, t = {}, r, s) {
1500
- let {
1501
- from: i = [],
1502
- originalValue: u = e,
1503
- recursive: a = this.spec.recursive
1504
- } = t;
1505
- t.from = [{
1506
- schema: this,
1507
- value: u
1508
- }, ...i], t.__validating = !0, t.originalValue = u, super._validate(e, t, r, (l, o) => {
1509
- if (!a || !Ee(o)) {
1510
- s(l, o);
1511
- return;
1512
- }
1513
- u = u || o;
1514
- let f = [];
1515
- for (let c of this._nodes) {
1516
- let h = this.fields[c];
1517
- !h || $.isRef(h) || f.push(h.asNestedTest({
1518
- options: t,
1519
- key: c,
1520
- parent: o,
1521
- parentPath: t.path,
1522
- originalParent: u
1523
- }));
1524
- }
1525
- this.runTests({
1526
- tests: f,
1527
- value: o,
1528
- originalValue: u,
1529
- options: t
1530
- }, r, (c) => {
1531
- s(c.sort(this._sortErrors).concat(l), o);
1532
- });
1533
- });
1534
- }
1535
- clone(e) {
1536
- const t = super.clone(e);
1537
- return t.fields = Object.assign({}, this.fields), t._nodes = this._nodes, t._excludedEdges = this._excludedEdges, t._sortErrors = this._sortErrors, t;
1538
- }
1539
- concat(e) {
1540
- let t = super.concat(e), r = t.fields;
1541
- for (let [s, i] of Object.entries(this.fields)) {
1542
- const u = r[s];
1543
- r[s] = u === void 0 ? i : u;
1544
- }
1545
- return t.withMutation((s) => (
1546
- // XXX: excludes here is wrong
1547
- s.setFields(r, [...this._excludedEdges, ...e._excludedEdges])
1548
- ));
1549
- }
1550
- _getDefault(e) {
1551
- if ("default" in this.spec)
1552
- return super._getDefault(e);
1553
- if (!this._nodes.length)
1554
- return;
1555
- let t = {};
1556
- return this._nodes.forEach((r) => {
1557
- var s;
1558
- const i = this.fields[r];
1559
- let u = e;
1560
- (s = u) != null && s.value && (u = Object.assign({}, u, {
1561
- parent: u.value,
1562
- value: u.value[r]
1563
- })), t[r] = i && "getDefault" in i ? i.getDefault(u) : void 0;
1564
- }), t;
1565
- }
1566
- setFields(e, t) {
1567
- let r = this.clone();
1568
- return r.fields = e, r._nodes = Ot(e, t), r._sortErrors = Me(Object.keys(e)), t && (r._excludedEdges = t), r;
1569
- }
1570
- shape(e, t = []) {
1571
- return this.clone().withMutation((r) => {
1572
- let s = r._excludedEdges;
1573
- return t.length && (Array.isArray(t[0]) || (t = [t]), s = [...r._excludedEdges, ...t]), r.setFields(Object.assign(r.fields, e), s);
1574
- });
1575
- }
1576
- partial() {
1577
- const e = {};
1578
- for (const [t, r] of Object.entries(this.fields))
1579
- e[t] = "optional" in r && r.optional instanceof Function ? r.optional() : r;
1580
- return this.setFields(e);
1581
- }
1582
- deepPartial() {
1583
- return R(this);
1584
- }
1585
- pick(e) {
1586
- const t = {};
1587
- for (const r of e)
1588
- this.fields[r] && (t[r] = this.fields[r]);
1589
- return this.setFields(t, this._excludedEdges.filter(([r, s]) => e.includes(r) && e.includes(s)));
1590
- }
1591
- omit(e) {
1592
- const t = [];
1593
- for (const r of Object.keys(this.fields))
1594
- e.includes(r) || t.push(r);
1595
- return this.pick(t);
1596
- }
1597
- from(e, t, r) {
1598
- let s = k.getter(e, !0);
1599
- return this.transform((i) => {
1600
- if (!i)
1601
- return i;
1602
- let u = i;
1603
- return kt(i, e) && (u = Object.assign({}, i), r || delete u[e], u[t] = s(i)), u;
1604
- });
1605
- }
1606
- /** Parse an input JSON string to an object */
1607
- json() {
1608
- return this.transform(Pe);
1609
- }
1610
- noUnknown(e = !0, t = Q.noUnknown) {
1611
- typeof e != "boolean" && (t = e, e = !0);
1612
- let r = this.test({
1613
- name: "noUnknown",
1614
- exclusive: !0,
1615
- message: t,
1616
- test(s) {
1617
- if (s == null)
1618
- return !0;
1619
- const i = St(this.schema, s);
1620
- return !e || i.length === 0 || this.createError({
1621
- params: {
1622
- unknown: i.join(", ")
1623
- }
1624
- });
1625
- }
1626
- });
1627
- return r.spec.noUnknown = e, r;
1628
- }
1629
- unknown(e = !0, t = Q.noUnknown) {
1630
- return this.noUnknown(!e, t);
1631
- }
1632
- transformKeys(e) {
1633
- return this.transform((t) => {
1634
- if (!t)
1635
- return t;
1636
- const r = {};
1637
- for (const s of Object.keys(t))
1638
- r[e(s)] = t[s];
1639
- return r;
1640
- });
1641
- }
1642
- camelCase() {
1643
- return this.transformKeys(H.camelCase);
1644
- }
1645
- snakeCase() {
1646
- return this.transformKeys(H.snakeCase);
1647
- }
1648
- constantCase() {
1649
- return this.transformKeys((e) => H.snakeCase(e).toUpperCase());
1650
- }
1651
- describe(e) {
1652
- const t = (e ? this.resolve(e) : this).clone(), r = super.describe(e);
1653
- r.fields = {};
1654
- for (const [i, u] of Object.entries(t.fields)) {
1655
- var s;
1656
- let a = e;
1657
- (s = a) != null && s.value && (a = Object.assign({}, a, {
1658
- parent: a.value,
1659
- value: a.value[i]
1660
- })), r.fields[i] = u.describe(a);
1661
- }
1662
- return r;
1663
- }
1664
- }
1665
- Re.prototype = ce.prototype;
1666
- function Ie(n) {
1667
- return new fe(n);
1668
- }
1669
- class fe extends m {
1670
- constructor(e) {
1671
- super({
1672
- type: "array",
1673
- spec: {
1674
- types: e
1675
- },
1676
- check(t) {
1677
- return Array.isArray(t);
1678
- }
1679
- }), this.innerType = void 0, this.innerType = e;
1680
- }
1681
- _cast(e, t) {
1682
- const r = super._cast(e, t);
1683
- if (!this._typeCheck(r) || !this.innerType)
1684
- return r;
1685
- let s = !1;
1686
- const i = r.map((u, a) => {
1687
- const l = this.innerType.cast(u, Object.assign({}, t, {
1688
- path: `${t.path || ""}[${a}]`
1689
- }));
1690
- return l !== u && (s = !0), l;
1691
- });
1692
- return s ? i : r;
1693
- }
1694
- _validate(e, t = {}, r, s) {
1695
- var i;
1696
- let u = this.innerType, a = (i = t.recursive) != null ? i : this.spec.recursive;
1697
- t.originalValue != null && t.originalValue, super._validate(e, t, r, (l, o) => {
1698
- var f;
1699
- if (!a || !u || !this._typeCheck(o)) {
1700
- s(l, o);
1701
- return;
1702
- }
1703
- let c = new Array(o.length);
1704
- for (let d = 0; d < o.length; d++) {
1705
- var h;
1706
- c[d] = u.asNestedTest({
1707
- options: t,
1708
- index: d,
1709
- parent: o,
1710
- parentPath: t.path,
1711
- originalParent: (h = t.originalValue) != null ? h : e
1712
- });
1713
- }
1714
- this.runTests({
1715
- value: o,
1716
- tests: c,
1717
- originalValue: (f = t.originalValue) != null ? f : e,
1718
- options: t
1719
- }, r, (d) => s(d.concat(l), o));
1720
- });
1721
- }
1722
- clone(e) {
1723
- const t = super.clone(e);
1724
- return t.innerType = this.innerType, t;
1725
- }
1726
- /** Parse an input JSON string to an object */
1727
- json() {
1728
- return this.transform(Pe);
1729
- }
1730
- concat(e) {
1731
- let t = super.concat(e);
1732
- return t.innerType = this.innerType, e.innerType && (t.innerType = t.innerType ? (
1733
- // @ts-expect-error Lazy doesn't have concat and will break
1734
- t.innerType.concat(e.innerType)
1735
- ) : e.innerType), t;
1736
- }
1737
- of(e) {
1738
- let t = this.clone();
1739
- if (!A(e))
1740
- throw new TypeError("`array.of()` sub-schema must be a valid yup schema not: " + _(e));
1741
- return t.innerType = e, t.spec = Object.assign({}, t.spec, {
1742
- types: e
1743
- }), t;
1744
- }
1745
- length(e, t = P.length) {
1746
- return this.test({
1747
- message: t,
1748
- name: "length",
1749
- exclusive: !0,
1750
- params: {
1751
- length: e
1752
- },
1753
- skipAbsent: !0,
1754
- test(r) {
1755
- return r.length === this.resolve(e);
1756
- }
1757
- });
1758
- }
1759
- min(e, t) {
1760
- return t = t || P.min, this.test({
1761
- message: t,
1762
- name: "min",
1763
- exclusive: !0,
1764
- params: {
1765
- min: e
1766
- },
1767
- skipAbsent: !0,
1768
- // FIXME(ts): Array<typeof T>
1769
- test(r) {
1770
- return r.length >= this.resolve(e);
1771
- }
1772
- });
1773
- }
1774
- max(e, t) {
1775
- return t = t || P.max, this.test({
1776
- message: t,
1777
- name: "max",
1778
- exclusive: !0,
1779
- params: {
1780
- max: e
1781
- },
1782
- skipAbsent: !0,
1783
- test(r) {
1784
- return r.length <= this.resolve(e);
1785
- }
1786
- });
1787
- }
1788
- ensure() {
1789
- return this.default(() => []).transform((e, t) => this._typeCheck(e) ? e : t == null ? [] : [].concat(t));
1790
- }
1791
- compact(e) {
1792
- let t = e ? (r, s, i) => !e(r, s, i) : (r) => !!r;
1793
- return this.transform((r) => r != null ? r.filter(t) : r);
1794
- }
1795
- describe(e) {
1796
- const t = (e ? this.resolve(e) : this).clone(), r = super.describe(e);
1797
- if (t.innerType) {
1798
- var s;
1799
- let i = e;
1800
- (s = i) != null && s.value && (i = Object.assign({}, i, {
1801
- parent: i.value,
1802
- value: i.value[0]
1803
- })), r.innerType = t.innerType.describe(i);
1804
- }
1805
- return r;
1806
- }
1807
- }
1808
- Ie.prototype = fe.prototype;
1809
- function Ue(n) {
1810
- return new he(n);
1811
- }
1812
- class he extends m {
1813
- constructor(e) {
1814
- super({
1815
- type: "tuple",
1816
- spec: {
1817
- types: e
1818
- },
1819
- check(t) {
1820
- const r = this.spec.types;
1821
- return Array.isArray(t) && t.length === r.length;
1822
- }
1823
- }), this.withMutation(() => {
1824
- this.typeError(De.notType);
1825
- });
1826
- }
1827
- _cast(e, t) {
1828
- const {
1829
- types: r
1830
- } = this.spec, s = super._cast(e, t);
1831
- if (!this._typeCheck(s))
1832
- return s;
1833
- let i = !1;
1834
- const u = r.map((a, l) => {
1835
- const o = a.cast(s[l], Object.assign({}, t, {
1836
- path: `${t.path || ""}[${l}]`
1837
- }));
1838
- return o !== s[l] && (i = !0), o;
1839
- });
1840
- return i ? u : s;
1841
- }
1842
- _validate(e, t = {}, r, s) {
1843
- let i = this.spec.types;
1844
- super._validate(e, t, r, (u, a) => {
1845
- var l;
1846
- if (!this._typeCheck(a)) {
1847
- s(u, a);
1848
- return;
1849
- }
1850
- let o = [];
1851
- for (let [c, h] of i.entries()) {
1852
- var f;
1853
- o[c] = h.asNestedTest({
1854
- options: t,
1855
- index: c,
1856
- parent: a,
1857
- parentPath: t.path,
1858
- originalParent: (f = t.originalValue) != null ? f : e
1859
- });
1860
- }
1861
- this.runTests({
1862
- value: a,
1863
- tests: o,
1864
- originalValue: (l = t.originalValue) != null ? l : e,
1865
- options: t
1866
- }, r, (c) => s(c.concat(u), a));
1867
- });
1868
- }
1869
- describe(e) {
1870
- const t = (e ? this.resolve(e) : this).clone(), r = super.describe(e);
1871
- return r.innerType = t.spec.types.map((s, i) => {
1872
- var u;
1873
- let a = e;
1874
- return (u = a) != null && u.value && (a = Object.assign({}, a, {
1875
- parent: a.value,
1876
- value: a.value[i]
1877
- })), s.describe(a);
1878
- }), r;
1879
- }
1880
- }
1881
- Ue.prototype = he.prototype;
1882
- function Dt(n) {
1883
- return new de(n);
1884
- }
1885
- class de {
1886
- constructor(e) {
1887
- this.type = "lazy", this.__isYupSchema__ = !0, this.spec = void 0, this._resolve = (t, r = {}) => {
1888
- let s = this.builder(t, r);
1889
- if (!A(s))
1890
- throw new TypeError("lazy() functions must return a valid schema");
1891
- return this.spec.optional && (s = s.optional()), s.resolve(r);
1892
- }, this.builder = e, this.spec = {
1893
- meta: void 0,
1894
- optional: !1
1895
- };
1896
- }
1897
- clone(e) {
1898
- const t = new de(this.builder);
1899
- return t.spec = Object.assign({}, this.spec, e), t;
1900
- }
1901
- optionality(e) {
1902
- return this.clone({
1903
- optional: e
1904
- });
1905
- }
1906
- optional() {
1907
- return this.optionality(!0);
1908
- }
1909
- resolve(e) {
1910
- return this._resolve(e.value, e);
1911
- }
1912
- cast(e, t) {
1913
- return this._resolve(e, t).cast(e, t);
1914
- }
1915
- asNestedTest(e) {
1916
- let {
1917
- key: t,
1918
- index: r,
1919
- parent: s,
1920
- options: i
1921
- } = e, u = s[r ?? t];
1922
- return this._resolve(u, Object.assign({}, i, {
1923
- value: u,
1924
- parent: s
1925
- })).asNestedTest(e);
1926
- }
1927
- validate(e, t) {
1928
- return this._resolve(e, t).validate(e, t);
1929
- }
1930
- validateSync(e, t) {
1931
- return this._resolve(e, t).validateSync(e, t);
1932
- }
1933
- validateAt(e, t, r) {
1934
- return this._resolve(t, r).validateAt(e, t, r);
1935
- }
1936
- validateSyncAt(e, t, r) {
1937
- return this._resolve(t, r).validateSyncAt(e, t, r);
1938
- }
1939
- isValid(e, t) {
1940
- return this._resolve(e, t).isValid(e, t);
1941
- }
1942
- isValidSync(e, t) {
1943
- return this._resolve(e, t).isValidSync(e, t);
1944
- }
1945
- describe(e) {
1946
- return e ? this.resolve(e).describe(e) : {
1947
- type: "lazy",
1948
- meta: this.spec.meta,
1949
- label: void 0
1950
- };
1951
- }
1952
- meta(...e) {
1953
- if (e.length === 0)
1954
- return this.spec.meta;
1955
- let t = this.clone();
1956
- return t.spec.meta = Object.assign(t.spec.meta || {}, e[0]), t;
1957
- }
1958
- }
1959
- function jt(n) {
1960
- Object.keys(n).forEach((e) => {
1961
- Object.keys(n[e]).forEach((t) => {
1962
- je[e][t] = n[e][t];
1963
- });
1964
- });
1965
- }
1966
- function Ct(n, e, t) {
1967
- if (!n || !A(n.prototype))
1968
- throw new TypeError("You must provide a yup schema constructor function");
1969
- if (typeof e != "string")
1970
- throw new TypeError("A Method name must be provided");
1971
- if (typeof t != "function")
1972
- throw new TypeError("Method function must be provided");
1973
- n.prototype[e] = t;
1974
- }
1975
- const zt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1976
- __proto__: null,
1977
- ArraySchema: fe,
1978
- BooleanSchema: ue,
1979
- DateSchema: N,
1980
- MixedSchema: ie,
1981
- NumberSchema: le,
1982
- ObjectSchema: ce,
1983
- Schema: m,
1984
- StringSchema: ae,
1985
- TupleSchema: he,
1986
- ValidationError: y,
1987
- addMethod: Ct,
1988
- array: Ie,
1989
- bool: W,
1990
- boolean: W,
1991
- date: oe,
1992
- defaultLocale: je,
1993
- getIn: se,
1994
- isSchema: A,
1995
- lazy: Dt,
1996
- mixed: Ce,
1997
- number: ze,
1998
- object: Re,
1999
- printValue: _,
2000
- reach: yt,
2001
- ref: mt,
2002
- setLocale: jt,
2003
- string: Ne,
2004
- tuple: Ue
2005
- }, Symbol.toStringTag, { value: "Module" }));
2006
- export {
2007
- fe as ArraySchema,
2008
- ue as BooleanSchema,
2009
- N as DateSchema,
2010
- ie as MixedSchema,
2011
- le as NumberSchema,
2012
- ce as ObjectSchema,
2013
- m as Schema,
2014
- ae as StringSchema,
2015
- zt as akival,
2016
- Ie as array,
2017
- W as bool,
2018
- W as boolean,
2019
- oe as date,
2020
- Dt as lazy,
2021
- Ce as mixed,
2022
- ze as number,
2023
- Re as object,
2024
- mt as ref,
2025
- Ne as string
2026
- };