LogoLogo

Schema Benchmarks

    • home
      Home

    • download_2
      Download

    • timer
      Initialization
    • check_circle
      Validation
    • output_circle
      Parsing
    • swap_horiz
      Codec
    • schema
      Standard Schema
    • format_quote
      String

    • error
      Stack

    • deployed_code
      Libraries

    • article
      Blog
Expand sidebarExpand sidebar
yup/Compiled (minified)Compiled (minified)
github
GitHubGitHub
DiscordDiscord
PreferencesPreferences
schemas/libraries/yup/download_compiled/minified.js
code_off
View RawView Raw
Copy to clipboardCopy to clipboard
var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescriptor, r = Object.getOwnPropertyNames, i = Object.getPrototypeOf, a = Object.prototype.hasOwnProperty, o = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), (e = null)), t.exports), s = (e, i, o, s) => { if ((i && typeof i == `object`) || typeof i == `function`) for (var c = r(i), l = 0, u = c.length, d; l < u; l++) ((d = c[l]), !a.call(e, d) && d !== o && t(e, d, { get: ((e) => i[e]).bind(null, d), enumerable: !(s = n(i, d)) || s.enumerable, })); return e; }, c = (n, r, a) => ( (a = n == null ? {} : e(i(n))), s(r || !n || !n.__esModule ? t(a, `default`, { value: n, enumerable: !0 }) : a, n) ), l = o((e, t) => { function n(e) { ((this._maxSize = e), this.clear()); } ((n.prototype.clear = function () { ((this._size = 0), (this._values = Object.create(null))); }), (n.prototype.get = function (e) { return this._values[e]; }), (n.prototype.set = function (e, t) { return ( this._size >= this._maxSize && this.clear(), e in this._values || this._size++, (this._values[e] = t) ); })); var r = /[^.^\]^[]+|(?=\[\]|\.\.)/g, i = /^\d+$/, a = /^\d/, o = /[~`!#$%\^&*+=\-\[\]\\';,/{}|\\":<>\?]/g, s = /^\s*(['"]?)(.*?)(\1)\s*$/, c = 512, l = new n(c), u = new n(c), d = new n(c); t.exports = { Cache: n, split: p, normalizePath: f, setter: function (e) { var t = f(e); return ( u.get(e) || u.set(e, function (e, n) { for (var r = 0, i = t.length, a = e; r < i - 1;) { var o = t[r]; if (o === `__proto__` || o === `constructor` || o === `prototype`) return e; a = a[t[r++]]; } a[t[r]] = n; }) ); }, getter: function (e, t) { var n = f(e); return ( d.get(e) || d.set(e, function (e) { for (var r = 0, i = n.length; r < i;) if (e != null || !t) e = e[n[r++]]; else return; return e; }) ); }, join: function (e) { return e.reduce(function (e, t) { return e + (h(t) || i.test(t) ? `[` + t + `]` : (e ? `.` : ``) + t); }, ``); }, forEach: function (e, t, n) { m(Array.isArray(e) ? e : p(e), t, n); }, }; function f(e) { return ( l.get(e) || l.set( e, p(e).map(function (e) { return e.replace(s, `$2`); }), ) ); } function p(e) { return e.match(r) || [``]; } function m(e, t, n) { var r = e.length, i, a, o, s; for (a = 0; a < r; a++) ((i = e[a]), i && (v(i) && (i = `"` + i + `"`), (s = h(i)), (o = !s && /^\d+$/.test(i)), t.call(n, i, s, o, a, e))); } function h(e) { return typeof e == `string` && e && [`'`, `"`].indexOf(e.charAt(0)) !== -1; } function g(e) { return e.match(a) && !e.match(i); } function _(e) { return o.test(e); } function v(e) { return !h(e) && (g(e) || _(e)); } }), u = o((e, t) => { let n = /[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, r = (e) => e.match(n) || [], i = (e) => e[0].toUpperCase() + e.slice(1), a = (e, t) => r(e).join(t).toLowerCase(), o = (e) => r(e).reduce( (e, t) => `${e}${e ? t[0].toUpperCase() + t.slice(1).toLowerCase() : t.toLowerCase()}`, ``, ); t.exports = { words: r, upperFirst: i, camelCase: o, pascalCase: (e) => i(o(e)), snakeCase: (e) => a(e, `_`), kebabCase: (e) => a(e, `-`), sentenceCase: (e) => i(a(e, ` `)), titleCase: (e) => r(e).map(i).join(` `), }; }), d = o((e, t) => { ((t.exports = function (e) { return n(r(e), e); }), (t.exports.array = n)); function n(e, t) { var n = e.length, r = Array(n), o = {}, s = n, c = i(t), l = a(e); for ( t.forEach(function (e) { if (!l.has(e[0]) || !l.has(e[1])) throw Error(`Unknown node. There is an unknown node in the supplied edges.`); }); s--; ) o[s] || u(e[s], s, new Set()); return r; function u(e, t, i) { if (i.has(e)) { var a; try { a = `, node was:` + JSON.stringify(e); } catch { a = ``; } throw Error(`Cyclic dependency` + a); } if (!l.has(e)) throw Error( `Found unknown node. Make sure to provided all involved nodes. Unknown node: ` + JSON.stringify(e), ); if (!o[t]) { o[t] = !0; var s = c.get(e) || new Set(); if (((s = Array.from(s)), (t = s.length))) { i.add(e); do { var d = s[--t]; u(d, l.get(d), i); } while (t); i.delete(e); } r[--n] = e; } } } function r(e) { for (var t = new Set(), n = 0, r = e.length; n < r; n++) { var i = e[n]; (t.add(i[0]), t.add(i[1])); } return Array.from(t); } function i(e) { for (var t = new Map(), n = 0, r = e.length; n < r; n++) { var i = e[n]; (t.has(i[0]) || t.set(i[0], new Set()), t.has(i[1]) || t.set(i[1], new Set()), t.get(i[0]).add(i[1])); } return t; } function a(e) { for (var t = new Map(), n = 0, r = e.length; n < r; n++) t.set(e[n], n); return t; } }), f = l(), p = u(), m = c(d()); const h = Object.prototype.toString, g = Error.prototype.toString, _ = RegExp.prototype.toString, v = typeof Symbol < `u` ? Symbol.prototype.toString : () => ``, y = /^Symbol\((.*)\)(.*)$/; function b(e) { return e == +e ? (e === 0 && 1 / e < 0 ? `-0` : `` + e) : `NaN`; } function x(e, t = !1) { if (e == null || e === !0 || e === !1) return `` + e; let n = typeof e; if (n === `number`) return b(e); if (n === `string`) return t ? `"${e}"` : e; if (n === `function`) return `[Function ` + (e.name || `anonymous`) + `]`; if (n === `symbol`) return v.call(e).replace(y, `Symbol($1)`); let r = h.call(e).slice(8, -1); return r === `Date` ? isNaN(e.getTime()) ? `` + e : e.toISOString(e) : r === `Error` || e instanceof Error ? `[` + g.call(e) + `]` : r === `RegExp` ? _.call(e) : null; } function S(e, t) { let n = x(e, t); return n === null ? JSON.stringify( e, function (e, n) { let r = x(this[e], t); return r === null ? n : r; }, 2, ) : n; } function C(e) { return e == null ? [] : [].concat(e); } let ee, w, T, te = /\$\{\s*(\w+)\s*\}/g; ee = Symbol.toStringTag; var E = class { constructor(e, t, n, r) { ((this.name = void 0), (this.message = void 0), (this.value = void 0), (this.path = void 0), (this.type = void 0), (this.params = void 0), (this.errors = void 0), (this.inner = void 0), (this[ee] = `Error`), (this.name = `ValidationError`), (this.value = t), (this.path = n), (this.type = r), (this.errors = []), (this.inner = []), C(e).forEach((e) => { if (D.isError(e)) { this.errors.push(...e.errors); let t = e.inner.length ? e.inner : [e]; this.inner.push(...t); } else this.errors.push(e); }), (this.message = this.errors.length > 1 ? `${this.errors.length} errors occurred` : this.errors[0])); } }; ((w = Symbol.hasInstance), (T = Symbol.toStringTag)); var D = class e extends Error { static formatError(e, t) { let n = t.label || t.path || `this`; return ( (t = Object.assign({}, t, { path: n, originalPath: t.path })), typeof e == `string` ? e.replace(te, (e, n) => S(t[n])) : typeof e == `function` ? e(t) : e ); } static isError(e) { return e && e.name === `ValidationError`; } constructor(t, n, r, i, a) { let o = new E(t, n, r, i); if (a) return o; (super(), (this.value = void 0), (this.path = void 0), (this.type = void 0), (this.params = void 0), (this.errors = []), (this.inner = []), (this[T] = `Error`), (this.name = o.name), (this.message = o.message), (this.type = o.type), (this.value = o.value), (this.path = o.path), (this.errors = o.errors), (this.inner = o.inner), Error.captureStackTrace && Error.captureStackTrace(this, e)); } static [w](e) { return E[Symbol.hasInstance](e) || super[Symbol.hasInstance](e); } }; let O = { default: "${path} is invalid", required: "${path} is a required field", defined: "${path} must be defined", notNull: "${path} cannot be null", oneOf: "${path} must be one of the following values: ${values}", notOneOf: "${path} must not be one of the following values: ${values}", notType: ({ path: e, type: t, value: n, originalValue: r }) => { let i = r != null && r !== n ? ` (cast from the value \`${S(r, !0)}\`).` : `.`; return t === `mixed` ? `${e} must match the configured type. The validated value was: \`${S(n, !0)}\`` + i : `${e} must be a \`${t}\` type, but the final value was: \`${S(n, !0)}\`` + i; }, }, k = { length: "${path} must be exactly ${length} characters", min: "${path} must be at least ${min} characters", max: "${path} must be at most ${max} characters", matches: '${path} must match the following: "${regex}"', email: "${path} must be a valid email", url: "${path} must be a valid URL", uuid: "${path} must be a valid UUID", datetime: "${path} must be a valid ISO date-time", datetime_precision: "${path} must be a valid ISO date-time with a sub-second precision of exactly ${precision} digits", datetime_offset: '${path} must be a valid ISO date-time with UTC "Z" timezone', trim: "${path} must be a trimmed string", lowercase: "${path} must be a lowercase string", uppercase: "${path} must be a upper case string", }, A = { min: "${path} must be greater than or equal to ${min}", max: "${path} must be less than or equal to ${max}", lessThan: "${path} must be less than ${less}", moreThan: "${path} must be greater than ${more}", positive: "${path} must be a positive number", negative: "${path} must be a negative number", integer: "${path} must be an integer", }, j = { min: "${path} field must be later than ${min}", max: "${path} field must be at earlier than ${max}", }, M = { isValue: "${path} field must be ${value}" }, N = { noUnknown: "${path} field has unspecified keys: ${unknown}", exact: "${path} object contains unknown properties: ${properties}", }, P = { min: "${path} field must have at least ${min} items", max: "${path} field must have less than or equal to ${max} items", length: "${path} must have ${length} items", }, ne = { notType: (e) => { let { path: t, value: n, spec: r } = e, i = r.types.length; if (Array.isArray(n)) { if (n.length < i) return `${t} tuple value has too few items, expected a length of ${i} but got ${n.length} for value: \`${S(n, !0)}\``; if (n.length > i) return `${t} tuple value has too many items, expected a length of ${i} but got ${n.length} for value: \`${S(n, !0)}\``; } return D.formatError(O.notType, e); }, }; Object.assign(Object.create(null), { mixed: O, string: k, number: A, date: j, object: N, array: P, boolean: M, tuple: ne, }); const F = (e) => e && e.__isYupSchema__; var re = class e { static fromOptions(t, n) { if (!n.then && !n.otherwise) throw TypeError("either `then:` or `otherwise:` is required for `when()` conditions"); let { is: r, then: i, otherwise: a } = n, o = typeof r == `function` ? r : (...e) => e.every((e) => e === r); return new e(t, (e, t) => (o(...e) ? i : a)?.(t) ?? t); } constructor(e, t) { ((this.fn = void 0), (this.refs = e), (this.refs = e), (this.fn = t)); } resolve(e, t) { let n = this.refs.map((e) => e.getValue(t?.value, t?.parent, t?.context)), r = this.fn(n, e, t); if (r === void 0 || r === e) return e; if (!F(r)) throw TypeError(`conditions must return a schema object`); return r.resolve(t); } }; const I = { context: `$`, value: `.` }; var L = class { constructor(e, t = {}) { 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`) ) throw TypeError(`ref must be a string, got: ` + e); if (((this.key = e.trim()), e === ``)) throw TypeError(`ref must be a non-empty string`); ((this.isContext = this.key[0] === I.context), (this.isValue = this.key[0] === I.value), (this.isSibling = !this.isContext && !this.isValue)); let n = this.isContext ? I.context : this.isValue ? I.value : ``; ((this.path = this.key.slice(n.length)), (this.getter = this.path && (0, f.getter)(this.path, !0)), (this.map = t.map)); } getValue(e, t, n) { let r = this.isContext ? n : this.isValue ? e : t; return (this.getter && (r = this.getter(r || {})), this.map && (r = this.map(r)), r); } cast(e, t) { return this.getValue(e, t?.parent, t?.context); } resolve() { return this; } describe() { return { type: `ref`, key: this.key }; } toString() { return `Ref(${this.key})`; } static isRef(e) { return e && e.__isYupRef; } }; L.prototype.__isYupRef = !0; const R = (e) => e == null; function z(e) { function t({ value: t, path: n = ``, options: r, originalValue: i, schema: a }, o, s) { let { name: c, test: l, params: u, message: d, skipAbsent: f } = e, { parent: p, context: m, abortEarly: h = a.spec.abortEarly, disableStackTrace: g = a.spec.disableStackTrace, } = r, _ = { value: t, parent: p, context: m }; function v(e = {}) { let r = ie( Object.assign( { value: t, originalValue: i, label: a.spec.label, path: e.path || n, spec: a.spec, disableStackTrace: e.disableStackTrace || g, }, u, e.params, ), _, ), o = new D(D.formatError(e.message || d, r), t, r.path, e.type || c, r.disableStackTrace); return ((o.params = r), o); } let y = h ? o : s, b = { path: n, parent: p, type: c, from: r.from, createError: v, resolve(e) { return B(e, _); }, options: r, originalValue: i, schema: a, }, x = (e) => { D.isError(e) ? y(e) : e ? s(null) : y(v()); }, S = (e) => { D.isError(e) ? y(e) : o(e); }; if (f && R(t)) return x(!0); let C; try { if (((C = l.call(b, t, b)), typeof C?.then == `function`)) { if (r.sync) throw Error( `Validation test of type: "${b.type}" returned a Promise during a synchronous validate. This test will finish after the validate call has returned`, ); return Promise.resolve(C).then(x, S); } } catch (e) { S(e); return; } x(C); } return ((t.OPTIONS = e), t); } function ie(e, t) { if (!e) return e; for (let n of Object.keys(e)) e[n] = B(e[n], t); return e; } function B(e, t) { return L.isRef(e) ? e.getValue(t.value, t.parent, t.context) : e; } function ae(e, t, n, r = n) { let i, a, o; return t ? ((0, f.forEach)(t, (s, c, l) => { let u = c ? s.slice(1, s.length - 1) : s; e = e.resolve({ context: r, parent: i, value: n }); let d = e.type === `tuple`, f = l ? parseInt(u, 10) : 0; if (e.innerType || d) { if (d && !l) throw Error( `Yup.reach cannot implicitly index into a tuple type. the path part "${o}" must contain an index to the tuple element, e.g. "${o}[0]"`, ); if (n && f >= n.length) throw Error( `Yup.reach cannot resolve an array item at index: ${s}, in the path: ${t}. because there is no value at that index. `, ); ((i = n), (n &&= n[f]), (e = d ? e.spec.types[f] : e.innerType)); } if (!l) { if (!e.fields || !e.fields[u]) throw Error( `The schema does not contain the path: ${t}. (failed at: ${o} which is a type: "${e.type}")`, ); ((i = n), (n &&= n[u]), (e = e.fields[u])); } ((a = u), (o = c ? `[` + s + `]` : `.` + s)); }), { schema: e, parent: i, parentPath: a }) : { parent: i, parentPath: t, schema: e }; } var V = class e extends Set { describe() { let e = []; for (let t of this.values()) e.push(L.isRef(t) ? t.describe() : t); return e; } resolveAll(e) { let t = []; for (let n of this.values()) t.push(e(n)); return t; } clone() { return new e(this.values()); } merge(e, t) { let n = this.clone(); return (e.forEach((e) => n.add(e)), t.forEach((e) => n.delete(e)), n); } }; function H(e, t = new Map()) { if (F(e) || !e || typeof e != `object`) return e; if (t.has(e)) return t.get(e); let n; if (e instanceof Date) ((n = new Date(e.getTime())), t.set(e, n)); else if (e instanceof RegExp) ((n = new RegExp(e)), t.set(e, n)); else if (Array.isArray(e)) { ((n = Array(e.length)), t.set(e, n)); for (let r = 0; r < e.length; r++) n[r] = H(e[r], t); } else if (e instanceof Map) { ((n = new Map()), t.set(e, n)); for (let [r, i] of e.entries()) n.set(r, H(i, t)); } else if (e instanceof Set) { ((n = new Set()), t.set(e, n)); for (let r of e) n.add(H(r, t)); } else if (e instanceof Object) { ((n = {}), t.set(e, n)); for (let [r, i] of Object.entries(e)) n[r] = H(i, t); } else throw Error(`Unable to clone ${e}`); return n; } function oe(e) { if (!(e != null && e.length)) return; let t = [], n = ``, r = !1, i = !1; for (let a = 0; a < e.length; a++) { let o = e[a]; if (o === `[` && !i) { ((n &&= (t.push(...n.split(`.`).filter(Boolean)), ``)), (r = !0)); continue; } if (o === `]` && !i) { ((n &&= (/^\d+$/.test(n) ? t.push(n) : t.push(n.replace(/^"|"$/g, ``)), ``)), (r = !1)); continue; } if (o === `"`) { i = !i; continue; } if (o === `.` && !r && !i) { n &&= (t.push(n), ``); continue; } n += o; } return (n && t.push(...n.split(`.`).filter(Boolean)), t); } function se(e, t) { let n = t ? `${t}.${e.path}` : e.path; return e.errors.map((e) => ({ message: e, path: oe(n) })); } function U(e, t) { var n; if (!((n = e.inner) != null && n.length) && e.errors.length) return se(e, t); let r = t ? `${t}.${e.path}` : e.path; return e.inner.flatMap((e) => U(e, r)); } var W = class { constructor(e) { ((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 V()), (this._blacklist = new V()), (this.exclusiveTests = Object.create(null)), (this._typeCheck = void 0), (this.spec = void 0), (this.tests = []), (this.transforms = []), this.withMutation(() => { this.typeError(O.notType); }), (this.type = e.type), (this._typeCheck = e.check), (this.spec = Object.assign( { strip: !1, strict: !1, abortEarly: !0, recursive: !0, disableStackTrace: !1, nullable: !1, optional: !0, coerce: !0, }, e?.spec, )), this.withMutation((e) => { e.nonNullable(); })); } get _type() { return this.type; } clone(e) { if (this._mutate) return (e && Object.assign(this.spec, e), this); let t = Object.create(Object.getPrototypeOf(this)); 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 = H(Object.assign({}, this.spec, e))), t ); } label(e) { let t = this.clone(); return ((t.spec.label = e), t); } meta(...e) { if (e.length === 0) return this.spec.meta; let t = this.clone(); return ((t.spec.meta = Object.assign(t.spec.meta || {}, e[0])), t); } withMutation(e) { let t = this._mutate; this._mutate = !0; let n = e(this); return ((this._mutate = t), n); } concat(e) { if (!e || e === this) return this; if (e.type !== this.type && this.type !== `mixed`) throw TypeError( `You cannot \`concat()\` schema's of different types: ${this.type} and ${e.type}`, ); let t = this, n = e.clone(); return ( (n.spec = Object.assign({}, t.spec, n.spec)), (n.internalTests = Object.assign({}, t.internalTests, n.internalTests)), (n._whitelist = t._whitelist.merge(e._whitelist, e._blacklist)), (n._blacklist = t._blacklist.merge(e._blacklist, e._whitelist)), (n.tests = t.tests), (n.exclusiveTests = t.exclusiveTests), n.withMutation((t) => { e.tests.forEach((e) => { t.test(e.OPTIONS); }); }), (n.transforms = [...t.transforms, ...n.transforms]), n ); } isType(e) { return e == null ? !!((this.spec.nullable && e === null) || (this.spec.optional && e === void 0)) : this._typeCheck(e); } resolve(e) { let t = this; if (t.conditions.length) { let n = t.conditions; ((t = t.clone()), (t.conditions = []), (t = n.reduce((t, n) => n.resolve(t, e), t)), (t = t.resolve(e))); } return t; } resolveOptions(e) { return Object.assign({}, e, { from: e.from || [], strict: e.strict ?? this.spec.strict, abortEarly: e.abortEarly ?? this.spec.abortEarly, recursive: e.recursive ?? this.spec.recursive, disableStackTrace: e.disableStackTrace ?? this.spec.disableStackTrace, }); } cast(e, t = {}) { let n = this.resolve(Object.assign({}, t, { value: e })), r = t.assert === `ignore-optionality`, i = n._cast(e, t); if (t.assert !== !1 && !n.isType(i)) { if (r && R(i)) return i; let a = S(e), o = S(i); throw TypeError( `The value of ${t.path || `field`} could not be cast to a value that satisfies the schema type: "${n.type}". \n\nattempted value: ${a} \n` + (o === a ? `` : `result of cast: ${o}`), ); } return i; } _cast(e, t) { let n = e === void 0 ? e : this.transforms.reduce((n, r) => r.call(this, n, e, this, t), e); return (n === void 0 && (n = this.getDefault(t)), n); } _validate(e, t = {}, n, r) { let { path: i, originalValue: a = e, strict: o = this.spec.strict } = t, s = e; o || (s = this._cast(s, Object.assign({ assert: !1 }, t))); let c = []; for (let e of Object.values(this.internalTests)) e && c.push(e); this.runTests({ path: i, value: s, originalValue: a, options: t, tests: c }, n, (e) => { if (e.length) return r(e, s); this.runTests({ path: i, value: s, originalValue: a, options: t, tests: this.tests }, n, r); }); } runTests(e, t, n) { let r = !1, { tests: i, value: a, originalValue: o, path: s, options: c } = e, l = (e) => { r || ((r = !0), t(e, a)); }, u = (e) => { r || ((r = !0), n(e, a)); }, d = i.length, f = []; if (!d) return u([]); let p = { value: a, originalValue: o, path: s, options: c, schema: this }; for (let e = 0; e < i.length; e++) { let t = i[e]; t(p, l, function (e) { (e && (Array.isArray(e) ? f.push(...e) : f.push(e)), --d <= 0 && u(f)); }); } } asNestedTest({ key: e, index: t, parent: n, parentPath: r, originalParent: i, options: a }) { let o = e ?? t; if (o == null) throw TypeError("Must include `key` or `index` for nested validations"); let s = typeof o == `number`, c = n[o], l = Object.assign({}, a, { strict: !0, parent: n, value: c, originalValue: i[o], key: void 0, [s ? `index` : `key`]: o, path: s || o.includes(`.`) ? `${r || ``}[${s ? o : `"${o}"`}]` : (r ? `${r}.` : ``) + e, }); return (e, t, n) => this.resolve(l)._validate(c, l, t, n); } validate(e, t) { let n = this.resolve(Object.assign({}, t, { value: e })), r = t?.disableStackTrace ?? n.spec.disableStackTrace; return new Promise((i, a) => n._validate( e, t, (e, t) => { (D.isError(e) && (e.value = t), a(e)); }, (e, t) => { e.length ? a(new D(e, t, void 0, void 0, r)) : i(t); }, ), ); } validateSync(e, t) { let n = this.resolve(Object.assign({}, t, { value: e })), r, i = t?.disableStackTrace ?? n.spec.disableStackTrace; return ( n._validate( e, Object.assign({}, t, { sync: !0 }), (e, t) => { throw (D.isError(e) && (e.value = t), e); }, (t, n) => { if (t.length) throw new D(t, e, void 0, void 0, i); r = n; }, ), r ); } isValid(e, t) { return this.validate(e, t).then( () => !0, (e) => { if (D.isError(e)) return !1; throw e; }, ); } isValidSync(e, t) { try { return (this.validateSync(e, t), !0); } catch (e) { if (D.isError(e)) return !1; throw e; } } _getDefault(e) { let t = this.spec.default; return t == null ? t : typeof t == `function` ? t.call(this, e) : H(t); } getDefault(e) { return this.resolve(e || {})._getDefault(e); } default(e) { return arguments.length === 0 ? this._getDefault() : this.clone({ default: e }); } strict(e = !0) { return this.clone({ strict: e }); } nullability(e, t) { let n = this.clone({ nullable: e }); return ( (n.internalTests.nullable = z({ message: t, name: `nullable`, test(e) { return e !== null || this.schema.spec.nullable; }, })), n ); } optionality(e, t) { let n = this.clone({ optional: e }); return ( (n.internalTests.optionality = z({ message: t, name: `optionality`, test(e) { return e !== void 0 || this.schema.spec.optional; }, })), n ); } optional() { return this.optionality(!0); } defined(e = O.defined) { return this.optionality(!1, e); } nullable() { return this.nullability(!0); } nonNullable(e = O.notNull) { return this.nullability(!1, e); } required(e = O.required) { return this.clone().withMutation((t) => t.nonNullable(e).defined(e)); } notRequired() { return this.clone().withMutation((e) => e.nullable().optional()); } transform(e) { let t = this.clone(); return (t.transforms.push(e), t); } test(...e) { let t; if ( ((t = e.length === 1 ? typeof e[0] == `function` ? { test: e[0] } : e[0] : e.length === 2 ? { name: e[0], test: e[1] } : { name: e[0], message: e[1], test: e[2] }), t.message === void 0 && (t.message = O.default), typeof t.test != `function`) ) throw TypeError("`test` is a required parameters"); let n = this.clone(), r = z(t), i = t.exclusive || (t.name && n.exclusiveTests[t.name] === !0); if (t.exclusive && !t.name) throw TypeError("Exclusive tests must provide a unique `name` identifying the test"); return ( t.name && (n.exclusiveTests[t.name] = !!t.exclusive), (n.tests = n.tests.filter( (e) => !(e.OPTIONS.name === t.name && (i || e.OPTIONS.test === r.OPTIONS.test)), )), n.tests.push(r), n ); } when(e, t) { !Array.isArray(e) && typeof e != `string` && ((t = e), (e = `.`)); let n = this.clone(), r = C(e).map((e) => new L(e)); return ( r.forEach((e) => { e.isSibling && n.deps.push(e.key); }), n.conditions.push(typeof t == `function` ? new re(r, t) : re.fromOptions(r, t)), n ); } typeError(e) { let t = this.clone(); return ( (t.internalTests.typeError = z({ message: e, name: `typeError`, skipAbsent: !0, test(e) { return this.schema._typeCheck(e) ? !0 : this.createError({ params: { type: this.schema.type } }); }, })), t ); } oneOf(e, t = O.oneOf) { let n = this.clone(); return ( e.forEach((e) => { (n._whitelist.add(e), n._blacklist.delete(e)); }), (n.internalTests.whiteList = z({ message: t, name: `oneOf`, skipAbsent: !0, test(e) { let t = this.schema._whitelist, n = t.resolveAll(this.resolve); return n.includes(e) ? !0 : this.createError({ params: { values: Array.from(t).join(`, `), resolved: n } }); }, })), n ); } notOneOf(e, t = O.notOneOf) { let n = this.clone(); return ( e.forEach((e) => { (n._blacklist.add(e), n._whitelist.delete(e)); }), (n.internalTests.blacklist = z({ message: t, name: `notOneOf`, test(e) { let t = this.schema._blacklist, n = t.resolveAll(this.resolve); return ( !n.includes(e) || this.createError({ params: { values: Array.from(t).join(`, `), resolved: n } }) ); }, })), n ); } strip(e = !0) { let t = this.clone(); return ((t.spec.strip = e), t); } describe(e) { let t = (e ? this.resolve(e) : this).clone(), { label: n, meta: r, optional: i, nullable: a } = t.spec; return { meta: r, label: n, optional: i, nullable: a, default: t.getDefault(e), type: t.type, oneOf: t._whitelist.describe(), notOneOf: t._blacklist.describe(), tests: t.tests .filter((e, t, n) => n.findIndex((t) => t.OPTIONS.name === e.OPTIONS.name) === t) .map((t) => { let n = t.OPTIONS.params && e ? ie(Object.assign({}, t.OPTIONS.params), e) : t.OPTIONS.params; return { name: t.OPTIONS.name, params: n }; }), }; } get "~standard"() { let e = this; return { version: 1, vendor: `yup`, async validate(t) { try { return { value: await e.validate(t, { abortEarly: !1 }) }; } catch (e) { if (e instanceof D) return { issues: U(e) }; throw e; } }, }; } }; W.prototype.__isYupSchema__ = !0; for (let e of [`validate`, `validateSync`]) W.prototype[`${e}At`] = function (t, n, r = {}) { let { parent: i, parentPath: a, schema: o } = ae(this, t, n, r.context); return o[e](i && i[a], Object.assign({}, r, { parent: i, path: t })); }; for (let e of [`equals`, `is`]) W.prototype[e] = W.prototype.oneOf; for (let e of [`not`, `nope`]) W.prototype[e] = W.prototype.notOneOf; const ce = () => !0; ((class extends W { constructor(e) { super( typeof e == `function` ? { type: `mixed`, check: e } : Object.assign({ type: `mixed`, check: ce }, e), ); } }).prototype, class extends W { constructor() { (super({ type: `boolean`, check(e) { return (e instanceof Boolean && (e = e.valueOf()), typeof e == `boolean`); }, }), this.withMutation(() => { this.transform((e, t) => { if (this.spec.coerce && !this.isType(e)) { if (/^(true|1)$/i.test(String(e))) return !0; if (/^(false|0)$/i.test(String(e))) return !1; } return e; }); })); } isTrue(e = M.isValue) { return this.test({ message: e, name: `is-value`, exclusive: !0, params: { value: `true` }, test(e) { return R(e) || e === !0; }, }); } isFalse(e = M.isValue) { return this.test({ message: e, name: `is-value`, exclusive: !0, params: { value: `false` }, test(e) { return R(e) || e === !1; }, }); } default(e) { return super.default(e); } defined(e) { return super.defined(e); } optional() { return super.optional(); } required(e) { return super.required(e); } notRequired() { return super.notRequired(); } nullable() { return super.nullable(); } nonNullable(e) { return super.nonNullable(e); } strip(e) { return super.strip(e); } }.prototype); const le = /^(\d{4}|[+-]\d{6})(?:-?(\d{2})(?:-?(\d{2}))?)?(?:[ T]?(\d{2}):?(\d{2})(?::?(\d{2})(?:[,.](\d{1,}))?)?(?:(Z)|([+-])(\d{2})(?::?(\d{2}))?)?)?$/; function ue(e) { let t = G(e); if (!t) return Date.parse ? Date.parse(e) : NaN; if (t.z === void 0 && t.plusMinus === void 0) return new Date(t.year, t.month, t.day, t.hour, t.minute, t.second, t.millisecond).valueOf(); let n = 0; return ( t.z !== `Z` && t.plusMinus !== void 0 && ((n = t.hourOffset * 60 + t.minuteOffset), t.plusMinus === `+` && (n = 0 - n)), Date.UTC(t.year, t.month, t.day, t.hour, t.minute + n, t.second, t.millisecond) ); } function G(e) { let t = le.exec(e); return t ? { year: K(t[1]), month: K(t[2], 1) - 1, day: K(t[3], 1), hour: K(t[4]), minute: K(t[5]), second: K(t[6]), millisecond: t[7] ? K(t[7].substring(0, 3)) : 0, precision: t[7]?.length ?? void 0, z: t[8] || void 0, plusMinus: t[9] || void 0, hourOffset: K(t[10]), minuteOffset: K(t[11]), } : null; } function K(e, t = 0) { return Number(e) || t; } let de = /^[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])?)*$/, fe = /^((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, pe = /^(?:[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, me = RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}(:?\\d{2})?)|Z)$`), he = (e) => R(e) || e === e.trim(), ge = {}.toString(); function q() { return new _e(); } var _e = class extends W { constructor() { (super({ type: `string`, check(e) { return (e instanceof String && (e = e.valueOf()), typeof e == `string`); }, }), this.withMutation(() => { this.transform((e, t) => { if (!this.spec.coerce || this.isType(e) || Array.isArray(e)) return e; let n = e != null && e.toString ? e.toString() : e; return n === ge ? e : n; }); })); } required(e) { return super .required(e) .withMutation((t) => t.test({ message: e || O.required, name: `required`, skipAbsent: !0, test: (e) => !!e.length, }), ); } notRequired() { return super .notRequired() .withMutation((e) => ((e.tests = e.tests.filter((e) => e.OPTIONS.name !== `required`)), e)); } length(e, t = k.length) { return this.test({ message: t, name: `length`, exclusive: !0, params: { length: e }, skipAbsent: !0, test(t) { return t.length === this.resolve(e); }, }); } min(e, t = k.min) { return this.test({ message: t, name: `min`, exclusive: !0, params: { min: e }, skipAbsent: !0, test(t) { return t.length >= this.resolve(e); }, }); } max(e, t = k.max) { return this.test({ name: `max`, exclusive: !0, message: t, params: { max: e }, skipAbsent: !0, test(t) { return t.length <= this.resolve(e); }, }); } matches(e, t) { let n = !1, r, i; return ( t && (typeof t == `object` ? ({ excludeEmptyString: n = !1, message: r, name: i } = t) : (r = t)), this.test({ name: i || `matches`, message: r || k.matches, params: { regex: e }, skipAbsent: !0, test: (t) => (t === `` && n) || t.search(e) !== -1, }) ); } email(e = k.email) { return this.matches(de, { name: `email`, message: e, excludeEmptyString: !0 }); } url(e = k.url) { return this.matches(fe, { name: `url`, message: e, excludeEmptyString: !0 }); } uuid(e = k.uuid) { return this.matches(pe, { name: `uuid`, message: e, excludeEmptyString: !1 }); } datetime(e) { let t = ``, n, r; return ( e && (typeof e == `object` ? ({ message: t = ``, allowOffset: n = !1, precision: r = void 0 } = e) : (t = e)), this.matches(me, { name: `datetime`, message: t || k.datetime, excludeEmptyString: !0 }) .test({ name: `datetime_offset`, message: t || k.datetime_offset, params: { allowOffset: n }, skipAbsent: !0, test: (e) => { if (!e || n) return !0; let t = G(e); return t ? !!t.z : !1; }, }) .test({ name: `datetime_precision`, message: t || k.datetime_precision, params: { precision: r }, skipAbsent: !0, test: (e) => { if (!e || r == null) return !0; let t = G(e); return t ? t.precision === r : !1; }, }) ); } ensure() { return this.default(``).transform((e) => (e === null ? `` : e)); } trim(e = k.trim) { return this.transform((e) => (e == null ? e : e.trim())).test({ message: e, name: `trim`, test: he, }); } lowercase(e = k.lowercase) { return this.transform((e) => (R(e) ? e : e.toLowerCase())).test({ message: e, name: `string_case`, exclusive: !0, skipAbsent: !0, test: (e) => R(e) || e === e.toLowerCase(), }); } uppercase(e = k.uppercase) { return this.transform((e) => (R(e) ? e : e.toUpperCase())).test({ message: e, name: `string_case`, exclusive: !0, skipAbsent: !0, test: (e) => R(e) || e === e.toUpperCase(), }); } }; q.prototype = _e.prototype; let ve = (e) => e != +e; function J() { return new ye(); } var ye = class extends W { constructor() { (super({ type: `number`, check(e) { return (e instanceof Number && (e = e.valueOf()), typeof e == `number` && !ve(e)); }, }), this.withMutation(() => { this.transform((e, t) => { if (!this.spec.coerce) return e; let n = e; if (typeof n == `string`) { if (((n = n.replace(/\s/g, ``)), n === ``)) return NaN; n = +n; } return this.isType(n) || n === null ? n : parseFloat(n); }); })); } min(e, t = A.min) { return this.test({ message: t, name: `min`, exclusive: !0, params: { min: e }, skipAbsent: !0, test(t) { return t >= this.resolve(e); }, }); } max(e, t = A.max) { return this.test({ message: t, name: `max`, exclusive: !0, params: { max: e }, skipAbsent: !0, test(t) { return t <= this.resolve(e); }, }); } lessThan(e, t = A.lessThan) { return this.test({ message: t, name: `max`, exclusive: !0, params: { less: e }, skipAbsent: !0, test(t) { return t < this.resolve(e); }, }); } moreThan(e, t = A.moreThan) { return this.test({ message: t, name: `min`, exclusive: !0, params: { more: e }, skipAbsent: !0, test(t) { return t > this.resolve(e); }, }); } positive(e = A.positive) { return this.moreThan(0, e); } negative(e = A.negative) { return this.lessThan(0, e); } integer(e = A.integer) { return this.test({ name: `integer`, message: e, skipAbsent: !0, test: (e) => Number.isInteger(e), }); } truncate() { return this.transform((e) => (R(e) ? e : e | 0)); } round(e) { let t = [`ceil`, `floor`, `round`, `trunc`]; if (((e = e?.toLowerCase() || `round`), e === `trunc`)) return this.truncate(); if (t.indexOf(e.toLowerCase()) === -1) throw TypeError(`Only valid options for round() are: ` + t.join(`, `)); return this.transform((t) => (R(t) ? t : Math[e](t))); } }; J.prototype = ye.prototype; let be = new Date(``), xe = (e) => Object.prototype.toString.call(e) === `[object Date]`; function Y() { return new X(); } var X = class e extends W { constructor() { (super({ type: `date`, check(e) { return xe(e) && !isNaN(e.getTime()); }, }), this.withMutation(() => { this.transform((t, n) => !this.spec.coerce || this.isType(t) || t === null ? t : ((t = ue(t)), isNaN(t) ? e.INVALID_DATE : new Date(t)), ); })); } prepareParam(e, t) { let n; if (L.isRef(e)) n = e; else { let r = this.cast(e); if (!this._typeCheck(r)) throw TypeError(`\`${t}\` must be a Date or a value that can be \`cast()\` to a Date`); n = r; } return n; } min(e, t = j.min) { let n = this.prepareParam(e, `min`); return this.test({ message: t, name: `min`, exclusive: !0, params: { min: e }, skipAbsent: !0, test(e) { return e >= this.resolve(n); }, }); } max(e, t = j.max) { let n = this.prepareParam(e, `max`); return this.test({ message: t, name: `max`, exclusive: !0, params: { max: e }, skipAbsent: !0, test(e) { return e <= this.resolve(n); }, }); } }; ((X.INVALID_DATE = be), (Y.prototype = X.prototype), (Y.INVALID_DATE = be)); function Se(e, t = []) { let n = [], r = new Set(), i = new Set(t.map(([e, t]) => `${e}-${t}`)); function a(e, t) { let a = (0, f.split)(e)[0]; (r.add(a), i.has(`${t}-${a}`) || n.push([t, a])); } for (let t of Object.keys(e)) { let n = e[t]; (r.add(t), L.isRef(n) && n.isSibling ? a(n.path, t) : F(n) && `deps` in n && n.deps.forEach((e) => a(e, t))); } return m.default.array(Array.from(r), n).reverse(); } function Ce(e, t) { let n = 1 / 0; return ( e.some((e, r) => { var i; if ((i = t.path) != null && i.includes(e)) return ((n = r), !0); }), n ); } function we(e) { return (t, n) => Ce(e, t) - Ce(e, n); } const Te = (e, t, n) => { if (typeof e != `string`) return e; let r = e; try { r = JSON.parse(e); } catch {} return n.isType(r) ? r : e; }; function Z(e) { if (`fields` in e) { let t = {}; for (let [n, r] of Object.entries(e.fields)) t[n] = Z(r); return e.setFields(t); } if (e.type === `array`) { let t = e.optional(); return ((t.innerType &&= Z(t.innerType)), t); } return e.type === `tuple` ? e.optional().clone({ types: e.spec.types.map(Z) }) : `optional` in e ? e.optional() : e; } const Ee = (e, t) => { let n = [...(0, f.normalizePath)(t)]; if (n.length === 1) return n[0] in e; let r = n.pop(), i = (0, f.getter)((0, f.join)(n), !0)(e); return !!(i && r in i); }; let De = (e) => Object.prototype.toString.call(e) === `[object Object]`; function Oe(e, t) { let n = Object.keys(e.fields); return Object.keys(t).filter((e) => n.indexOf(e) === -1); } const ke = we([]); function Q(e) { return new Ae(e); } var Ae = class extends W { constructor(e) { (super({ type: `object`, check(e) { return De(e) || typeof e == `function`; }, }), (this.fields = Object.create(null)), (this._sortErrors = ke), (this._nodes = []), (this._excludedEdges = []), this.withMutation(() => { e && this.shape(e); })); } _cast(e, t = {}) { let n = super._cast(e, t); if (n === void 0) return this.getDefault(t); if (!this._typeCheck(n)) return n; let r = this.fields, i = t.stripUnknown ?? this.spec.noUnknown, a = [].concat( this._nodes, Object.keys(n).filter((e) => !this._nodes.includes(e)), ), o = {}, s = Object.assign({}, t, { parent: o, __validating: t.__validating || !1 }), c = !1; for (let e of a) { let a = r[e], l = e in n, u = n[e]; if (a) { let r; ((s.path = (t.path ? `${t.path}.` : ``) + e), (a = a.resolve({ value: u, context: t.context, parent: o }))); let i = a instanceof W ? a.spec : void 0, l = i?.strict; if (i != null && i.strip) { c ||= e in n; continue; } ((r = !t.__validating || !l ? a.cast(u, s) : u), r !== void 0 && (o[e] = r)); } else l && !i && (o[e] = u); (l !== e in o || o[e] !== u) && (c = !0); } return c ? o : n; } _validate(e, t = {}, n, r) { let { from: i = [], originalValue: a = e, recursive: o = this.spec.recursive } = t; ((t.from = [{ schema: this, value: a }, ...i]), (t.__validating = !0), (t.originalValue = a), super._validate(e, t, n, (e, i) => { if (!o || !De(i)) { r(e, i); return; } a ||= i; let s = []; for (let e of this._nodes) { let n = this.fields[e]; !n || L.isRef(n) || s.push( n.asNestedTest({ options: t, key: e, parent: i, parentPath: t.path, originalParent: a, }), ); } this.runTests({ tests: s, value: i, originalValue: a, options: t }, n, (t) => { r(t.sort(this._sortErrors).concat(e), i); }); })); } clone(e) { let t = super.clone(e); return ( (t.fields = Object.assign({}, this.fields)), (t._nodes = this._nodes), (t._excludedEdges = this._excludedEdges), (t._sortErrors = this._sortErrors), t ); } concat(e) { let t = super.concat(e), n = t.fields; for (let [e, t] of Object.entries(this.fields)) { let r = n[e]; n[e] = r === void 0 ? t : r; } return t.withMutation((t) => t.setFields(n, [...this._excludedEdges, ...e._excludedEdges])); } _getDefault(e) { if (`default` in this.spec) return super._getDefault(e); if (!this._nodes.length) return; let t = {}; return ( this._nodes.forEach((n) => { var r; let i = this.fields[n], a = e; ((r = a) != null && r.value && (a = Object.assign({}, a, { parent: a.value, value: a.value[n] })), (t[n] = i && `getDefault` in i ? i.getDefault(a) : void 0)); }), t ); } setFields(e, t) { let n = this.clone(); return ( (n.fields = e), (n._nodes = Se(e, t)), (n._sortErrors = we(Object.keys(e))), t && (n._excludedEdges = t), n ); } shape(e, t = []) { return this.clone().withMutation((n) => { let r = n._excludedEdges; return ( t.length && (Array.isArray(t[0]) || (t = [t]), (r = [...n._excludedEdges, ...t])), n.setFields(Object.assign(n.fields, e), r) ); }); } partial() { let e = {}; for (let [t, n] of Object.entries(this.fields)) e[t] = `optional` in n && n.optional instanceof Function ? n.optional() : n; return this.setFields(e); } deepPartial() { return Z(this); } pick(e) { let t = {}; for (let n of e) this.fields[n] && (t[n] = this.fields[n]); return this.setFields( t, this._excludedEdges.filter(([t, n]) => e.includes(t) && e.includes(n)), ); } omit(e) { let t = []; for (let n of Object.keys(this.fields)) e.includes(n) || t.push(n); return this.pick(t); } from(e, t, n) { let r = (0, f.getter)(e, !0); return this.transform((i) => { if (!i) return i; let a = i; return (Ee(i, e) && ((a = Object.assign({}, i)), n || delete a[e], (a[t] = r(i))), a); }); } json() { return this.transform(Te); } exact(e) { return this.test({ name: `exact`, exclusive: !0, message: e || N.exact, test(e) { if (e == null) return !0; let t = Oe(this.schema, e); return t.length === 0 || this.createError({ params: { properties: t.join(`, `) } }); }, }); } stripUnknown() { return this.clone({ noUnknown: !0 }); } noUnknown(e = !0, t = N.noUnknown) { typeof e != `boolean` && ((t = e), (e = !0)); let n = this.test({ name: `noUnknown`, exclusive: !0, message: t, test(t) { if (t == null) return !0; let n = Oe(this.schema, t); return !e || n.length === 0 || this.createError({ params: { unknown: n.join(`, `) } }); }, }); return ((n.spec.noUnknown = e), n); } unknown(e = !0, t = N.noUnknown) { return this.noUnknown(!e, t); } transformKeys(e) { return this.transform((t) => { if (!t) return t; let n = {}; for (let r of Object.keys(t)) n[e(r)] = t[r]; return n; }); } camelCase() { return this.transformKeys(p.camelCase); } snakeCase() { return this.transformKeys(p.snakeCase); } constantCase() { return this.transformKeys((e) => (0, p.snakeCase)(e).toUpperCase()); } describe(e) { let t = (e ? this.resolve(e) : this).clone(), n = super.describe(e); n.fields = {}; for (let [i, a] of Object.entries(t.fields)) { var r; let t = e; ((r = t) != null && r.value && (t = Object.assign({}, t, { parent: t.value, value: t.value[i] })), (n.fields[i] = a.describe(t))); } return n; } }; Q.prototype = Ae.prototype; function $(e) { return new je(e); } var je = class extends W { constructor(e) { (super({ type: `array`, spec: { types: e }, check(e) { return Array.isArray(e); }, }), (this.innerType = void 0), (this.innerType = e)); } _cast(e, t) { let n = super._cast(e, t); if (!this._typeCheck(n) || !this.innerType) return n; let r = !1, i = n.map((e, i) => { let a = this.innerType.cast( e, Object.assign({}, t, { path: `${t.path || ``}[${i}]`, parent: n, originalValue: e, value: e, index: i, }), ); return (a !== e && (r = !0), a); }); return r ? i : n; } _validate(e, t = {}, n, r) { let i = this.innerType, a = t.recursive ?? this.spec.recursive; (t.originalValue != null && t.originalValue, super._validate(e, t, n, (o, s) => { if (!a || !i || !this._typeCheck(s)) { r(o, s); return; } let c = Array(s.length); for (let n = 0; n < s.length; n++) c[n] = i.asNestedTest({ options: t, index: n, parent: s, parentPath: t.path, originalParent: t.originalValue ?? e, }); this.runTests( { value: s, tests: c, originalValue: t.originalValue ?? e, options: t }, n, (e) => r(e.concat(o), s), ); })); } clone(e) { let t = super.clone(e); return ((t.innerType = this.innerType), t); } json() { return this.transform(Te); } concat(e) { let t = super.concat(e); return ( (t.innerType = this.innerType), e.innerType && (t.innerType = t.innerType ? t.innerType.concat(e.innerType) : e.innerType), t ); } of(e) { let t = this.clone(); if (!F(e)) throw TypeError("`array.of()` sub-schema must be a valid yup schema not: " + S(e)); return ((t.innerType = e), (t.spec = Object.assign({}, t.spec, { types: e })), t); } length(e, t = P.length) { return this.test({ message: t, name: `length`, exclusive: !0, params: { length: e }, skipAbsent: !0, test(t) { return t.length === this.resolve(e); }, }); } min(e, t) { return ( (t ||= P.min), this.test({ message: t, name: `min`, exclusive: !0, params: { min: e }, skipAbsent: !0, test(t) { return t.length >= this.resolve(e); }, }) ); } max(e, t) { return ( (t ||= P.max), this.test({ message: t, name: `max`, exclusive: !0, params: { max: e }, skipAbsent: !0, test(t) { return t.length <= this.resolve(e); }, }) ); } ensure() { return this.default(() => []).transform((e, t) => this._typeCheck(e) ? e : t == null ? [] : [].concat(t), ); } compact(e) { let t = e ? (t, n, r) => !e(t, n, r) : (e) => !!e; return this.transform((e) => (e == null ? e : e.filter(t))); } describe(e) { let t = (e ? this.resolve(e) : this).clone(), n = super.describe(e); if (t.innerType) { var r; let i = e; ((r = i) != null && r.value && (i = Object.assign({}, i, { parent: i.value, value: i.value[0] })), (n.innerType = t.innerType.describe(i))); } return n; } }; (($.prototype = je.prototype), class extends W { constructor(e) { (super({ type: `tuple`, spec: { types: e }, check(e) { let t = this.spec.types; return Array.isArray(e) && e.length === t.length; }, }), this.withMutation(() => { this.typeError(ne.notType); })); } _cast(e, t) { let { types: n } = this.spec, r = super._cast(e, t); if (!this._typeCheck(r)) return r; let i = !1, a = n.map((e, n) => { let a = e.cast( r[n], Object.assign({}, t, { path: `${t.path || ``}[${n}]`, parent: r, originalValue: r[n], value: r[n], index: n, }), ); return (a !== r[n] && (i = !0), a); }); return i ? a : r; } _validate(e, t = {}, n, r) { let i = this.spec.types; super._validate(e, t, n, (a, o) => { if (!this._typeCheck(o)) { r(a, o); return; } let s = []; for (let [n, r] of i.entries()) s[n] = r.asNestedTest({ options: t, index: n, parent: o, parentPath: t.path, originalParent: t.originalValue ?? e, }); this.runTests( { value: o, tests: s, originalValue: t.originalValue ?? e, options: t }, n, (e) => r(e.concat(a), o), ); }); } describe(e) { let t = (e ? this.resolve(e) : this).clone(), n = super.describe(e); return ( (n.innerType = t.spec.types.map((t, n) => { var r; let i = e; return ( (r = i) != null && r.value && (i = Object.assign({}, i, { parent: i.value, value: i.value[n] })), t.describe(i) ); })), n ); } }.prototype); const Me = Q({ id: J().required(), created: Y().required(), title: q().min(1).max(100).required(), type: q().oneOf([`jpg`, `png`]).required(), size: J().required(), url: q().url().required(), }), Ne = Q({ id: J().required(), stars: J().min(0).max(5).required(), title: q().min(1).max(100).required(), text: q().min(1).max(1e3).required(), images: $(Me).required(), }); Q({ id: J().required(), created: Y().required(), title: q().min(1).max(100).required(), brand: q().min(1).max(30).required(), description: q().min(1).max(500).required(), price: J().min(1).max(1e4).required(), discount: J().min(1).max(100).required().nullable(), quantity: J().min(0).max(10).required(), tags: $(q().min(1).max(30).required()).required(), images: $(Me).required(), ratings: $(Ne).required(), }).validate({});
Created by eskimojo for Open Circle

Preferences

Style
Theme
NPM browser
Code ligatures