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