@me1a/ui 1.2.1 → 1.2.3
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/{hook-forms/index → example}/hook-forms/index.d.ts +2 -0
- package/dist/example/index.cjs.js.map +1 -0
- package/dist/example/index.es.js.map +1 -0
- package/dist/example/mui/index.d.ts +1 -0
- package/dist/{index → hook-forms}/hook-forms/index.d.ts +2 -0
- package/dist/hook-forms/{index/index.cjs.js → index.cjs.js} +2780 -21
- package/dist/hook-forms/index.cjs.js.map +1 -0
- package/dist/hook-forms/{index/index.es.js → index.es.js} +2779 -22
- package/dist/hook-forms/index.es.js.map +1 -0
- package/dist/hook-forms/mui/index.d.ts +1 -0
- package/dist/{index/index.cjs.js → index.cjs.js} +2780 -21
- package/dist/index.cjs.js.map +1 -0
- package/dist/{index/index.es.js → index.es.js} +2779 -22
- package/dist/index.es.js.map +1 -0
- package/dist/mui/example/simple.d.ts +4 -0
- package/dist/mui/hook-forms/form-provider.d.ts +8 -0
- package/dist/{example/index → mui}/hook-forms/index.d.ts +2 -0
- package/dist/mui/hook-forms/rhf-autocomplete.d.ts +11 -0
- package/dist/mui/hook-forms/rhf-checkbox.d.ts +19 -0
- package/dist/mui/hook-forms/rhf-radio-group.d.ts +13 -0
- package/dist/mui/hook-forms/rhf-select.d.ts +11 -0
- package/dist/mui/hook-forms/rhf-slider.d.ts +7 -0
- package/dist/mui/hook-forms/rhf-switch.d.ts +7 -0
- package/dist/mui/hook-forms/rhf-text-field.d.ts +6 -0
- package/dist/mui/index.cjs.js +54943 -0
- package/dist/mui/index.cjs.js.map +1 -0
- package/dist/mui/index.d.ts +2 -0
- package/dist/mui/index.es.js +54463 -0
- package/dist/mui/index.es.js.map +1 -0
- package/dist/mui/mui/index.d.ts +1 -0
- package/package.json +26 -2
- package/dist/example/index/index.cjs.js.map +0 -1
- package/dist/example/index/index.es.js.map +0 -1
- package/dist/hook-forms/index/index.cjs.js.map +0 -1
- package/dist/hook-forms/index/index.es.js.map +0 -1
- package/dist/index/index.cjs.js.map +0 -1
- package/dist/index/index.es.js.map +0 -1
- /package/dist/example/{index/example → example}/index.d.ts +0 -0
- /package/dist/example/{index/example → example}/simple.d.ts +0 -0
- /package/dist/example/{index/hook-forms → hook-forms}/form-provider.d.ts +0 -0
- /package/dist/example/{index/hook-forms → hook-forms}/rhf-autocomplete.d.ts +0 -0
- /package/dist/example/{index/hook-forms → hook-forms}/rhf-checkbox.d.ts +0 -0
- /package/dist/example/{index/hook-forms → hook-forms}/rhf-radio-group.d.ts +0 -0
- /package/dist/example/{index/hook-forms → hook-forms}/rhf-select.d.ts +0 -0
- /package/dist/example/{index/hook-forms → hook-forms}/rhf-slider.d.ts +0 -0
- /package/dist/example/{index/hook-forms → hook-forms}/rhf-switch.d.ts +0 -0
- /package/dist/example/{index/hook-forms → hook-forms}/rhf-text-field.d.ts +0 -0
- /package/dist/example/{index/index.cjs.js → index.cjs.js} +0 -0
- /package/dist/example/{index/index.d.ts → index.d.ts} +0 -0
- /package/dist/example/{index/index.es.js → index.es.js} +0 -0
- /package/dist/{hook-forms/index/example → example}/simple.d.ts +0 -0
- /package/dist/hook-forms/{index/example → example}/index.d.ts +0 -0
- /package/dist/{index → hook-forms}/example/simple.d.ts +0 -0
- /package/dist/hook-forms/{index/hook-forms/form-provider.d.ts → form-provider.d.ts} +0 -0
- /package/dist/{index → hook-forms}/hook-forms/form-provider.d.ts +0 -0
- /package/dist/hook-forms/{index/hook-forms → hook-forms}/rhf-autocomplete.d.ts +0 -0
- /package/dist/hook-forms/{index/hook-forms → hook-forms}/rhf-checkbox.d.ts +0 -0
- /package/dist/hook-forms/{index/hook-forms → hook-forms}/rhf-radio-group.d.ts +0 -0
- /package/dist/hook-forms/{index/hook-forms → hook-forms}/rhf-select.d.ts +0 -0
- /package/dist/hook-forms/{index/hook-forms → hook-forms}/rhf-slider.d.ts +0 -0
- /package/dist/hook-forms/{index/hook-forms → hook-forms}/rhf-switch.d.ts +0 -0
- /package/dist/hook-forms/{index/hook-forms → hook-forms}/rhf-text-field.d.ts +0 -0
- /package/dist/hook-forms/{index/index.d.ts → index.d.ts} +0 -0
- /package/dist/{index/hook-forms → hook-forms}/rhf-autocomplete.d.ts +0 -0
- /package/dist/{index/hook-forms → hook-forms}/rhf-checkbox.d.ts +0 -0
- /package/dist/{index/hook-forms → hook-forms}/rhf-radio-group.d.ts +0 -0
- /package/dist/{index/hook-forms → hook-forms}/rhf-select.d.ts +0 -0
- /package/dist/{index/hook-forms → hook-forms}/rhf-slider.d.ts +0 -0
- /package/dist/{index/hook-forms → hook-forms}/rhf-switch.d.ts +0 -0
- /package/dist/{index/hook-forms → hook-forms}/rhf-text-field.d.ts +0 -0
- /package/dist/{index/index.d.ts → index.d.ts} +0 -0
- /package/dist/{index → mui}/example/index.d.ts +0 -0
|
@@ -1389,12 +1389,12 @@ var isDateObject = (value) => value instanceof Date;
|
|
|
1389
1389
|
var isNullOrUndefined = (value) => value == null;
|
|
1390
1390
|
|
|
1391
1391
|
const isObjectType = (value) => typeof value === 'object';
|
|
1392
|
-
var isObject = (value) => !isNullOrUndefined(value) &&
|
|
1392
|
+
var isObject$1 = (value) => !isNullOrUndefined(value) &&
|
|
1393
1393
|
!Array.isArray(value) &&
|
|
1394
1394
|
isObjectType(value) &&
|
|
1395
1395
|
!isDateObject(value);
|
|
1396
1396
|
|
|
1397
|
-
var getEventValue = (event) => isObject(event) && event.target
|
|
1397
|
+
var getEventValue = (event) => isObject$1(event) && event.target
|
|
1398
1398
|
? isCheckBoxInput(event.target)
|
|
1399
1399
|
? event.target.checked
|
|
1400
1400
|
: event.target.value
|
|
@@ -1406,7 +1406,7 @@ var isNameInFieldArray = (names, name) => names.has(getNodeParentName(name));
|
|
|
1406
1406
|
|
|
1407
1407
|
var isPlainObject$1 = (tempObject) => {
|
|
1408
1408
|
const prototypeCopy = tempObject.constructor && tempObject.constructor.prototype;
|
|
1409
|
-
return (isObject(prototypeCopy) && prototypeCopy.hasOwnProperty('isPrototypeOf'));
|
|
1409
|
+
return (isObject$1(prototypeCopy) && prototypeCopy.hasOwnProperty('isPrototypeOf'));
|
|
1410
1410
|
};
|
|
1411
1411
|
|
|
1412
1412
|
var isWeb = typeof window !== 'undefined' &&
|
|
@@ -1423,7 +1423,7 @@ function cloneObject(data) {
|
|
|
1423
1423
|
copy = new Set(data);
|
|
1424
1424
|
}
|
|
1425
1425
|
else if (!(isWeb && (data instanceof Blob || data instanceof FileList)) &&
|
|
1426
|
-
(isArray || isObject(data))) {
|
|
1426
|
+
(isArray || isObject$1(data))) {
|
|
1427
1427
|
copy = isArray ? [] : {};
|
|
1428
1428
|
if (!isArray && !isPlainObject$1(data)) {
|
|
1429
1429
|
copy = data;
|
|
@@ -1447,7 +1447,7 @@ var compact = (value) => Array.isArray(value) ? value.filter(Boolean) : [];
|
|
|
1447
1447
|
var isUndefined = (val) => val === undefined;
|
|
1448
1448
|
|
|
1449
1449
|
var get = (object, path, defaultValue) => {
|
|
1450
|
-
if (!path || !isObject(object)) {
|
|
1450
|
+
if (!path || !isObject$1(object)) {
|
|
1451
1451
|
return defaultValue;
|
|
1452
1452
|
}
|
|
1453
1453
|
const result = compact(path.split(/[,[\].]+?/)).reduce((result, key) => isNullOrUndefined(result) ? result : result[key], object);
|
|
@@ -1475,7 +1475,7 @@ var set = (object, path, value) => {
|
|
|
1475
1475
|
if (index !== lastIndex) {
|
|
1476
1476
|
const objValue = object[key];
|
|
1477
1477
|
newValue =
|
|
1478
|
-
isObject(objValue) || Array.isArray(objValue)
|
|
1478
|
+
isObject$1(objValue) || Array.isArray(objValue)
|
|
1479
1479
|
? objValue
|
|
1480
1480
|
: !isNaN(+tempPath[index + 1])
|
|
1481
1481
|
? []
|
|
@@ -1598,7 +1598,7 @@ var getProxyFormState = (formState, control, localProxyFormState, isRoot = true)
|
|
|
1598
1598
|
return result;
|
|
1599
1599
|
};
|
|
1600
1600
|
|
|
1601
|
-
var isEmptyObject = (value) => isObject(value) && !Object.keys(value).length;
|
|
1601
|
+
var isEmptyObject = (value) => isObject$1(value) && !Object.keys(value).length;
|
|
1602
1602
|
|
|
1603
1603
|
var shouldRenderFormState = (formStateData, _proxyFormState, updateFormState, isRoot) => {
|
|
1604
1604
|
updateFormState(formStateData);
|
|
@@ -2103,7 +2103,7 @@ const iterateFieldsByAction = (fields, action, fieldsNames, abortEarly) => {
|
|
|
2103
2103
|
}
|
|
2104
2104
|
}
|
|
2105
2105
|
}
|
|
2106
|
-
else if (isObject(currentField)) {
|
|
2106
|
+
else if (isObject$1(currentField)) {
|
|
2107
2107
|
if (iterateFieldsByAction(currentField, action)) {
|
|
2108
2108
|
break;
|
|
2109
2109
|
}
|
|
@@ -2189,7 +2189,7 @@ function getValidateError(result, ref, type = 'validate') {
|
|
|
2189
2189
|
}
|
|
2190
2190
|
}
|
|
2191
2191
|
|
|
2192
|
-
var getValueAndMessage = (validationData) => isObject(validationData) && !isRegex(validationData)
|
|
2192
|
+
var getValueAndMessage = (validationData) => isObject$1(validationData) && !isRegex(validationData)
|
|
2193
2193
|
? validationData
|
|
2194
2194
|
: {
|
|
2195
2195
|
value: validationData,
|
|
@@ -2342,7 +2342,7 @@ var validateField = async (field, formValues, validateAllFieldCriteria, shouldUs
|
|
|
2342
2342
|
}
|
|
2343
2343
|
}
|
|
2344
2344
|
}
|
|
2345
|
-
else if (isObject(validate)) {
|
|
2345
|
+
else if (isObject$1(validate)) {
|
|
2346
2346
|
let validationResult = {};
|
|
2347
2347
|
for (const key in validate) {
|
|
2348
2348
|
if (!isEmptyObject(validationResult) && !validateAllFieldCriteria) {
|
|
@@ -2452,7 +2452,7 @@ function unset(object, path) {
|
|
|
2452
2452
|
delete childObject[key];
|
|
2453
2453
|
}
|
|
2454
2454
|
if (index !== 0 &&
|
|
2455
|
-
((isObject(childObject) && isEmptyObject(childObject)) ||
|
|
2455
|
+
((isObject$1(childObject) && isEmptyObject(childObject)) ||
|
|
2456
2456
|
(Array.isArray(childObject) && isEmptyArray(childObject)))) {
|
|
2457
2457
|
unset(object, paths.slice(0, -1));
|
|
2458
2458
|
}
|
|
@@ -2745,7 +2745,7 @@ function deepEqual(object1, object2) {
|
|
|
2745
2745
|
if (key !== 'ref') {
|
|
2746
2746
|
const val2 = object2[key];
|
|
2747
2747
|
if ((isDateObject(val1) && isDateObject(val2)) ||
|
|
2748
|
-
(isObject(val1) && isObject(val2)) ||
|
|
2748
|
+
(isObject$1(val1) && isObject$1(val2)) ||
|
|
2749
2749
|
(Array.isArray(val1) && Array.isArray(val2))
|
|
2750
2750
|
? !deepEqual(val1, val2)
|
|
2751
2751
|
: val1 !== val2) {
|
|
@@ -2773,10 +2773,10 @@ var objectHasFunction = (data) => {
|
|
|
2773
2773
|
|
|
2774
2774
|
function markFieldsDirty(data, fields = {}) {
|
|
2775
2775
|
const isParentNodeArray = Array.isArray(data);
|
|
2776
|
-
if (isObject(data) || isParentNodeArray) {
|
|
2776
|
+
if (isObject$1(data) || isParentNodeArray) {
|
|
2777
2777
|
for (const key in data) {
|
|
2778
2778
|
if (Array.isArray(data[key]) ||
|
|
2779
|
-
(isObject(data[key]) && !objectHasFunction(data[key]))) {
|
|
2779
|
+
(isObject$1(data[key]) && !objectHasFunction(data[key]))) {
|
|
2780
2780
|
fields[key] = Array.isArray(data[key]) ? [] : {};
|
|
2781
2781
|
markFieldsDirty(data[key], fields[key]);
|
|
2782
2782
|
}
|
|
@@ -2789,10 +2789,10 @@ function markFieldsDirty(data, fields = {}) {
|
|
|
2789
2789
|
}
|
|
2790
2790
|
function getDirtyFieldsFromDefaultValues(data, formValues, dirtyFieldsFromValues) {
|
|
2791
2791
|
const isParentNodeArray = Array.isArray(data);
|
|
2792
|
-
if (isObject(data) || isParentNodeArray) {
|
|
2792
|
+
if (isObject$1(data) || isParentNodeArray) {
|
|
2793
2793
|
for (const key in data) {
|
|
2794
2794
|
if (Array.isArray(data[key]) ||
|
|
2795
|
-
(isObject(data[key]) && !objectHasFunction(data[key]))) {
|
|
2795
|
+
(isObject$1(data[key]) && !objectHasFunction(data[key]))) {
|
|
2796
2796
|
if (isUndefined(formValues) ||
|
|
2797
2797
|
isPrimitive(dirtyFieldsFromValues[key])) {
|
|
2798
2798
|
dirtyFieldsFromValues[key] = Array.isArray(data[key])
|
|
@@ -2864,7 +2864,7 @@ var getRuleValue = (rule) => isUndefined(rule)
|
|
|
2864
2864
|
? rule
|
|
2865
2865
|
: isRegex(rule)
|
|
2866
2866
|
? rule.source
|
|
2867
|
-
: isObject(rule)
|
|
2867
|
+
: isObject$1(rule)
|
|
2868
2868
|
? isRegex(rule.value)
|
|
2869
2869
|
? rule.value.source
|
|
2870
2870
|
: rule.value
|
|
@@ -2874,7 +2874,7 @@ const ASYNC_FUNCTION = 'AsyncFunction';
|
|
|
2874
2874
|
var hasPromiseValidation = (fieldReference) => (!fieldReference || !fieldReference.validate) &&
|
|
2875
2875
|
!!((isFunction(fieldReference.validate) &&
|
|
2876
2876
|
fieldReference.validate.constructor.name === ASYNC_FUNCTION) ||
|
|
2877
|
-
(isObject(fieldReference.validate) &&
|
|
2877
|
+
(isObject$1(fieldReference.validate) &&
|
|
2878
2878
|
Object.values(fieldReference.validate).find((validateFunction) => validateFunction.constructor.name === ASYNC_FUNCTION)));
|
|
2879
2879
|
|
|
2880
2880
|
var hasValidation = (options) => options.mount &&
|
|
@@ -2959,7 +2959,7 @@ function createFormControl(props = {}) {
|
|
|
2959
2959
|
disabled: _options.disabled || false,
|
|
2960
2960
|
};
|
|
2961
2961
|
let _fields = {};
|
|
2962
|
-
let _defaultValues = isObject(_options.defaultValues) || isObject(_options.values)
|
|
2962
|
+
let _defaultValues = isObject$1(_options.defaultValues) || isObject$1(_options.values)
|
|
2963
2963
|
? cloneObject(_options.defaultValues || _options.values) || {}
|
|
2964
2964
|
: {};
|
|
2965
2965
|
let _formValues = _options.shouldUnregister
|
|
@@ -3294,7 +3294,7 @@ function createFormControl(props = {}) {
|
|
|
3294
3294
|
const fieldName = `${name}.${fieldKey}`;
|
|
3295
3295
|
const field = get(_fields, fieldName);
|
|
3296
3296
|
(_names.array.has(name) ||
|
|
3297
|
-
isObject(fieldValue) ||
|
|
3297
|
+
isObject$1(fieldValue) ||
|
|
3298
3298
|
(field && !field._f)) &&
|
|
3299
3299
|
!isDateObject(fieldValue)
|
|
3300
3300
|
? setValues(fieldName, fieldValue, options)
|
|
@@ -5229,7 +5229,7 @@ function requirePropTypes () {
|
|
|
5229
5229
|
var propTypesExports = /*@__PURE__*/ requirePropTypes();
|
|
5230
5230
|
var PropTypes = /*@__PURE__*/getDefaultExportFromCjs(propTypesExports);
|
|
5231
5231
|
|
|
5232
|
-
function r(e){var t,f,n="";if("string"==typeof e||"number"==typeof e)n+=e;else if("object"==typeof e)if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(f=r(e[t]))&&(n&&(n+=" "),n+=f);}else for(f in e)e[f]&&(n&&(n+=" "),n+=f);return n}function clsx(){for(var e,t,f=0,n="",o=arguments.length;f<o;f++)(e=arguments[f])&&(t=r(e))&&(n&&(n+=" "),n+=t);return n}
|
|
5232
|
+
function r$1(e){var t,f,n="";if("string"==typeof e||"number"==typeof e)n+=e;else if("object"==typeof e)if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(f=r$1(e[t]))&&(n&&(n+=" "),n+=f);}else for(f in e)e[f]&&(n&&(n+=" "),n+=f);return n}function clsx(){for(var e,t,f=0,n="",o=arguments.length;f<o;f++)(e=arguments[f])&&(t=r$1(e))&&(n&&(n+=" "),n+=t);return n}
|
|
5233
5233
|
|
|
5234
5234
|
/* eslint no-restricted-syntax: 0, prefer-template: 0, guard-for-in: 0
|
|
5235
5235
|
---
|
|
@@ -27228,5 +27228,2762 @@ function FormProvider({
|
|
|
27228
27228
|
});
|
|
27229
27229
|
}
|
|
27230
27230
|
|
|
27231
|
-
|
|
27231
|
+
const s=(e,s,o)=>{if(e&&"reportValidity"in e){const r=get(o,s);e.setCustomValidity(r&&r.message||""),e.reportValidity();}},o$1=(t,e)=>{for(const o in e.fields){const r=e.fields[o];r&&r.ref&&"reportValidity"in r.ref?s(r.ref,o,t):r.refs&&r.refs.forEach(e=>s(e,o,t));}},r=(s,r)=>{r.shouldUseNativeValidation&&o$1(s,r);const f={};for(const o in s){const n=get(r.fields,o),a=Object.assign(s[o]||{},{ref:n&&n.ref});if(i(r.names||Object.keys(s),o)){const s=Object.assign({},get(f,o));set(s,"root",a),set(f,o,s);}else set(f,o,a);}return f},i=(t,e)=>t.some(t=>t.startsWith(e+"."));
|
|
27232
|
+
|
|
27233
|
+
function o(o,n,a){return void 0===n&&(n={}),void 0===a&&(a={}),function(s,i,c){try{return Promise.resolve(function(t,r){try{var u=(n.context&&"development"===process.env.NODE_ENV&&console.warn("You should not used the yup options context. Please, use the 'useForm' context object instead"),Promise.resolve(o["sync"===a.mode?"validateSync":"validate"](s,Object.assign({abortEarly:!1},n,{context:i}))).then(function(t){return c.shouldUseNativeValidation&&o$1({},c),{values:a.raw?s:t,errors:{}}}));}catch(e){return r(e)}return u&&u.then?u.then(void 0,r):u}(0,function(e){if(!e.inner)throw e;return {values:{},errors:r((o=e,n=!c.shouldUseNativeValidation&&"all"===c.criteriaMode,(o.inner||[]).reduce(function(e,t){if(e[t.path]||(e[t.path]={message:t.message,type:t.type}),n){var o=e[t.path].types,a=o&&o[t.type];e[t.path]=appendErrors(t.path,n,e,t.type,a?[].concat(a,t.message):t.message);}return e},{})),c)};var o,n;}))}catch(e){return Promise.reject(e)}}}
|
|
27234
|
+
|
|
27235
|
+
/**
|
|
27236
|
+
* Based on Kendo UI Core expression code <https://github.com/telerik/kendo-ui-core#license-information>
|
|
27237
|
+
*/
|
|
27238
|
+
|
|
27239
|
+
var propertyExpr;
|
|
27240
|
+
var hasRequiredPropertyExpr;
|
|
27241
|
+
|
|
27242
|
+
function requirePropertyExpr () {
|
|
27243
|
+
if (hasRequiredPropertyExpr) return propertyExpr;
|
|
27244
|
+
hasRequiredPropertyExpr = 1;
|
|
27245
|
+
|
|
27246
|
+
function Cache(maxSize) {
|
|
27247
|
+
this._maxSize = maxSize;
|
|
27248
|
+
this.clear();
|
|
27249
|
+
}
|
|
27250
|
+
Cache.prototype.clear = function () {
|
|
27251
|
+
this._size = 0;
|
|
27252
|
+
this._values = Object.create(null);
|
|
27253
|
+
};
|
|
27254
|
+
Cache.prototype.get = function (key) {
|
|
27255
|
+
return this._values[key]
|
|
27256
|
+
};
|
|
27257
|
+
Cache.prototype.set = function (key, value) {
|
|
27258
|
+
this._size >= this._maxSize && this.clear();
|
|
27259
|
+
if (!(key in this._values)) this._size++;
|
|
27260
|
+
|
|
27261
|
+
return (this._values[key] = value)
|
|
27262
|
+
};
|
|
27263
|
+
|
|
27264
|
+
var SPLIT_REGEX = /[^.^\]^[]+|(?=\[\]|\.\.)/g,
|
|
27265
|
+
DIGIT_REGEX = /^\d+$/,
|
|
27266
|
+
LEAD_DIGIT_REGEX = /^\d/,
|
|
27267
|
+
SPEC_CHAR_REGEX = /[~`!#$%\^&*+=\-\[\]\\';,/{}|\\":<>\?]/g,
|
|
27268
|
+
CLEAN_QUOTES_REGEX = /^\s*(['"]?)(.*?)(\1)\s*$/,
|
|
27269
|
+
MAX_CACHE_SIZE = 512;
|
|
27270
|
+
|
|
27271
|
+
var pathCache = new Cache(MAX_CACHE_SIZE),
|
|
27272
|
+
setCache = new Cache(MAX_CACHE_SIZE),
|
|
27273
|
+
getCache = new Cache(MAX_CACHE_SIZE);
|
|
27274
|
+
|
|
27275
|
+
propertyExpr = {
|
|
27276
|
+
Cache: Cache,
|
|
27277
|
+
|
|
27278
|
+
split: split,
|
|
27279
|
+
|
|
27280
|
+
normalizePath: normalizePath,
|
|
27281
|
+
|
|
27282
|
+
setter: function (path) {
|
|
27283
|
+
var parts = normalizePath(path);
|
|
27284
|
+
|
|
27285
|
+
return (
|
|
27286
|
+
setCache.get(path) ||
|
|
27287
|
+
setCache.set(path, function setter(obj, value) {
|
|
27288
|
+
var index = 0;
|
|
27289
|
+
var len = parts.length;
|
|
27290
|
+
var data = obj;
|
|
27291
|
+
|
|
27292
|
+
while (index < len - 1) {
|
|
27293
|
+
var part = parts[index];
|
|
27294
|
+
if (
|
|
27295
|
+
part === '__proto__' ||
|
|
27296
|
+
part === 'constructor' ||
|
|
27297
|
+
part === 'prototype'
|
|
27298
|
+
) {
|
|
27299
|
+
return obj
|
|
27300
|
+
}
|
|
27301
|
+
|
|
27302
|
+
data = data[parts[index++]];
|
|
27303
|
+
}
|
|
27304
|
+
data[parts[index]] = value;
|
|
27305
|
+
})
|
|
27306
|
+
)
|
|
27307
|
+
},
|
|
27308
|
+
|
|
27309
|
+
getter: function (path, safe) {
|
|
27310
|
+
var parts = normalizePath(path);
|
|
27311
|
+
return (
|
|
27312
|
+
getCache.get(path) ||
|
|
27313
|
+
getCache.set(path, function getter(data) {
|
|
27314
|
+
var index = 0,
|
|
27315
|
+
len = parts.length;
|
|
27316
|
+
while (index < len) {
|
|
27317
|
+
if (data != null || !safe) data = data[parts[index++]];
|
|
27318
|
+
else return
|
|
27319
|
+
}
|
|
27320
|
+
return data
|
|
27321
|
+
})
|
|
27322
|
+
)
|
|
27323
|
+
},
|
|
27324
|
+
|
|
27325
|
+
join: function (segments) {
|
|
27326
|
+
return segments.reduce(function (path, part) {
|
|
27327
|
+
return (
|
|
27328
|
+
path +
|
|
27329
|
+
(isQuoted(part) || DIGIT_REGEX.test(part)
|
|
27330
|
+
? '[' + part + ']'
|
|
27331
|
+
: (path ? '.' : '') + part)
|
|
27332
|
+
)
|
|
27333
|
+
}, '')
|
|
27334
|
+
},
|
|
27335
|
+
|
|
27336
|
+
forEach: function (path, cb, thisArg) {
|
|
27337
|
+
forEach(Array.isArray(path) ? path : split(path), cb, thisArg);
|
|
27338
|
+
},
|
|
27339
|
+
};
|
|
27340
|
+
|
|
27341
|
+
function normalizePath(path) {
|
|
27342
|
+
return (
|
|
27343
|
+
pathCache.get(path) ||
|
|
27344
|
+
pathCache.set(
|
|
27345
|
+
path,
|
|
27346
|
+
split(path).map(function (part) {
|
|
27347
|
+
return part.replace(CLEAN_QUOTES_REGEX, '$2')
|
|
27348
|
+
})
|
|
27349
|
+
)
|
|
27350
|
+
)
|
|
27351
|
+
}
|
|
27352
|
+
|
|
27353
|
+
function split(path) {
|
|
27354
|
+
return path.match(SPLIT_REGEX) || ['']
|
|
27355
|
+
}
|
|
27356
|
+
|
|
27357
|
+
function forEach(parts, iter, thisArg) {
|
|
27358
|
+
var len = parts.length,
|
|
27359
|
+
part,
|
|
27360
|
+
idx,
|
|
27361
|
+
isArray,
|
|
27362
|
+
isBracket;
|
|
27363
|
+
|
|
27364
|
+
for (idx = 0; idx < len; idx++) {
|
|
27365
|
+
part = parts[idx];
|
|
27366
|
+
|
|
27367
|
+
if (part) {
|
|
27368
|
+
if (shouldBeQuoted(part)) {
|
|
27369
|
+
part = '"' + part + '"';
|
|
27370
|
+
}
|
|
27371
|
+
|
|
27372
|
+
isBracket = isQuoted(part);
|
|
27373
|
+
isArray = !isBracket && /^\d+$/.test(part);
|
|
27374
|
+
|
|
27375
|
+
iter.call(thisArg, part, isBracket, isArray, idx, parts);
|
|
27376
|
+
}
|
|
27377
|
+
}
|
|
27378
|
+
}
|
|
27379
|
+
|
|
27380
|
+
function isQuoted(str) {
|
|
27381
|
+
return (
|
|
27382
|
+
typeof str === 'string' && str && ["'", '"'].indexOf(str.charAt(0)) !== -1
|
|
27383
|
+
)
|
|
27384
|
+
}
|
|
27385
|
+
|
|
27386
|
+
function hasLeadingNumber(part) {
|
|
27387
|
+
return part.match(LEAD_DIGIT_REGEX) && !part.match(DIGIT_REGEX)
|
|
27388
|
+
}
|
|
27389
|
+
|
|
27390
|
+
function hasSpecialChars(part) {
|
|
27391
|
+
return SPEC_CHAR_REGEX.test(part)
|
|
27392
|
+
}
|
|
27393
|
+
|
|
27394
|
+
function shouldBeQuoted(part) {
|
|
27395
|
+
return !isQuoted(part) && (hasLeadingNumber(part) || hasSpecialChars(part))
|
|
27396
|
+
}
|
|
27397
|
+
return propertyExpr;
|
|
27398
|
+
}
|
|
27399
|
+
|
|
27400
|
+
var propertyExprExports = requirePropertyExpr();
|
|
27401
|
+
|
|
27402
|
+
var tinyCase;
|
|
27403
|
+
var hasRequiredTinyCase;
|
|
27404
|
+
|
|
27405
|
+
function requireTinyCase () {
|
|
27406
|
+
if (hasRequiredTinyCase) return tinyCase;
|
|
27407
|
+
hasRequiredTinyCase = 1;
|
|
27408
|
+
const reWords = /[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;
|
|
27409
|
+
|
|
27410
|
+
const words = (str) => str.match(reWords) || [];
|
|
27411
|
+
|
|
27412
|
+
const upperFirst = (str) => str[0].toUpperCase() + str.slice(1);
|
|
27413
|
+
|
|
27414
|
+
const join = (str, d) => words(str).join(d).toLowerCase();
|
|
27415
|
+
|
|
27416
|
+
const camelCase = (str) =>
|
|
27417
|
+
words(str).reduce(
|
|
27418
|
+
(acc, next) =>
|
|
27419
|
+
`${acc}${
|
|
27420
|
+
!acc
|
|
27421
|
+
? next.toLowerCase()
|
|
27422
|
+
: next[0].toUpperCase() + next.slice(1).toLowerCase()
|
|
27423
|
+
}`,
|
|
27424
|
+
'',
|
|
27425
|
+
);
|
|
27426
|
+
|
|
27427
|
+
const pascalCase = (str) => upperFirst(camelCase(str));
|
|
27428
|
+
|
|
27429
|
+
const snakeCase = (str) => join(str, '_');
|
|
27430
|
+
|
|
27431
|
+
const kebabCase = (str) => join(str, '-');
|
|
27432
|
+
|
|
27433
|
+
const sentenceCase = (str) => upperFirst(join(str, ' '));
|
|
27434
|
+
|
|
27435
|
+
const titleCase = (str) => words(str).map(upperFirst).join(' ');
|
|
27436
|
+
|
|
27437
|
+
tinyCase = {
|
|
27438
|
+
words,
|
|
27439
|
+
upperFirst,
|
|
27440
|
+
camelCase,
|
|
27441
|
+
pascalCase,
|
|
27442
|
+
snakeCase,
|
|
27443
|
+
kebabCase,
|
|
27444
|
+
sentenceCase,
|
|
27445
|
+
titleCase,
|
|
27446
|
+
};
|
|
27447
|
+
return tinyCase;
|
|
27448
|
+
}
|
|
27449
|
+
|
|
27450
|
+
var tinyCaseExports = requireTinyCase();
|
|
27451
|
+
|
|
27452
|
+
var toposort$1 = {exports: {}};
|
|
27453
|
+
|
|
27454
|
+
var hasRequiredToposort;
|
|
27455
|
+
|
|
27456
|
+
function requireToposort () {
|
|
27457
|
+
if (hasRequiredToposort) return toposort$1.exports;
|
|
27458
|
+
hasRequiredToposort = 1;
|
|
27459
|
+
/**
|
|
27460
|
+
* Topological sorting function
|
|
27461
|
+
*
|
|
27462
|
+
* @param {Array} edges
|
|
27463
|
+
* @returns {Array}
|
|
27464
|
+
*/
|
|
27465
|
+
|
|
27466
|
+
toposort$1.exports = function(edges) {
|
|
27467
|
+
return toposort(uniqueNodes(edges), edges)
|
|
27468
|
+
};
|
|
27469
|
+
|
|
27470
|
+
toposort$1.exports.array = toposort;
|
|
27471
|
+
|
|
27472
|
+
function toposort(nodes, edges) {
|
|
27473
|
+
var cursor = nodes.length
|
|
27474
|
+
, sorted = new Array(cursor)
|
|
27475
|
+
, visited = {}
|
|
27476
|
+
, i = cursor
|
|
27477
|
+
// Better data structures make algorithm much faster.
|
|
27478
|
+
, outgoingEdges = makeOutgoingEdges(edges)
|
|
27479
|
+
, nodesHash = makeNodesHash(nodes);
|
|
27480
|
+
|
|
27481
|
+
// check for unknown nodes
|
|
27482
|
+
edges.forEach(function(edge) {
|
|
27483
|
+
if (!nodesHash.has(edge[0]) || !nodesHash.has(edge[1])) {
|
|
27484
|
+
throw new Error('Unknown node. There is an unknown node in the supplied edges.')
|
|
27485
|
+
}
|
|
27486
|
+
});
|
|
27487
|
+
|
|
27488
|
+
while (i--) {
|
|
27489
|
+
if (!visited[i]) visit(nodes[i], i, new Set());
|
|
27490
|
+
}
|
|
27491
|
+
|
|
27492
|
+
return sorted
|
|
27493
|
+
|
|
27494
|
+
function visit(node, i, predecessors) {
|
|
27495
|
+
if(predecessors.has(node)) {
|
|
27496
|
+
var nodeRep;
|
|
27497
|
+
try {
|
|
27498
|
+
nodeRep = ", node was:" + JSON.stringify(node);
|
|
27499
|
+
} catch(e) {
|
|
27500
|
+
nodeRep = "";
|
|
27501
|
+
}
|
|
27502
|
+
throw new Error('Cyclic dependency' + nodeRep)
|
|
27503
|
+
}
|
|
27504
|
+
|
|
27505
|
+
if (!nodesHash.has(node)) {
|
|
27506
|
+
throw new Error('Found unknown node. Make sure to provided all involved nodes. Unknown node: '+JSON.stringify(node))
|
|
27507
|
+
}
|
|
27508
|
+
|
|
27509
|
+
if (visited[i]) return;
|
|
27510
|
+
visited[i] = true;
|
|
27511
|
+
|
|
27512
|
+
var outgoing = outgoingEdges.get(node) || new Set();
|
|
27513
|
+
outgoing = Array.from(outgoing);
|
|
27514
|
+
|
|
27515
|
+
if (i = outgoing.length) {
|
|
27516
|
+
predecessors.add(node);
|
|
27517
|
+
do {
|
|
27518
|
+
var child = outgoing[--i];
|
|
27519
|
+
visit(child, nodesHash.get(child), predecessors);
|
|
27520
|
+
} while (i)
|
|
27521
|
+
predecessors.delete(node);
|
|
27522
|
+
}
|
|
27523
|
+
|
|
27524
|
+
sorted[--cursor] = node;
|
|
27525
|
+
}
|
|
27526
|
+
}
|
|
27527
|
+
|
|
27528
|
+
function uniqueNodes(arr){
|
|
27529
|
+
var res = new Set();
|
|
27530
|
+
for (var i = 0, len = arr.length; i < len; i++) {
|
|
27531
|
+
var edge = arr[i];
|
|
27532
|
+
res.add(edge[0]);
|
|
27533
|
+
res.add(edge[1]);
|
|
27534
|
+
}
|
|
27535
|
+
return Array.from(res)
|
|
27536
|
+
}
|
|
27537
|
+
|
|
27538
|
+
function makeOutgoingEdges(arr){
|
|
27539
|
+
var edges = new Map();
|
|
27540
|
+
for (var i = 0, len = arr.length; i < len; i++) {
|
|
27541
|
+
var edge = arr[i];
|
|
27542
|
+
if (!edges.has(edge[0])) edges.set(edge[0], new Set());
|
|
27543
|
+
if (!edges.has(edge[1])) edges.set(edge[1], new Set());
|
|
27544
|
+
edges.get(edge[0]).add(edge[1]);
|
|
27545
|
+
}
|
|
27546
|
+
return edges
|
|
27547
|
+
}
|
|
27548
|
+
|
|
27549
|
+
function makeNodesHash(arr){
|
|
27550
|
+
var res = new Map();
|
|
27551
|
+
for (var i = 0, len = arr.length; i < len; i++) {
|
|
27552
|
+
res.set(arr[i], i);
|
|
27553
|
+
}
|
|
27554
|
+
return res
|
|
27555
|
+
}
|
|
27556
|
+
return toposort$1.exports;
|
|
27557
|
+
}
|
|
27558
|
+
|
|
27559
|
+
var toposortExports = requireToposort();
|
|
27560
|
+
var toposort = /*@__PURE__*/getDefaultExportFromCjs(toposortExports);
|
|
27561
|
+
|
|
27562
|
+
const toString = Object.prototype.toString;
|
|
27563
|
+
const errorToString = Error.prototype.toString;
|
|
27564
|
+
const regExpToString = RegExp.prototype.toString;
|
|
27565
|
+
const symbolToString = typeof Symbol !== 'undefined' ? Symbol.prototype.toString : () => '';
|
|
27566
|
+
const SYMBOL_REGEXP = /^Symbol\((.*)\)(.*)$/;
|
|
27567
|
+
function printNumber(val) {
|
|
27568
|
+
if (val != +val) return 'NaN';
|
|
27569
|
+
const isNegativeZero = val === 0 && 1 / val < 0;
|
|
27570
|
+
return isNegativeZero ? '-0' : '' + val;
|
|
27571
|
+
}
|
|
27572
|
+
function printSimpleValue(val, quoteStrings = false) {
|
|
27573
|
+
if (val == null || val === true || val === false) return '' + val;
|
|
27574
|
+
const typeOf = typeof val;
|
|
27575
|
+
if (typeOf === 'number') return printNumber(val);
|
|
27576
|
+
if (typeOf === 'string') return quoteStrings ? `"${val}"` : val;
|
|
27577
|
+
if (typeOf === 'function') return '[Function ' + (val.name || 'anonymous') + ']';
|
|
27578
|
+
if (typeOf === 'symbol') return symbolToString.call(val).replace(SYMBOL_REGEXP, 'Symbol($1)');
|
|
27579
|
+
const tag = toString.call(val).slice(8, -1);
|
|
27580
|
+
if (tag === 'Date') return isNaN(val.getTime()) ? '' + val : val.toISOString(val);
|
|
27581
|
+
if (tag === 'Error' || val instanceof Error) return '[' + errorToString.call(val) + ']';
|
|
27582
|
+
if (tag === 'RegExp') return regExpToString.call(val);
|
|
27583
|
+
return null;
|
|
27584
|
+
}
|
|
27585
|
+
function printValue(value, quoteStrings) {
|
|
27586
|
+
let result = printSimpleValue(value, quoteStrings);
|
|
27587
|
+
if (result !== null) return result;
|
|
27588
|
+
return JSON.stringify(value, function (key, value) {
|
|
27589
|
+
let result = printSimpleValue(this[key], quoteStrings);
|
|
27590
|
+
if (result !== null) return result;
|
|
27591
|
+
return value;
|
|
27592
|
+
}, 2);
|
|
27593
|
+
}
|
|
27594
|
+
|
|
27595
|
+
function toArray(value) {
|
|
27596
|
+
return value == null ? [] : [].concat(value);
|
|
27597
|
+
}
|
|
27598
|
+
|
|
27599
|
+
let _Symbol$toStringTag, _Symbol$hasInstance, _Symbol$toStringTag2;
|
|
27600
|
+
let strReg = /\$\{\s*(\w+)\s*\}/g;
|
|
27601
|
+
_Symbol$toStringTag = Symbol.toStringTag;
|
|
27602
|
+
class ValidationErrorNoStack {
|
|
27603
|
+
constructor(errorOrErrors, value, field, type) {
|
|
27604
|
+
this.name = void 0;
|
|
27605
|
+
this.message = void 0;
|
|
27606
|
+
this.value = void 0;
|
|
27607
|
+
this.path = void 0;
|
|
27608
|
+
this.type = void 0;
|
|
27609
|
+
this.params = void 0;
|
|
27610
|
+
this.errors = void 0;
|
|
27611
|
+
this.inner = void 0;
|
|
27612
|
+
this[_Symbol$toStringTag] = 'Error';
|
|
27613
|
+
this.name = 'ValidationError';
|
|
27614
|
+
this.value = value;
|
|
27615
|
+
this.path = field;
|
|
27616
|
+
this.type = type;
|
|
27617
|
+
this.errors = [];
|
|
27618
|
+
this.inner = [];
|
|
27619
|
+
toArray(errorOrErrors).forEach(err => {
|
|
27620
|
+
if (ValidationError.isError(err)) {
|
|
27621
|
+
this.errors.push(...err.errors);
|
|
27622
|
+
const innerErrors = err.inner.length ? err.inner : [err];
|
|
27623
|
+
this.inner.push(...innerErrors);
|
|
27624
|
+
} else {
|
|
27625
|
+
this.errors.push(err);
|
|
27626
|
+
}
|
|
27627
|
+
});
|
|
27628
|
+
this.message = this.errors.length > 1 ? `${this.errors.length} errors occurred` : this.errors[0];
|
|
27629
|
+
}
|
|
27630
|
+
}
|
|
27631
|
+
_Symbol$hasInstance = Symbol.hasInstance;
|
|
27632
|
+
_Symbol$toStringTag2 = Symbol.toStringTag;
|
|
27633
|
+
class ValidationError extends Error {
|
|
27634
|
+
static formatError(message, params) {
|
|
27635
|
+
const path = params.label || params.path || 'this';
|
|
27636
|
+
if (path !== params.path) params = Object.assign({}, params, {
|
|
27637
|
+
path
|
|
27638
|
+
});
|
|
27639
|
+
if (typeof message === 'string') return message.replace(strReg, (_, key) => printValue(params[key]));
|
|
27640
|
+
if (typeof message === 'function') return message(params);
|
|
27641
|
+
return message;
|
|
27642
|
+
}
|
|
27643
|
+
static isError(err) {
|
|
27644
|
+
return err && err.name === 'ValidationError';
|
|
27645
|
+
}
|
|
27646
|
+
constructor(errorOrErrors, value, field, type, disableStack) {
|
|
27647
|
+
const errorNoStack = new ValidationErrorNoStack(errorOrErrors, value, field, type);
|
|
27648
|
+
if (disableStack) {
|
|
27649
|
+
return errorNoStack;
|
|
27650
|
+
}
|
|
27651
|
+
super();
|
|
27652
|
+
this.value = void 0;
|
|
27653
|
+
this.path = void 0;
|
|
27654
|
+
this.type = void 0;
|
|
27655
|
+
this.params = void 0;
|
|
27656
|
+
this.errors = [];
|
|
27657
|
+
this.inner = [];
|
|
27658
|
+
this[_Symbol$toStringTag2] = 'Error';
|
|
27659
|
+
this.name = errorNoStack.name;
|
|
27660
|
+
this.message = errorNoStack.message;
|
|
27661
|
+
this.type = errorNoStack.type;
|
|
27662
|
+
this.value = errorNoStack.value;
|
|
27663
|
+
this.path = errorNoStack.path;
|
|
27664
|
+
this.errors = errorNoStack.errors;
|
|
27665
|
+
this.inner = errorNoStack.inner;
|
|
27666
|
+
if (Error.captureStackTrace) {
|
|
27667
|
+
Error.captureStackTrace(this, ValidationError);
|
|
27668
|
+
}
|
|
27669
|
+
}
|
|
27670
|
+
static [_Symbol$hasInstance](inst) {
|
|
27671
|
+
return ValidationErrorNoStack[Symbol.hasInstance](inst) || super[Symbol.hasInstance](inst);
|
|
27672
|
+
}
|
|
27673
|
+
}
|
|
27674
|
+
|
|
27675
|
+
let mixed = {
|
|
27676
|
+
default: '${path} is invalid',
|
|
27677
|
+
required: '${path} is a required field',
|
|
27678
|
+
defined: '${path} must be defined',
|
|
27679
|
+
notNull: '${path} cannot be null',
|
|
27680
|
+
oneOf: '${path} must be one of the following values: ${values}',
|
|
27681
|
+
notOneOf: '${path} must not be one of the following values: ${values}',
|
|
27682
|
+
notType: ({
|
|
27683
|
+
path,
|
|
27684
|
+
type,
|
|
27685
|
+
value,
|
|
27686
|
+
originalValue
|
|
27687
|
+
}) => {
|
|
27688
|
+
const castMsg = originalValue != null && originalValue !== value ? ` (cast from the value \`${printValue(originalValue, true)}\`).` : '.';
|
|
27689
|
+
return type !== 'mixed' ? `${path} must be a \`${type}\` type, ` + `but the final value was: \`${printValue(value, true)}\`` + castMsg : `${path} must match the configured type. ` + `The validated value was: \`${printValue(value, true)}\`` + castMsg;
|
|
27690
|
+
}
|
|
27691
|
+
};
|
|
27692
|
+
let string = {
|
|
27693
|
+
length: '${path} must be exactly ${length} characters',
|
|
27694
|
+
min: '${path} must be at least ${min} characters',
|
|
27695
|
+
max: '${path} must be at most ${max} characters',
|
|
27696
|
+
matches: '${path} must match the following: "${regex}"',
|
|
27697
|
+
email: '${path} must be a valid email',
|
|
27698
|
+
url: '${path} must be a valid URL',
|
|
27699
|
+
uuid: '${path} must be a valid UUID',
|
|
27700
|
+
datetime: '${path} must be a valid ISO date-time',
|
|
27701
|
+
datetime_precision: '${path} must be a valid ISO date-time with a sub-second precision of exactly ${precision} digits',
|
|
27702
|
+
datetime_offset: '${path} must be a valid ISO date-time with UTC "Z" timezone',
|
|
27703
|
+
trim: '${path} must be a trimmed string',
|
|
27704
|
+
lowercase: '${path} must be a lowercase string',
|
|
27705
|
+
uppercase: '${path} must be a upper case string'
|
|
27706
|
+
};
|
|
27707
|
+
let number = {
|
|
27708
|
+
min: '${path} must be greater than or equal to ${min}',
|
|
27709
|
+
max: '${path} must be less than or equal to ${max}',
|
|
27710
|
+
lessThan: '${path} must be less than ${less}',
|
|
27711
|
+
moreThan: '${path} must be greater than ${more}',
|
|
27712
|
+
positive: '${path} must be a positive number',
|
|
27713
|
+
negative: '${path} must be a negative number',
|
|
27714
|
+
integer: '${path} must be an integer'
|
|
27715
|
+
};
|
|
27716
|
+
let date = {
|
|
27717
|
+
min: '${path} field must be later than ${min}',
|
|
27718
|
+
max: '${path} field must be at earlier than ${max}'
|
|
27719
|
+
};
|
|
27720
|
+
let boolean = {
|
|
27721
|
+
isValue: '${path} field must be ${value}'
|
|
27722
|
+
};
|
|
27723
|
+
let object = {
|
|
27724
|
+
noUnknown: '${path} field has unspecified keys: ${unknown}'
|
|
27725
|
+
};
|
|
27726
|
+
let array = {
|
|
27727
|
+
min: '${path} field must have at least ${min} items',
|
|
27728
|
+
max: '${path} field must have less than or equal to ${max} items',
|
|
27729
|
+
length: '${path} must have ${length} items'
|
|
27730
|
+
};
|
|
27731
|
+
let tuple = {
|
|
27732
|
+
notType: params => {
|
|
27733
|
+
const {
|
|
27734
|
+
path,
|
|
27735
|
+
value,
|
|
27736
|
+
spec
|
|
27737
|
+
} = params;
|
|
27738
|
+
const typeLen = spec.types.length;
|
|
27739
|
+
if (Array.isArray(value)) {
|
|
27740
|
+
if (value.length < typeLen) return `${path} tuple value has too few items, expected a length of ${typeLen} but got ${value.length} for value: \`${printValue(value, true)}\``;
|
|
27741
|
+
if (value.length > typeLen) return `${path} tuple value has too many items, expected a length of ${typeLen} but got ${value.length} for value: \`${printValue(value, true)}\``;
|
|
27742
|
+
}
|
|
27743
|
+
return ValidationError.formatError(mixed.notType, params);
|
|
27744
|
+
}
|
|
27745
|
+
};
|
|
27746
|
+
var locale = Object.assign(Object.create(null), {
|
|
27747
|
+
mixed,
|
|
27748
|
+
string,
|
|
27749
|
+
number,
|
|
27750
|
+
date,
|
|
27751
|
+
object,
|
|
27752
|
+
array,
|
|
27753
|
+
boolean,
|
|
27754
|
+
tuple
|
|
27755
|
+
});
|
|
27756
|
+
|
|
27757
|
+
const isSchema = obj => obj && obj.__isYupSchema__;
|
|
27758
|
+
|
|
27759
|
+
class Condition {
|
|
27760
|
+
static fromOptions(refs, config) {
|
|
27761
|
+
if (!config.then && !config.otherwise) throw new TypeError('either `then:` or `otherwise:` is required for `when()` conditions');
|
|
27762
|
+
let {
|
|
27763
|
+
is,
|
|
27764
|
+
then,
|
|
27765
|
+
otherwise
|
|
27766
|
+
} = config;
|
|
27767
|
+
let check = typeof is === 'function' ? is : (...values) => values.every(value => value === is);
|
|
27768
|
+
return new Condition(refs, (values, schema) => {
|
|
27769
|
+
var _branch;
|
|
27770
|
+
let branch = check(...values) ? then : otherwise;
|
|
27771
|
+
return (_branch = branch == null ? void 0 : branch(schema)) != null ? _branch : schema;
|
|
27772
|
+
});
|
|
27773
|
+
}
|
|
27774
|
+
constructor(refs, builder) {
|
|
27775
|
+
this.fn = void 0;
|
|
27776
|
+
this.refs = refs;
|
|
27777
|
+
this.refs = refs;
|
|
27778
|
+
this.fn = builder;
|
|
27779
|
+
}
|
|
27780
|
+
resolve(base, options) {
|
|
27781
|
+
let values = this.refs.map(ref =>
|
|
27782
|
+
// TODO: ? operator here?
|
|
27783
|
+
ref.getValue(options == null ? void 0 : options.value, options == null ? void 0 : options.parent, options == null ? void 0 : options.context));
|
|
27784
|
+
let schema = this.fn(values, base, options);
|
|
27785
|
+
if (schema === undefined ||
|
|
27786
|
+
// @ts-ignore this can be base
|
|
27787
|
+
schema === base) {
|
|
27788
|
+
return base;
|
|
27789
|
+
}
|
|
27790
|
+
if (!isSchema(schema)) throw new TypeError('conditions must return a schema object');
|
|
27791
|
+
return schema.resolve(options);
|
|
27792
|
+
}
|
|
27793
|
+
}
|
|
27794
|
+
|
|
27795
|
+
const prefixes = {
|
|
27796
|
+
context: '$',
|
|
27797
|
+
value: '.'
|
|
27798
|
+
};
|
|
27799
|
+
function create$9(key, options) {
|
|
27800
|
+
return new Reference(key, options);
|
|
27801
|
+
}
|
|
27802
|
+
class Reference {
|
|
27803
|
+
constructor(key, options = {}) {
|
|
27804
|
+
this.key = void 0;
|
|
27805
|
+
this.isContext = void 0;
|
|
27806
|
+
this.isValue = void 0;
|
|
27807
|
+
this.isSibling = void 0;
|
|
27808
|
+
this.path = void 0;
|
|
27809
|
+
this.getter = void 0;
|
|
27810
|
+
this.map = void 0;
|
|
27811
|
+
if (typeof key !== 'string') throw new TypeError('ref must be a string, got: ' + key);
|
|
27812
|
+
this.key = key.trim();
|
|
27813
|
+
if (key === '') throw new TypeError('ref must be a non-empty string');
|
|
27814
|
+
this.isContext = this.key[0] === prefixes.context;
|
|
27815
|
+
this.isValue = this.key[0] === prefixes.value;
|
|
27816
|
+
this.isSibling = !this.isContext && !this.isValue;
|
|
27817
|
+
let prefix = this.isContext ? prefixes.context : this.isValue ? prefixes.value : '';
|
|
27818
|
+
this.path = this.key.slice(prefix.length);
|
|
27819
|
+
this.getter = this.path && propertyExprExports.getter(this.path, true);
|
|
27820
|
+
this.map = options.map;
|
|
27821
|
+
}
|
|
27822
|
+
getValue(value, parent, context) {
|
|
27823
|
+
let result = this.isContext ? context : this.isValue ? value : parent;
|
|
27824
|
+
if (this.getter) result = this.getter(result || {});
|
|
27825
|
+
if (this.map) result = this.map(result);
|
|
27826
|
+
return result;
|
|
27827
|
+
}
|
|
27828
|
+
|
|
27829
|
+
/**
|
|
27830
|
+
*
|
|
27831
|
+
* @param {*} value
|
|
27832
|
+
* @param {Object} options
|
|
27833
|
+
* @param {Object=} options.context
|
|
27834
|
+
* @param {Object=} options.parent
|
|
27835
|
+
*/
|
|
27836
|
+
cast(value, options) {
|
|
27837
|
+
return this.getValue(value, options == null ? void 0 : options.parent, options == null ? void 0 : options.context);
|
|
27838
|
+
}
|
|
27839
|
+
resolve() {
|
|
27840
|
+
return this;
|
|
27841
|
+
}
|
|
27842
|
+
describe() {
|
|
27843
|
+
return {
|
|
27844
|
+
type: 'ref',
|
|
27845
|
+
key: this.key
|
|
27846
|
+
};
|
|
27847
|
+
}
|
|
27848
|
+
toString() {
|
|
27849
|
+
return `Ref(${this.key})`;
|
|
27850
|
+
}
|
|
27851
|
+
static isRef(value) {
|
|
27852
|
+
return value && value.__isYupRef;
|
|
27853
|
+
}
|
|
27854
|
+
}
|
|
27855
|
+
|
|
27856
|
+
// @ts-ignore
|
|
27857
|
+
Reference.prototype.__isYupRef = true;
|
|
27858
|
+
|
|
27859
|
+
const isAbsent = value => value == null;
|
|
27860
|
+
|
|
27861
|
+
function createValidation(config) {
|
|
27862
|
+
function validate({
|
|
27863
|
+
value,
|
|
27864
|
+
path = '',
|
|
27865
|
+
options,
|
|
27866
|
+
originalValue,
|
|
27867
|
+
schema
|
|
27868
|
+
}, panic, next) {
|
|
27869
|
+
const {
|
|
27870
|
+
name,
|
|
27871
|
+
test,
|
|
27872
|
+
params,
|
|
27873
|
+
message,
|
|
27874
|
+
skipAbsent
|
|
27875
|
+
} = config;
|
|
27876
|
+
let {
|
|
27877
|
+
parent,
|
|
27878
|
+
context,
|
|
27879
|
+
abortEarly = schema.spec.abortEarly,
|
|
27880
|
+
disableStackTrace = schema.spec.disableStackTrace
|
|
27881
|
+
} = options;
|
|
27882
|
+
function resolve(item) {
|
|
27883
|
+
return Reference.isRef(item) ? item.getValue(value, parent, context) : item;
|
|
27884
|
+
}
|
|
27885
|
+
function createError(overrides = {}) {
|
|
27886
|
+
const nextParams = Object.assign({
|
|
27887
|
+
value,
|
|
27888
|
+
originalValue,
|
|
27889
|
+
label: schema.spec.label,
|
|
27890
|
+
path: overrides.path || path,
|
|
27891
|
+
spec: schema.spec,
|
|
27892
|
+
disableStackTrace: overrides.disableStackTrace || disableStackTrace
|
|
27893
|
+
}, params, overrides.params);
|
|
27894
|
+
for (const key of Object.keys(nextParams)) nextParams[key] = resolve(nextParams[key]);
|
|
27895
|
+
const error = new ValidationError(ValidationError.formatError(overrides.message || message, nextParams), value, nextParams.path, overrides.type || name, nextParams.disableStackTrace);
|
|
27896
|
+
error.params = nextParams;
|
|
27897
|
+
return error;
|
|
27898
|
+
}
|
|
27899
|
+
const invalid = abortEarly ? panic : next;
|
|
27900
|
+
let ctx = {
|
|
27901
|
+
path,
|
|
27902
|
+
parent,
|
|
27903
|
+
type: name,
|
|
27904
|
+
from: options.from,
|
|
27905
|
+
createError,
|
|
27906
|
+
resolve,
|
|
27907
|
+
options,
|
|
27908
|
+
originalValue,
|
|
27909
|
+
schema
|
|
27910
|
+
};
|
|
27911
|
+
const handleResult = validOrError => {
|
|
27912
|
+
if (ValidationError.isError(validOrError)) invalid(validOrError);else if (!validOrError) invalid(createError());else next(null);
|
|
27913
|
+
};
|
|
27914
|
+
const handleError = err => {
|
|
27915
|
+
if (ValidationError.isError(err)) invalid(err);else panic(err);
|
|
27916
|
+
};
|
|
27917
|
+
const shouldSkip = skipAbsent && isAbsent(value);
|
|
27918
|
+
if (shouldSkip) {
|
|
27919
|
+
return handleResult(true);
|
|
27920
|
+
}
|
|
27921
|
+
let result;
|
|
27922
|
+
try {
|
|
27923
|
+
var _result;
|
|
27924
|
+
result = test.call(ctx, value, ctx);
|
|
27925
|
+
if (typeof ((_result = result) == null ? void 0 : _result.then) === 'function') {
|
|
27926
|
+
if (options.sync) {
|
|
27927
|
+
throw new Error(`Validation test of type: "${ctx.type}" returned a Promise during a synchronous validate. ` + `This test will finish after the validate call has returned`);
|
|
27928
|
+
}
|
|
27929
|
+
return Promise.resolve(result).then(handleResult, handleError);
|
|
27930
|
+
}
|
|
27931
|
+
} catch (err) {
|
|
27932
|
+
handleError(err);
|
|
27933
|
+
return;
|
|
27934
|
+
}
|
|
27935
|
+
handleResult(result);
|
|
27936
|
+
}
|
|
27937
|
+
validate.OPTIONS = config;
|
|
27938
|
+
return validate;
|
|
27939
|
+
}
|
|
27940
|
+
|
|
27941
|
+
function getIn(schema, path, value, context = value) {
|
|
27942
|
+
let parent, lastPart, lastPartDebug;
|
|
27943
|
+
|
|
27944
|
+
// root path: ''
|
|
27945
|
+
if (!path) return {
|
|
27946
|
+
parent,
|
|
27947
|
+
parentPath: path,
|
|
27948
|
+
schema
|
|
27949
|
+
};
|
|
27950
|
+
propertyExprExports.forEach(path, (_part, isBracket, isArray) => {
|
|
27951
|
+
let part = isBracket ? _part.slice(1, _part.length - 1) : _part;
|
|
27952
|
+
schema = schema.resolve({
|
|
27953
|
+
context,
|
|
27954
|
+
parent,
|
|
27955
|
+
value
|
|
27956
|
+
});
|
|
27957
|
+
let isTuple = schema.type === 'tuple';
|
|
27958
|
+
let idx = isArray ? parseInt(part, 10) : 0;
|
|
27959
|
+
if (schema.innerType || isTuple) {
|
|
27960
|
+
if (isTuple && !isArray) throw new Error(`Yup.reach cannot implicitly index into a tuple type. the path part "${lastPartDebug}" must contain an index to the tuple element, e.g. "${lastPartDebug}[0]"`);
|
|
27961
|
+
if (value && idx >= value.length) {
|
|
27962
|
+
throw new Error(`Yup.reach cannot resolve an array item at index: ${_part}, in the path: ${path}. ` + `because there is no value at that index. `);
|
|
27963
|
+
}
|
|
27964
|
+
parent = value;
|
|
27965
|
+
value = value && value[idx];
|
|
27966
|
+
schema = isTuple ? schema.spec.types[idx] : schema.innerType;
|
|
27967
|
+
}
|
|
27968
|
+
|
|
27969
|
+
// sometimes the array index part of a path doesn't exist: "nested.arr.child"
|
|
27970
|
+
// in these cases the current part is the next schema and should be processed
|
|
27971
|
+
// in this iteration. For cases where the index signature is included this
|
|
27972
|
+
// check will fail and we'll handle the `child` part on the next iteration like normal
|
|
27973
|
+
if (!isArray) {
|
|
27974
|
+
if (!schema.fields || !schema.fields[part]) throw new Error(`The schema does not contain the path: ${path}. ` + `(failed at: ${lastPartDebug} which is a type: "${schema.type}")`);
|
|
27975
|
+
parent = value;
|
|
27976
|
+
value = value && value[part];
|
|
27977
|
+
schema = schema.fields[part];
|
|
27978
|
+
}
|
|
27979
|
+
lastPart = part;
|
|
27980
|
+
lastPartDebug = isBracket ? '[' + _part + ']' : '.' + _part;
|
|
27981
|
+
});
|
|
27982
|
+
return {
|
|
27983
|
+
schema,
|
|
27984
|
+
parent,
|
|
27985
|
+
parentPath: lastPart
|
|
27986
|
+
};
|
|
27987
|
+
}
|
|
27988
|
+
function reach(obj, path, value, context) {
|
|
27989
|
+
return getIn(obj, path, value, context).schema;
|
|
27990
|
+
}
|
|
27991
|
+
|
|
27992
|
+
class ReferenceSet extends Set {
|
|
27993
|
+
describe() {
|
|
27994
|
+
const description = [];
|
|
27995
|
+
for (const item of this.values()) {
|
|
27996
|
+
description.push(Reference.isRef(item) ? item.describe() : item);
|
|
27997
|
+
}
|
|
27998
|
+
return description;
|
|
27999
|
+
}
|
|
28000
|
+
resolveAll(resolve) {
|
|
28001
|
+
let result = [];
|
|
28002
|
+
for (const item of this.values()) {
|
|
28003
|
+
result.push(resolve(item));
|
|
28004
|
+
}
|
|
28005
|
+
return result;
|
|
28006
|
+
}
|
|
28007
|
+
clone() {
|
|
28008
|
+
return new ReferenceSet(this.values());
|
|
28009
|
+
}
|
|
28010
|
+
merge(newItems, removeItems) {
|
|
28011
|
+
const next = this.clone();
|
|
28012
|
+
newItems.forEach(value => next.add(value));
|
|
28013
|
+
removeItems.forEach(value => next.delete(value));
|
|
28014
|
+
return next;
|
|
28015
|
+
}
|
|
28016
|
+
}
|
|
28017
|
+
|
|
28018
|
+
// tweaked from https://github.com/Kelin2025/nanoclone/blob/0abeb7635bda9b68ef2277093f76dbe3bf3948e1/src/index.js
|
|
28019
|
+
function clone(src, seen = new Map()) {
|
|
28020
|
+
if (isSchema(src) || !src || typeof src !== 'object') return src;
|
|
28021
|
+
if (seen.has(src)) return seen.get(src);
|
|
28022
|
+
let copy;
|
|
28023
|
+
if (src instanceof Date) {
|
|
28024
|
+
// Date
|
|
28025
|
+
copy = new Date(src.getTime());
|
|
28026
|
+
seen.set(src, copy);
|
|
28027
|
+
} else if (src instanceof RegExp) {
|
|
28028
|
+
// RegExp
|
|
28029
|
+
copy = new RegExp(src);
|
|
28030
|
+
seen.set(src, copy);
|
|
28031
|
+
} else if (Array.isArray(src)) {
|
|
28032
|
+
// Array
|
|
28033
|
+
copy = new Array(src.length);
|
|
28034
|
+
seen.set(src, copy);
|
|
28035
|
+
for (let i = 0; i < src.length; i++) copy[i] = clone(src[i], seen);
|
|
28036
|
+
} else if (src instanceof Map) {
|
|
28037
|
+
// Map
|
|
28038
|
+
copy = new Map();
|
|
28039
|
+
seen.set(src, copy);
|
|
28040
|
+
for (const [k, v] of src.entries()) copy.set(k, clone(v, seen));
|
|
28041
|
+
} else if (src instanceof Set) {
|
|
28042
|
+
// Set
|
|
28043
|
+
copy = new Set();
|
|
28044
|
+
seen.set(src, copy);
|
|
28045
|
+
for (const v of src) copy.add(clone(v, seen));
|
|
28046
|
+
} else if (src instanceof Object) {
|
|
28047
|
+
// Object
|
|
28048
|
+
copy = {};
|
|
28049
|
+
seen.set(src, copy);
|
|
28050
|
+
for (const [k, v] of Object.entries(src)) copy[k] = clone(v, seen);
|
|
28051
|
+
} else {
|
|
28052
|
+
throw Error(`Unable to clone ${src}`);
|
|
28053
|
+
}
|
|
28054
|
+
return copy;
|
|
28055
|
+
}
|
|
28056
|
+
|
|
28057
|
+
// If `CustomSchemaMeta` isn't extended with any keys, we'll fall back to a
|
|
28058
|
+
// loose Record definition allowing free form usage.
|
|
28059
|
+
class Schema {
|
|
28060
|
+
constructor(options) {
|
|
28061
|
+
this.type = void 0;
|
|
28062
|
+
this.deps = [];
|
|
28063
|
+
this.tests = void 0;
|
|
28064
|
+
this.transforms = void 0;
|
|
28065
|
+
this.conditions = [];
|
|
28066
|
+
this._mutate = void 0;
|
|
28067
|
+
this.internalTests = {};
|
|
28068
|
+
this._whitelist = new ReferenceSet();
|
|
28069
|
+
this._blacklist = new ReferenceSet();
|
|
28070
|
+
this.exclusiveTests = Object.create(null);
|
|
28071
|
+
this._typeCheck = void 0;
|
|
28072
|
+
this.spec = void 0;
|
|
28073
|
+
this.tests = [];
|
|
28074
|
+
this.transforms = [];
|
|
28075
|
+
this.withMutation(() => {
|
|
28076
|
+
this.typeError(mixed.notType);
|
|
28077
|
+
});
|
|
28078
|
+
this.type = options.type;
|
|
28079
|
+
this._typeCheck = options.check;
|
|
28080
|
+
this.spec = Object.assign({
|
|
28081
|
+
strip: false,
|
|
28082
|
+
strict: false,
|
|
28083
|
+
abortEarly: true,
|
|
28084
|
+
recursive: true,
|
|
28085
|
+
disableStackTrace: false,
|
|
28086
|
+
nullable: false,
|
|
28087
|
+
optional: true,
|
|
28088
|
+
coerce: true
|
|
28089
|
+
}, options == null ? void 0 : options.spec);
|
|
28090
|
+
this.withMutation(s => {
|
|
28091
|
+
s.nonNullable();
|
|
28092
|
+
});
|
|
28093
|
+
}
|
|
28094
|
+
|
|
28095
|
+
// TODO: remove
|
|
28096
|
+
get _type() {
|
|
28097
|
+
return this.type;
|
|
28098
|
+
}
|
|
28099
|
+
clone(spec) {
|
|
28100
|
+
if (this._mutate) {
|
|
28101
|
+
if (spec) Object.assign(this.spec, spec);
|
|
28102
|
+
return this;
|
|
28103
|
+
}
|
|
28104
|
+
|
|
28105
|
+
// if the nested value is a schema we can skip cloning, since
|
|
28106
|
+
// they are already immutable
|
|
28107
|
+
const next = Object.create(Object.getPrototypeOf(this));
|
|
28108
|
+
|
|
28109
|
+
// @ts-expect-error this is readonly
|
|
28110
|
+
next.type = this.type;
|
|
28111
|
+
next._typeCheck = this._typeCheck;
|
|
28112
|
+
next._whitelist = this._whitelist.clone();
|
|
28113
|
+
next._blacklist = this._blacklist.clone();
|
|
28114
|
+
next.internalTests = Object.assign({}, this.internalTests);
|
|
28115
|
+
next.exclusiveTests = Object.assign({}, this.exclusiveTests);
|
|
28116
|
+
|
|
28117
|
+
// @ts-expect-error this is readonly
|
|
28118
|
+
next.deps = [...this.deps];
|
|
28119
|
+
next.conditions = [...this.conditions];
|
|
28120
|
+
next.tests = [...this.tests];
|
|
28121
|
+
next.transforms = [...this.transforms];
|
|
28122
|
+
next.spec = clone(Object.assign({}, this.spec, spec));
|
|
28123
|
+
return next;
|
|
28124
|
+
}
|
|
28125
|
+
label(label) {
|
|
28126
|
+
let next = this.clone();
|
|
28127
|
+
next.spec.label = label;
|
|
28128
|
+
return next;
|
|
28129
|
+
}
|
|
28130
|
+
meta(...args) {
|
|
28131
|
+
if (args.length === 0) return this.spec.meta;
|
|
28132
|
+
let next = this.clone();
|
|
28133
|
+
next.spec.meta = Object.assign(next.spec.meta || {}, args[0]);
|
|
28134
|
+
return next;
|
|
28135
|
+
}
|
|
28136
|
+
withMutation(fn) {
|
|
28137
|
+
let before = this._mutate;
|
|
28138
|
+
this._mutate = true;
|
|
28139
|
+
let result = fn(this);
|
|
28140
|
+
this._mutate = before;
|
|
28141
|
+
return result;
|
|
28142
|
+
}
|
|
28143
|
+
concat(schema) {
|
|
28144
|
+
if (!schema || schema === this) return this;
|
|
28145
|
+
if (schema.type !== this.type && this.type !== 'mixed') throw new TypeError(`You cannot \`concat()\` schema's of different types: ${this.type} and ${schema.type}`);
|
|
28146
|
+
let base = this;
|
|
28147
|
+
let combined = schema.clone();
|
|
28148
|
+
const mergedSpec = Object.assign({}, base.spec, combined.spec);
|
|
28149
|
+
combined.spec = mergedSpec;
|
|
28150
|
+
combined.internalTests = Object.assign({}, base.internalTests, combined.internalTests);
|
|
28151
|
+
|
|
28152
|
+
// manually merge the blacklist/whitelist (the other `schema` takes
|
|
28153
|
+
// precedence in case of conflicts)
|
|
28154
|
+
combined._whitelist = base._whitelist.merge(schema._whitelist, schema._blacklist);
|
|
28155
|
+
combined._blacklist = base._blacklist.merge(schema._blacklist, schema._whitelist);
|
|
28156
|
+
|
|
28157
|
+
// start with the current tests
|
|
28158
|
+
combined.tests = base.tests;
|
|
28159
|
+
combined.exclusiveTests = base.exclusiveTests;
|
|
28160
|
+
|
|
28161
|
+
// manually add the new tests to ensure
|
|
28162
|
+
// the deduping logic is consistent
|
|
28163
|
+
combined.withMutation(next => {
|
|
28164
|
+
schema.tests.forEach(fn => {
|
|
28165
|
+
next.test(fn.OPTIONS);
|
|
28166
|
+
});
|
|
28167
|
+
});
|
|
28168
|
+
combined.transforms = [...base.transforms, ...combined.transforms];
|
|
28169
|
+
return combined;
|
|
28170
|
+
}
|
|
28171
|
+
isType(v) {
|
|
28172
|
+
if (v == null) {
|
|
28173
|
+
if (this.spec.nullable && v === null) return true;
|
|
28174
|
+
if (this.spec.optional && v === undefined) return true;
|
|
28175
|
+
return false;
|
|
28176
|
+
}
|
|
28177
|
+
return this._typeCheck(v);
|
|
28178
|
+
}
|
|
28179
|
+
resolve(options) {
|
|
28180
|
+
let schema = this;
|
|
28181
|
+
if (schema.conditions.length) {
|
|
28182
|
+
let conditions = schema.conditions;
|
|
28183
|
+
schema = schema.clone();
|
|
28184
|
+
schema.conditions = [];
|
|
28185
|
+
schema = conditions.reduce((prevSchema, condition) => condition.resolve(prevSchema, options), schema);
|
|
28186
|
+
schema = schema.resolve(options);
|
|
28187
|
+
}
|
|
28188
|
+
return schema;
|
|
28189
|
+
}
|
|
28190
|
+
resolveOptions(options) {
|
|
28191
|
+
var _options$strict, _options$abortEarly, _options$recursive, _options$disableStack;
|
|
28192
|
+
return Object.assign({}, options, {
|
|
28193
|
+
from: options.from || [],
|
|
28194
|
+
strict: (_options$strict = options.strict) != null ? _options$strict : this.spec.strict,
|
|
28195
|
+
abortEarly: (_options$abortEarly = options.abortEarly) != null ? _options$abortEarly : this.spec.abortEarly,
|
|
28196
|
+
recursive: (_options$recursive = options.recursive) != null ? _options$recursive : this.spec.recursive,
|
|
28197
|
+
disableStackTrace: (_options$disableStack = options.disableStackTrace) != null ? _options$disableStack : this.spec.disableStackTrace
|
|
28198
|
+
});
|
|
28199
|
+
}
|
|
28200
|
+
|
|
28201
|
+
/**
|
|
28202
|
+
* Run the configured transform pipeline over an input value.
|
|
28203
|
+
*/
|
|
28204
|
+
|
|
28205
|
+
cast(value, options = {}) {
|
|
28206
|
+
let resolvedSchema = this.resolve(Object.assign({
|
|
28207
|
+
value
|
|
28208
|
+
}, options));
|
|
28209
|
+
let allowOptionality = options.assert === 'ignore-optionality';
|
|
28210
|
+
let result = resolvedSchema._cast(value, options);
|
|
28211
|
+
if (options.assert !== false && !resolvedSchema.isType(result)) {
|
|
28212
|
+
if (allowOptionality && isAbsent(result)) {
|
|
28213
|
+
return result;
|
|
28214
|
+
}
|
|
28215
|
+
let formattedValue = printValue(value);
|
|
28216
|
+
let formattedResult = printValue(result);
|
|
28217
|
+
throw new TypeError(`The value of ${options.path || 'field'} could not be cast to a value ` + `that satisfies the schema type: "${resolvedSchema.type}". \n\n` + `attempted value: ${formattedValue} \n` + (formattedResult !== formattedValue ? `result of cast: ${formattedResult}` : ''));
|
|
28218
|
+
}
|
|
28219
|
+
return result;
|
|
28220
|
+
}
|
|
28221
|
+
_cast(rawValue, options) {
|
|
28222
|
+
let value = rawValue === undefined ? rawValue : this.transforms.reduce((prevValue, fn) => fn.call(this, prevValue, rawValue, this), rawValue);
|
|
28223
|
+
if (value === undefined) {
|
|
28224
|
+
value = this.getDefault(options);
|
|
28225
|
+
}
|
|
28226
|
+
return value;
|
|
28227
|
+
}
|
|
28228
|
+
_validate(_value, options = {}, panic, next) {
|
|
28229
|
+
let {
|
|
28230
|
+
path,
|
|
28231
|
+
originalValue = _value,
|
|
28232
|
+
strict = this.spec.strict
|
|
28233
|
+
} = options;
|
|
28234
|
+
let value = _value;
|
|
28235
|
+
if (!strict) {
|
|
28236
|
+
value = this._cast(value, Object.assign({
|
|
28237
|
+
assert: false
|
|
28238
|
+
}, options));
|
|
28239
|
+
}
|
|
28240
|
+
let initialTests = [];
|
|
28241
|
+
for (let test of Object.values(this.internalTests)) {
|
|
28242
|
+
if (test) initialTests.push(test);
|
|
28243
|
+
}
|
|
28244
|
+
this.runTests({
|
|
28245
|
+
path,
|
|
28246
|
+
value,
|
|
28247
|
+
originalValue,
|
|
28248
|
+
options,
|
|
28249
|
+
tests: initialTests
|
|
28250
|
+
}, panic, initialErrors => {
|
|
28251
|
+
// even if we aren't ending early we can't proceed further if the types aren't correct
|
|
28252
|
+
if (initialErrors.length) {
|
|
28253
|
+
return next(initialErrors, value);
|
|
28254
|
+
}
|
|
28255
|
+
this.runTests({
|
|
28256
|
+
path,
|
|
28257
|
+
value,
|
|
28258
|
+
originalValue,
|
|
28259
|
+
options,
|
|
28260
|
+
tests: this.tests
|
|
28261
|
+
}, panic, next);
|
|
28262
|
+
});
|
|
28263
|
+
}
|
|
28264
|
+
|
|
28265
|
+
/**
|
|
28266
|
+
* Executes a set of validations, either schema, produced Tests or a nested
|
|
28267
|
+
* schema validate result.
|
|
28268
|
+
*/
|
|
28269
|
+
runTests(runOptions, panic, next) {
|
|
28270
|
+
let fired = false;
|
|
28271
|
+
let {
|
|
28272
|
+
tests,
|
|
28273
|
+
value,
|
|
28274
|
+
originalValue,
|
|
28275
|
+
path,
|
|
28276
|
+
options
|
|
28277
|
+
} = runOptions;
|
|
28278
|
+
let panicOnce = arg => {
|
|
28279
|
+
if (fired) return;
|
|
28280
|
+
fired = true;
|
|
28281
|
+
panic(arg, value);
|
|
28282
|
+
};
|
|
28283
|
+
let nextOnce = arg => {
|
|
28284
|
+
if (fired) return;
|
|
28285
|
+
fired = true;
|
|
28286
|
+
next(arg, value);
|
|
28287
|
+
};
|
|
28288
|
+
let count = tests.length;
|
|
28289
|
+
let nestedErrors = [];
|
|
28290
|
+
if (!count) return nextOnce([]);
|
|
28291
|
+
let args = {
|
|
28292
|
+
value,
|
|
28293
|
+
originalValue,
|
|
28294
|
+
path,
|
|
28295
|
+
options,
|
|
28296
|
+
schema: this
|
|
28297
|
+
};
|
|
28298
|
+
for (let i = 0; i < tests.length; i++) {
|
|
28299
|
+
const test = tests[i];
|
|
28300
|
+
test(args, panicOnce, function finishTestRun(err) {
|
|
28301
|
+
if (err) {
|
|
28302
|
+
Array.isArray(err) ? nestedErrors.push(...err) : nestedErrors.push(err);
|
|
28303
|
+
}
|
|
28304
|
+
if (--count <= 0) {
|
|
28305
|
+
nextOnce(nestedErrors);
|
|
28306
|
+
}
|
|
28307
|
+
});
|
|
28308
|
+
}
|
|
28309
|
+
}
|
|
28310
|
+
asNestedTest({
|
|
28311
|
+
key,
|
|
28312
|
+
index,
|
|
28313
|
+
parent,
|
|
28314
|
+
parentPath,
|
|
28315
|
+
originalParent,
|
|
28316
|
+
options
|
|
28317
|
+
}) {
|
|
28318
|
+
const k = key != null ? key : index;
|
|
28319
|
+
if (k == null) {
|
|
28320
|
+
throw TypeError('Must include `key` or `index` for nested validations');
|
|
28321
|
+
}
|
|
28322
|
+
const isIndex = typeof k === 'number';
|
|
28323
|
+
let value = parent[k];
|
|
28324
|
+
const testOptions = Object.assign({}, options, {
|
|
28325
|
+
// Nested validations fields are always strict:
|
|
28326
|
+
// 1. parent isn't strict so the casting will also have cast inner values
|
|
28327
|
+
// 2. parent is strict in which case the nested values weren't cast either
|
|
28328
|
+
strict: true,
|
|
28329
|
+
parent,
|
|
28330
|
+
value,
|
|
28331
|
+
originalValue: originalParent[k],
|
|
28332
|
+
// FIXME: tests depend on `index` being passed around deeply,
|
|
28333
|
+
// we should not let the options.key/index bleed through
|
|
28334
|
+
key: undefined,
|
|
28335
|
+
// index: undefined,
|
|
28336
|
+
[isIndex ? 'index' : 'key']: k,
|
|
28337
|
+
path: isIndex || k.includes('.') ? `${parentPath || ''}[${isIndex ? k : `"${k}"`}]` : (parentPath ? `${parentPath}.` : '') + key
|
|
28338
|
+
});
|
|
28339
|
+
return (_, panic, next) => this.resolve(testOptions)._validate(value, testOptions, panic, next);
|
|
28340
|
+
}
|
|
28341
|
+
validate(value, options) {
|
|
28342
|
+
var _options$disableStack2;
|
|
28343
|
+
let schema = this.resolve(Object.assign({}, options, {
|
|
28344
|
+
value
|
|
28345
|
+
}));
|
|
28346
|
+
let disableStackTrace = (_options$disableStack2 = options == null ? void 0 : options.disableStackTrace) != null ? _options$disableStack2 : schema.spec.disableStackTrace;
|
|
28347
|
+
return new Promise((resolve, reject) => schema._validate(value, options, (error, parsed) => {
|
|
28348
|
+
if (ValidationError.isError(error)) error.value = parsed;
|
|
28349
|
+
reject(error);
|
|
28350
|
+
}, (errors, validated) => {
|
|
28351
|
+
if (errors.length) reject(new ValidationError(errors, validated, undefined, undefined, disableStackTrace));else resolve(validated);
|
|
28352
|
+
}));
|
|
28353
|
+
}
|
|
28354
|
+
validateSync(value, options) {
|
|
28355
|
+
var _options$disableStack3;
|
|
28356
|
+
let schema = this.resolve(Object.assign({}, options, {
|
|
28357
|
+
value
|
|
28358
|
+
}));
|
|
28359
|
+
let result;
|
|
28360
|
+
let disableStackTrace = (_options$disableStack3 = options == null ? void 0 : options.disableStackTrace) != null ? _options$disableStack3 : schema.spec.disableStackTrace;
|
|
28361
|
+
schema._validate(value, Object.assign({}, options, {
|
|
28362
|
+
sync: true
|
|
28363
|
+
}), (error, parsed) => {
|
|
28364
|
+
if (ValidationError.isError(error)) error.value = parsed;
|
|
28365
|
+
throw error;
|
|
28366
|
+
}, (errors, validated) => {
|
|
28367
|
+
if (errors.length) throw new ValidationError(errors, value, undefined, undefined, disableStackTrace);
|
|
28368
|
+
result = validated;
|
|
28369
|
+
});
|
|
28370
|
+
return result;
|
|
28371
|
+
}
|
|
28372
|
+
isValid(value, options) {
|
|
28373
|
+
return this.validate(value, options).then(() => true, err => {
|
|
28374
|
+
if (ValidationError.isError(err)) return false;
|
|
28375
|
+
throw err;
|
|
28376
|
+
});
|
|
28377
|
+
}
|
|
28378
|
+
isValidSync(value, options) {
|
|
28379
|
+
try {
|
|
28380
|
+
this.validateSync(value, options);
|
|
28381
|
+
return true;
|
|
28382
|
+
} catch (err) {
|
|
28383
|
+
if (ValidationError.isError(err)) return false;
|
|
28384
|
+
throw err;
|
|
28385
|
+
}
|
|
28386
|
+
}
|
|
28387
|
+
_getDefault(options) {
|
|
28388
|
+
let defaultValue = this.spec.default;
|
|
28389
|
+
if (defaultValue == null) {
|
|
28390
|
+
return defaultValue;
|
|
28391
|
+
}
|
|
28392
|
+
return typeof defaultValue === 'function' ? defaultValue.call(this, options) : clone(defaultValue);
|
|
28393
|
+
}
|
|
28394
|
+
getDefault(options
|
|
28395
|
+
// If schema is defaulted we know it's at least not undefined
|
|
28396
|
+
) {
|
|
28397
|
+
let schema = this.resolve(options || {});
|
|
28398
|
+
return schema._getDefault(options);
|
|
28399
|
+
}
|
|
28400
|
+
default(def) {
|
|
28401
|
+
if (arguments.length === 0) {
|
|
28402
|
+
return this._getDefault();
|
|
28403
|
+
}
|
|
28404
|
+
let next = this.clone({
|
|
28405
|
+
default: def
|
|
28406
|
+
});
|
|
28407
|
+
return next;
|
|
28408
|
+
}
|
|
28409
|
+
strict(isStrict = true) {
|
|
28410
|
+
return this.clone({
|
|
28411
|
+
strict: isStrict
|
|
28412
|
+
});
|
|
28413
|
+
}
|
|
28414
|
+
nullability(nullable, message) {
|
|
28415
|
+
const next = this.clone({
|
|
28416
|
+
nullable
|
|
28417
|
+
});
|
|
28418
|
+
next.internalTests.nullable = createValidation({
|
|
28419
|
+
message,
|
|
28420
|
+
name: 'nullable',
|
|
28421
|
+
test(value) {
|
|
28422
|
+
return value === null ? this.schema.spec.nullable : true;
|
|
28423
|
+
}
|
|
28424
|
+
});
|
|
28425
|
+
return next;
|
|
28426
|
+
}
|
|
28427
|
+
optionality(optional, message) {
|
|
28428
|
+
const next = this.clone({
|
|
28429
|
+
optional
|
|
28430
|
+
});
|
|
28431
|
+
next.internalTests.optionality = createValidation({
|
|
28432
|
+
message,
|
|
28433
|
+
name: 'optionality',
|
|
28434
|
+
test(value) {
|
|
28435
|
+
return value === undefined ? this.schema.spec.optional : true;
|
|
28436
|
+
}
|
|
28437
|
+
});
|
|
28438
|
+
return next;
|
|
28439
|
+
}
|
|
28440
|
+
optional() {
|
|
28441
|
+
return this.optionality(true);
|
|
28442
|
+
}
|
|
28443
|
+
defined(message = mixed.defined) {
|
|
28444
|
+
return this.optionality(false, message);
|
|
28445
|
+
}
|
|
28446
|
+
nullable() {
|
|
28447
|
+
return this.nullability(true);
|
|
28448
|
+
}
|
|
28449
|
+
nonNullable(message = mixed.notNull) {
|
|
28450
|
+
return this.nullability(false, message);
|
|
28451
|
+
}
|
|
28452
|
+
required(message = mixed.required) {
|
|
28453
|
+
return this.clone().withMutation(next => next.nonNullable(message).defined(message));
|
|
28454
|
+
}
|
|
28455
|
+
notRequired() {
|
|
28456
|
+
return this.clone().withMutation(next => next.nullable().optional());
|
|
28457
|
+
}
|
|
28458
|
+
transform(fn) {
|
|
28459
|
+
let next = this.clone();
|
|
28460
|
+
next.transforms.push(fn);
|
|
28461
|
+
return next;
|
|
28462
|
+
}
|
|
28463
|
+
|
|
28464
|
+
/**
|
|
28465
|
+
* Adds a test function to the schema's queue of tests.
|
|
28466
|
+
* tests can be exclusive or non-exclusive.
|
|
28467
|
+
*
|
|
28468
|
+
* - exclusive tests, will replace any existing tests of the same name.
|
|
28469
|
+
* - non-exclusive: can be stacked
|
|
28470
|
+
*
|
|
28471
|
+
* If a non-exclusive test is added to a schema with an exclusive test of the same name
|
|
28472
|
+
* the exclusive test is removed and further tests of the same name will be stacked.
|
|
28473
|
+
*
|
|
28474
|
+
* If an exclusive test is added to a schema with non-exclusive tests of the same name
|
|
28475
|
+
* the previous tests are removed and further tests of the same name will replace each other.
|
|
28476
|
+
*/
|
|
28477
|
+
|
|
28478
|
+
test(...args) {
|
|
28479
|
+
let opts;
|
|
28480
|
+
if (args.length === 1) {
|
|
28481
|
+
if (typeof args[0] === 'function') {
|
|
28482
|
+
opts = {
|
|
28483
|
+
test: args[0]
|
|
28484
|
+
};
|
|
28485
|
+
} else {
|
|
28486
|
+
opts = args[0];
|
|
28487
|
+
}
|
|
28488
|
+
} else if (args.length === 2) {
|
|
28489
|
+
opts = {
|
|
28490
|
+
name: args[0],
|
|
28491
|
+
test: args[1]
|
|
28492
|
+
};
|
|
28493
|
+
} else {
|
|
28494
|
+
opts = {
|
|
28495
|
+
name: args[0],
|
|
28496
|
+
message: args[1],
|
|
28497
|
+
test: args[2]
|
|
28498
|
+
};
|
|
28499
|
+
}
|
|
28500
|
+
if (opts.message === undefined) opts.message = mixed.default;
|
|
28501
|
+
if (typeof opts.test !== 'function') throw new TypeError('`test` is a required parameters');
|
|
28502
|
+
let next = this.clone();
|
|
28503
|
+
let validate = createValidation(opts);
|
|
28504
|
+
let isExclusive = opts.exclusive || opts.name && next.exclusiveTests[opts.name] === true;
|
|
28505
|
+
if (opts.exclusive) {
|
|
28506
|
+
if (!opts.name) throw new TypeError('Exclusive tests must provide a unique `name` identifying the test');
|
|
28507
|
+
}
|
|
28508
|
+
if (opts.name) next.exclusiveTests[opts.name] = !!opts.exclusive;
|
|
28509
|
+
next.tests = next.tests.filter(fn => {
|
|
28510
|
+
if (fn.OPTIONS.name === opts.name) {
|
|
28511
|
+
if (isExclusive) return false;
|
|
28512
|
+
if (fn.OPTIONS.test === validate.OPTIONS.test) return false;
|
|
28513
|
+
}
|
|
28514
|
+
return true;
|
|
28515
|
+
});
|
|
28516
|
+
next.tests.push(validate);
|
|
28517
|
+
return next;
|
|
28518
|
+
}
|
|
28519
|
+
when(keys, options) {
|
|
28520
|
+
if (!Array.isArray(keys) && typeof keys !== 'string') {
|
|
28521
|
+
options = keys;
|
|
28522
|
+
keys = '.';
|
|
28523
|
+
}
|
|
28524
|
+
let next = this.clone();
|
|
28525
|
+
let deps = toArray(keys).map(key => new Reference(key));
|
|
28526
|
+
deps.forEach(dep => {
|
|
28527
|
+
// @ts-ignore readonly array
|
|
28528
|
+
if (dep.isSibling) next.deps.push(dep.key);
|
|
28529
|
+
});
|
|
28530
|
+
next.conditions.push(typeof options === 'function' ? new Condition(deps, options) : Condition.fromOptions(deps, options));
|
|
28531
|
+
return next;
|
|
28532
|
+
}
|
|
28533
|
+
typeError(message) {
|
|
28534
|
+
let next = this.clone();
|
|
28535
|
+
next.internalTests.typeError = createValidation({
|
|
28536
|
+
message,
|
|
28537
|
+
name: 'typeError',
|
|
28538
|
+
skipAbsent: true,
|
|
28539
|
+
test(value) {
|
|
28540
|
+
if (!this.schema._typeCheck(value)) return this.createError({
|
|
28541
|
+
params: {
|
|
28542
|
+
type: this.schema.type
|
|
28543
|
+
}
|
|
28544
|
+
});
|
|
28545
|
+
return true;
|
|
28546
|
+
}
|
|
28547
|
+
});
|
|
28548
|
+
return next;
|
|
28549
|
+
}
|
|
28550
|
+
oneOf(enums, message = mixed.oneOf) {
|
|
28551
|
+
let next = this.clone();
|
|
28552
|
+
enums.forEach(val => {
|
|
28553
|
+
next._whitelist.add(val);
|
|
28554
|
+
next._blacklist.delete(val);
|
|
28555
|
+
});
|
|
28556
|
+
next.internalTests.whiteList = createValidation({
|
|
28557
|
+
message,
|
|
28558
|
+
name: 'oneOf',
|
|
28559
|
+
skipAbsent: true,
|
|
28560
|
+
test(value) {
|
|
28561
|
+
let valids = this.schema._whitelist;
|
|
28562
|
+
let resolved = valids.resolveAll(this.resolve);
|
|
28563
|
+
return resolved.includes(value) ? true : this.createError({
|
|
28564
|
+
params: {
|
|
28565
|
+
values: Array.from(valids).join(', '),
|
|
28566
|
+
resolved
|
|
28567
|
+
}
|
|
28568
|
+
});
|
|
28569
|
+
}
|
|
28570
|
+
});
|
|
28571
|
+
return next;
|
|
28572
|
+
}
|
|
28573
|
+
notOneOf(enums, message = mixed.notOneOf) {
|
|
28574
|
+
let next = this.clone();
|
|
28575
|
+
enums.forEach(val => {
|
|
28576
|
+
next._blacklist.add(val);
|
|
28577
|
+
next._whitelist.delete(val);
|
|
28578
|
+
});
|
|
28579
|
+
next.internalTests.blacklist = createValidation({
|
|
28580
|
+
message,
|
|
28581
|
+
name: 'notOneOf',
|
|
28582
|
+
test(value) {
|
|
28583
|
+
let invalids = this.schema._blacklist;
|
|
28584
|
+
let resolved = invalids.resolveAll(this.resolve);
|
|
28585
|
+
if (resolved.includes(value)) return this.createError({
|
|
28586
|
+
params: {
|
|
28587
|
+
values: Array.from(invalids).join(', '),
|
|
28588
|
+
resolved
|
|
28589
|
+
}
|
|
28590
|
+
});
|
|
28591
|
+
return true;
|
|
28592
|
+
}
|
|
28593
|
+
});
|
|
28594
|
+
return next;
|
|
28595
|
+
}
|
|
28596
|
+
strip(strip = true) {
|
|
28597
|
+
let next = this.clone();
|
|
28598
|
+
next.spec.strip = strip;
|
|
28599
|
+
return next;
|
|
28600
|
+
}
|
|
28601
|
+
|
|
28602
|
+
/**
|
|
28603
|
+
* Return a serialized description of the schema including validations, flags, types etc.
|
|
28604
|
+
*
|
|
28605
|
+
* @param options Provide any needed context for resolving runtime schema alterations (lazy, when conditions, etc).
|
|
28606
|
+
*/
|
|
28607
|
+
describe(options) {
|
|
28608
|
+
const next = (options ? this.resolve(options) : this).clone();
|
|
28609
|
+
const {
|
|
28610
|
+
label,
|
|
28611
|
+
meta,
|
|
28612
|
+
optional,
|
|
28613
|
+
nullable
|
|
28614
|
+
} = next.spec;
|
|
28615
|
+
const description = {
|
|
28616
|
+
meta,
|
|
28617
|
+
label,
|
|
28618
|
+
optional,
|
|
28619
|
+
nullable,
|
|
28620
|
+
default: next.getDefault(options),
|
|
28621
|
+
type: next.type,
|
|
28622
|
+
oneOf: next._whitelist.describe(),
|
|
28623
|
+
notOneOf: next._blacklist.describe(),
|
|
28624
|
+
tests: next.tests.map(fn => ({
|
|
28625
|
+
name: fn.OPTIONS.name,
|
|
28626
|
+
params: fn.OPTIONS.params
|
|
28627
|
+
})).filter((n, idx, list) => list.findIndex(c => c.name === n.name) === idx)
|
|
28628
|
+
};
|
|
28629
|
+
return description;
|
|
28630
|
+
}
|
|
28631
|
+
}
|
|
28632
|
+
// @ts-expect-error
|
|
28633
|
+
Schema.prototype.__isYupSchema__ = true;
|
|
28634
|
+
for (const method of ['validate', 'validateSync']) Schema.prototype[`${method}At`] = function (path, value, options = {}) {
|
|
28635
|
+
const {
|
|
28636
|
+
parent,
|
|
28637
|
+
parentPath,
|
|
28638
|
+
schema
|
|
28639
|
+
} = getIn(this, path, value, options.context);
|
|
28640
|
+
return schema[method](parent && parent[parentPath], Object.assign({}, options, {
|
|
28641
|
+
parent,
|
|
28642
|
+
path
|
|
28643
|
+
}));
|
|
28644
|
+
};
|
|
28645
|
+
for (const alias of ['equals', 'is']) Schema.prototype[alias] = Schema.prototype.oneOf;
|
|
28646
|
+
for (const alias of ['not', 'nope']) Schema.prototype[alias] = Schema.prototype.notOneOf;
|
|
28647
|
+
|
|
28648
|
+
const returnsTrue = () => true;
|
|
28649
|
+
function create$8(spec) {
|
|
28650
|
+
return new MixedSchema(spec);
|
|
28651
|
+
}
|
|
28652
|
+
class MixedSchema extends Schema {
|
|
28653
|
+
constructor(spec) {
|
|
28654
|
+
super(typeof spec === 'function' ? {
|
|
28655
|
+
type: 'mixed',
|
|
28656
|
+
check: spec
|
|
28657
|
+
} : Object.assign({
|
|
28658
|
+
type: 'mixed',
|
|
28659
|
+
check: returnsTrue
|
|
28660
|
+
}, spec));
|
|
28661
|
+
}
|
|
28662
|
+
}
|
|
28663
|
+
create$8.prototype = MixedSchema.prototype;
|
|
28664
|
+
|
|
28665
|
+
function create$7() {
|
|
28666
|
+
return new BooleanSchema();
|
|
28667
|
+
}
|
|
28668
|
+
class BooleanSchema extends Schema {
|
|
28669
|
+
constructor() {
|
|
28670
|
+
super({
|
|
28671
|
+
type: 'boolean',
|
|
28672
|
+
check(v) {
|
|
28673
|
+
if (v instanceof Boolean) v = v.valueOf();
|
|
28674
|
+
return typeof v === 'boolean';
|
|
28675
|
+
}
|
|
28676
|
+
});
|
|
28677
|
+
this.withMutation(() => {
|
|
28678
|
+
this.transform((value, _raw, ctx) => {
|
|
28679
|
+
if (ctx.spec.coerce && !ctx.isType(value)) {
|
|
28680
|
+
if (/^(true|1)$/i.test(String(value))) return true;
|
|
28681
|
+
if (/^(false|0)$/i.test(String(value))) return false;
|
|
28682
|
+
}
|
|
28683
|
+
return value;
|
|
28684
|
+
});
|
|
28685
|
+
});
|
|
28686
|
+
}
|
|
28687
|
+
isTrue(message = boolean.isValue) {
|
|
28688
|
+
return this.test({
|
|
28689
|
+
message,
|
|
28690
|
+
name: 'is-value',
|
|
28691
|
+
exclusive: true,
|
|
28692
|
+
params: {
|
|
28693
|
+
value: 'true'
|
|
28694
|
+
},
|
|
28695
|
+
test(value) {
|
|
28696
|
+
return isAbsent(value) || value === true;
|
|
28697
|
+
}
|
|
28698
|
+
});
|
|
28699
|
+
}
|
|
28700
|
+
isFalse(message = boolean.isValue) {
|
|
28701
|
+
return this.test({
|
|
28702
|
+
message,
|
|
28703
|
+
name: 'is-value',
|
|
28704
|
+
exclusive: true,
|
|
28705
|
+
params: {
|
|
28706
|
+
value: 'false'
|
|
28707
|
+
},
|
|
28708
|
+
test(value) {
|
|
28709
|
+
return isAbsent(value) || value === false;
|
|
28710
|
+
}
|
|
28711
|
+
});
|
|
28712
|
+
}
|
|
28713
|
+
default(def) {
|
|
28714
|
+
return super.default(def);
|
|
28715
|
+
}
|
|
28716
|
+
defined(msg) {
|
|
28717
|
+
return super.defined(msg);
|
|
28718
|
+
}
|
|
28719
|
+
optional() {
|
|
28720
|
+
return super.optional();
|
|
28721
|
+
}
|
|
28722
|
+
required(msg) {
|
|
28723
|
+
return super.required(msg);
|
|
28724
|
+
}
|
|
28725
|
+
notRequired() {
|
|
28726
|
+
return super.notRequired();
|
|
28727
|
+
}
|
|
28728
|
+
nullable() {
|
|
28729
|
+
return super.nullable();
|
|
28730
|
+
}
|
|
28731
|
+
nonNullable(msg) {
|
|
28732
|
+
return super.nonNullable(msg);
|
|
28733
|
+
}
|
|
28734
|
+
strip(v) {
|
|
28735
|
+
return super.strip(v);
|
|
28736
|
+
}
|
|
28737
|
+
}
|
|
28738
|
+
create$7.prototype = BooleanSchema.prototype;
|
|
28739
|
+
|
|
28740
|
+
/**
|
|
28741
|
+
* This file is a modified version of the file from the following repository:
|
|
28742
|
+
* Date.parse with progressive enhancement for ISO 8601 <https://github.com/csnover/js-iso8601>
|
|
28743
|
+
* NON-CONFORMANT EDITION.
|
|
28744
|
+
* © 2011 Colin Snover <http://zetafleet.com>
|
|
28745
|
+
* Released under MIT license.
|
|
28746
|
+
*/
|
|
28747
|
+
|
|
28748
|
+
// prettier-ignore
|
|
28749
|
+
// 1 YYYY 2 MM 3 DD 4 HH 5 mm 6 ss 7 msec 8 Z 9 ± 10 tzHH 11 tzmm
|
|
28750
|
+
const isoReg = /^(\d{4}|[+-]\d{6})(?:-?(\d{2})(?:-?(\d{2}))?)?(?:[ T]?(\d{2}):?(\d{2})(?::?(\d{2})(?:[,.](\d{1,}))?)?(?:(Z)|([+-])(\d{2})(?::?(\d{2}))?)?)?$/;
|
|
28751
|
+
function parseIsoDate(date) {
|
|
28752
|
+
const struct = parseDateStruct(date);
|
|
28753
|
+
if (!struct) return Date.parse ? Date.parse(date) : Number.NaN;
|
|
28754
|
+
|
|
28755
|
+
// timestamps without timezone identifiers should be considered local time
|
|
28756
|
+
if (struct.z === undefined && struct.plusMinus === undefined) {
|
|
28757
|
+
return new Date(struct.year, struct.month, struct.day, struct.hour, struct.minute, struct.second, struct.millisecond).valueOf();
|
|
28758
|
+
}
|
|
28759
|
+
let totalMinutesOffset = 0;
|
|
28760
|
+
if (struct.z !== 'Z' && struct.plusMinus !== undefined) {
|
|
28761
|
+
totalMinutesOffset = struct.hourOffset * 60 + struct.minuteOffset;
|
|
28762
|
+
if (struct.plusMinus === '+') totalMinutesOffset = 0 - totalMinutesOffset;
|
|
28763
|
+
}
|
|
28764
|
+
return Date.UTC(struct.year, struct.month, struct.day, struct.hour, struct.minute + totalMinutesOffset, struct.second, struct.millisecond);
|
|
28765
|
+
}
|
|
28766
|
+
function parseDateStruct(date) {
|
|
28767
|
+
var _regexResult$7$length, _regexResult$;
|
|
28768
|
+
const regexResult = isoReg.exec(date);
|
|
28769
|
+
if (!regexResult) return null;
|
|
28770
|
+
|
|
28771
|
+
// use of toNumber() avoids NaN timestamps caused by “undefined”
|
|
28772
|
+
// values being passed to Date constructor
|
|
28773
|
+
return {
|
|
28774
|
+
year: toNumber(regexResult[1]),
|
|
28775
|
+
month: toNumber(regexResult[2], 1) - 1,
|
|
28776
|
+
day: toNumber(regexResult[3], 1),
|
|
28777
|
+
hour: toNumber(regexResult[4]),
|
|
28778
|
+
minute: toNumber(regexResult[5]),
|
|
28779
|
+
second: toNumber(regexResult[6]),
|
|
28780
|
+
millisecond: regexResult[7] ?
|
|
28781
|
+
// allow arbitrary sub-second precision beyond milliseconds
|
|
28782
|
+
toNumber(regexResult[7].substring(0, 3)) : 0,
|
|
28783
|
+
precision: (_regexResult$7$length = (_regexResult$ = regexResult[7]) == null ? void 0 : _regexResult$.length) != null ? _regexResult$7$length : undefined,
|
|
28784
|
+
z: regexResult[8] || undefined,
|
|
28785
|
+
plusMinus: regexResult[9] || undefined,
|
|
28786
|
+
hourOffset: toNumber(regexResult[10]),
|
|
28787
|
+
minuteOffset: toNumber(regexResult[11])
|
|
28788
|
+
};
|
|
28789
|
+
}
|
|
28790
|
+
function toNumber(str, defaultValue = 0) {
|
|
28791
|
+
return Number(str) || defaultValue;
|
|
28792
|
+
}
|
|
28793
|
+
|
|
28794
|
+
// Taken from HTML spec: https://html.spec.whatwg.org/multipage/input.html#valid-e-mail-address
|
|
28795
|
+
let rEmail =
|
|
28796
|
+
// eslint-disable-next-line
|
|
28797
|
+
/^[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])?)*$/;
|
|
28798
|
+
let rUrl =
|
|
28799
|
+
// eslint-disable-next-line
|
|
28800
|
+
/^((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;
|
|
28801
|
+
|
|
28802
|
+
// eslint-disable-next-line
|
|
28803
|
+
let rUUID = /^(?:[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;
|
|
28804
|
+
let yearMonthDay = '^\\d{4}-\\d{2}-\\d{2}';
|
|
28805
|
+
let hourMinuteSecond = '\\d{2}:\\d{2}:\\d{2}';
|
|
28806
|
+
let zOrOffset = '(([+-]\\d{2}(:?\\d{2})?)|Z)';
|
|
28807
|
+
let rIsoDateTime = new RegExp(`${yearMonthDay}T${hourMinuteSecond}(\\.\\d+)?${zOrOffset}$`);
|
|
28808
|
+
let isTrimmed = value => isAbsent(value) || value === value.trim();
|
|
28809
|
+
let objStringTag = {}.toString();
|
|
28810
|
+
function create$6() {
|
|
28811
|
+
return new StringSchema();
|
|
28812
|
+
}
|
|
28813
|
+
class StringSchema extends Schema {
|
|
28814
|
+
constructor() {
|
|
28815
|
+
super({
|
|
28816
|
+
type: 'string',
|
|
28817
|
+
check(value) {
|
|
28818
|
+
if (value instanceof String) value = value.valueOf();
|
|
28819
|
+
return typeof value === 'string';
|
|
28820
|
+
}
|
|
28821
|
+
});
|
|
28822
|
+
this.withMutation(() => {
|
|
28823
|
+
this.transform((value, _raw, ctx) => {
|
|
28824
|
+
if (!ctx.spec.coerce || ctx.isType(value)) return value;
|
|
28825
|
+
|
|
28826
|
+
// don't ever convert arrays
|
|
28827
|
+
if (Array.isArray(value)) return value;
|
|
28828
|
+
const strValue = value != null && value.toString ? value.toString() : value;
|
|
28829
|
+
|
|
28830
|
+
// no one wants plain objects converted to [Object object]
|
|
28831
|
+
if (strValue === objStringTag) return value;
|
|
28832
|
+
return strValue;
|
|
28833
|
+
});
|
|
28834
|
+
});
|
|
28835
|
+
}
|
|
28836
|
+
required(message) {
|
|
28837
|
+
return super.required(message).withMutation(schema => schema.test({
|
|
28838
|
+
message: message || mixed.required,
|
|
28839
|
+
name: 'required',
|
|
28840
|
+
skipAbsent: true,
|
|
28841
|
+
test: value => !!value.length
|
|
28842
|
+
}));
|
|
28843
|
+
}
|
|
28844
|
+
notRequired() {
|
|
28845
|
+
return super.notRequired().withMutation(schema => {
|
|
28846
|
+
schema.tests = schema.tests.filter(t => t.OPTIONS.name !== 'required');
|
|
28847
|
+
return schema;
|
|
28848
|
+
});
|
|
28849
|
+
}
|
|
28850
|
+
length(length, message = string.length) {
|
|
28851
|
+
return this.test({
|
|
28852
|
+
message,
|
|
28853
|
+
name: 'length',
|
|
28854
|
+
exclusive: true,
|
|
28855
|
+
params: {
|
|
28856
|
+
length
|
|
28857
|
+
},
|
|
28858
|
+
skipAbsent: true,
|
|
28859
|
+
test(value) {
|
|
28860
|
+
return value.length === this.resolve(length);
|
|
28861
|
+
}
|
|
28862
|
+
});
|
|
28863
|
+
}
|
|
28864
|
+
min(min, message = string.min) {
|
|
28865
|
+
return this.test({
|
|
28866
|
+
message,
|
|
28867
|
+
name: 'min',
|
|
28868
|
+
exclusive: true,
|
|
28869
|
+
params: {
|
|
28870
|
+
min
|
|
28871
|
+
},
|
|
28872
|
+
skipAbsent: true,
|
|
28873
|
+
test(value) {
|
|
28874
|
+
return value.length >= this.resolve(min);
|
|
28875
|
+
}
|
|
28876
|
+
});
|
|
28877
|
+
}
|
|
28878
|
+
max(max, message = string.max) {
|
|
28879
|
+
return this.test({
|
|
28880
|
+
name: 'max',
|
|
28881
|
+
exclusive: true,
|
|
28882
|
+
message,
|
|
28883
|
+
params: {
|
|
28884
|
+
max
|
|
28885
|
+
},
|
|
28886
|
+
skipAbsent: true,
|
|
28887
|
+
test(value) {
|
|
28888
|
+
return value.length <= this.resolve(max);
|
|
28889
|
+
}
|
|
28890
|
+
});
|
|
28891
|
+
}
|
|
28892
|
+
matches(regex, options) {
|
|
28893
|
+
let excludeEmptyString = false;
|
|
28894
|
+
let message;
|
|
28895
|
+
let name;
|
|
28896
|
+
if (options) {
|
|
28897
|
+
if (typeof options === 'object') {
|
|
28898
|
+
({
|
|
28899
|
+
excludeEmptyString = false,
|
|
28900
|
+
message,
|
|
28901
|
+
name
|
|
28902
|
+
} = options);
|
|
28903
|
+
} else {
|
|
28904
|
+
message = options;
|
|
28905
|
+
}
|
|
28906
|
+
}
|
|
28907
|
+
return this.test({
|
|
28908
|
+
name: name || 'matches',
|
|
28909
|
+
message: message || string.matches,
|
|
28910
|
+
params: {
|
|
28911
|
+
regex
|
|
28912
|
+
},
|
|
28913
|
+
skipAbsent: true,
|
|
28914
|
+
test: value => value === '' && excludeEmptyString || value.search(regex) !== -1
|
|
28915
|
+
});
|
|
28916
|
+
}
|
|
28917
|
+
email(message = string.email) {
|
|
28918
|
+
return this.matches(rEmail, {
|
|
28919
|
+
name: 'email',
|
|
28920
|
+
message,
|
|
28921
|
+
excludeEmptyString: true
|
|
28922
|
+
});
|
|
28923
|
+
}
|
|
28924
|
+
url(message = string.url) {
|
|
28925
|
+
return this.matches(rUrl, {
|
|
28926
|
+
name: 'url',
|
|
28927
|
+
message,
|
|
28928
|
+
excludeEmptyString: true
|
|
28929
|
+
});
|
|
28930
|
+
}
|
|
28931
|
+
uuid(message = string.uuid) {
|
|
28932
|
+
return this.matches(rUUID, {
|
|
28933
|
+
name: 'uuid',
|
|
28934
|
+
message,
|
|
28935
|
+
excludeEmptyString: false
|
|
28936
|
+
});
|
|
28937
|
+
}
|
|
28938
|
+
datetime(options) {
|
|
28939
|
+
let message = '';
|
|
28940
|
+
let allowOffset;
|
|
28941
|
+
let precision;
|
|
28942
|
+
if (options) {
|
|
28943
|
+
if (typeof options === 'object') {
|
|
28944
|
+
({
|
|
28945
|
+
message = '',
|
|
28946
|
+
allowOffset = false,
|
|
28947
|
+
precision = undefined
|
|
28948
|
+
} = options);
|
|
28949
|
+
} else {
|
|
28950
|
+
message = options;
|
|
28951
|
+
}
|
|
28952
|
+
}
|
|
28953
|
+
return this.matches(rIsoDateTime, {
|
|
28954
|
+
name: 'datetime',
|
|
28955
|
+
message: message || string.datetime,
|
|
28956
|
+
excludeEmptyString: true
|
|
28957
|
+
}).test({
|
|
28958
|
+
name: 'datetime_offset',
|
|
28959
|
+
message: message || string.datetime_offset,
|
|
28960
|
+
params: {
|
|
28961
|
+
allowOffset
|
|
28962
|
+
},
|
|
28963
|
+
skipAbsent: true,
|
|
28964
|
+
test: value => {
|
|
28965
|
+
if (!value || allowOffset) return true;
|
|
28966
|
+
const struct = parseDateStruct(value);
|
|
28967
|
+
if (!struct) return false;
|
|
28968
|
+
return !!struct.z;
|
|
28969
|
+
}
|
|
28970
|
+
}).test({
|
|
28971
|
+
name: 'datetime_precision',
|
|
28972
|
+
message: message || string.datetime_precision,
|
|
28973
|
+
params: {
|
|
28974
|
+
precision
|
|
28975
|
+
},
|
|
28976
|
+
skipAbsent: true,
|
|
28977
|
+
test: value => {
|
|
28978
|
+
if (!value || precision == undefined) return true;
|
|
28979
|
+
const struct = parseDateStruct(value);
|
|
28980
|
+
if (!struct) return false;
|
|
28981
|
+
return struct.precision === precision;
|
|
28982
|
+
}
|
|
28983
|
+
});
|
|
28984
|
+
}
|
|
28985
|
+
|
|
28986
|
+
//-- transforms --
|
|
28987
|
+
ensure() {
|
|
28988
|
+
return this.default('').transform(val => val === null ? '' : val);
|
|
28989
|
+
}
|
|
28990
|
+
trim(message = string.trim) {
|
|
28991
|
+
return this.transform(val => val != null ? val.trim() : val).test({
|
|
28992
|
+
message,
|
|
28993
|
+
name: 'trim',
|
|
28994
|
+
test: isTrimmed
|
|
28995
|
+
});
|
|
28996
|
+
}
|
|
28997
|
+
lowercase(message = string.lowercase) {
|
|
28998
|
+
return this.transform(value => !isAbsent(value) ? value.toLowerCase() : value).test({
|
|
28999
|
+
message,
|
|
29000
|
+
name: 'string_case',
|
|
29001
|
+
exclusive: true,
|
|
29002
|
+
skipAbsent: true,
|
|
29003
|
+
test: value => isAbsent(value) || value === value.toLowerCase()
|
|
29004
|
+
});
|
|
29005
|
+
}
|
|
29006
|
+
uppercase(message = string.uppercase) {
|
|
29007
|
+
return this.transform(value => !isAbsent(value) ? value.toUpperCase() : value).test({
|
|
29008
|
+
message,
|
|
29009
|
+
name: 'string_case',
|
|
29010
|
+
exclusive: true,
|
|
29011
|
+
skipAbsent: true,
|
|
29012
|
+
test: value => isAbsent(value) || value === value.toUpperCase()
|
|
29013
|
+
});
|
|
29014
|
+
}
|
|
29015
|
+
}
|
|
29016
|
+
create$6.prototype = StringSchema.prototype;
|
|
29017
|
+
|
|
29018
|
+
//
|
|
29019
|
+
// String Interfaces
|
|
29020
|
+
//
|
|
29021
|
+
|
|
29022
|
+
let isNaN$1 = value => value != +value;
|
|
29023
|
+
function create$5() {
|
|
29024
|
+
return new NumberSchema();
|
|
29025
|
+
}
|
|
29026
|
+
class NumberSchema extends Schema {
|
|
29027
|
+
constructor() {
|
|
29028
|
+
super({
|
|
29029
|
+
type: 'number',
|
|
29030
|
+
check(value) {
|
|
29031
|
+
if (value instanceof Number) value = value.valueOf();
|
|
29032
|
+
return typeof value === 'number' && !isNaN$1(value);
|
|
29033
|
+
}
|
|
29034
|
+
});
|
|
29035
|
+
this.withMutation(() => {
|
|
29036
|
+
this.transform((value, _raw, ctx) => {
|
|
29037
|
+
if (!ctx.spec.coerce) return value;
|
|
29038
|
+
let parsed = value;
|
|
29039
|
+
if (typeof parsed === 'string') {
|
|
29040
|
+
parsed = parsed.replace(/\s/g, '');
|
|
29041
|
+
if (parsed === '') return NaN;
|
|
29042
|
+
// don't use parseFloat to avoid positives on alpha-numeric strings
|
|
29043
|
+
parsed = +parsed;
|
|
29044
|
+
}
|
|
29045
|
+
|
|
29046
|
+
// null -> NaN isn't useful; treat all nulls as null and let it fail on
|
|
29047
|
+
// nullability check vs TypeErrors
|
|
29048
|
+
if (ctx.isType(parsed) || parsed === null) return parsed;
|
|
29049
|
+
return parseFloat(parsed);
|
|
29050
|
+
});
|
|
29051
|
+
});
|
|
29052
|
+
}
|
|
29053
|
+
min(min, message = number.min) {
|
|
29054
|
+
return this.test({
|
|
29055
|
+
message,
|
|
29056
|
+
name: 'min',
|
|
29057
|
+
exclusive: true,
|
|
29058
|
+
params: {
|
|
29059
|
+
min
|
|
29060
|
+
},
|
|
29061
|
+
skipAbsent: true,
|
|
29062
|
+
test(value) {
|
|
29063
|
+
return value >= this.resolve(min);
|
|
29064
|
+
}
|
|
29065
|
+
});
|
|
29066
|
+
}
|
|
29067
|
+
max(max, message = number.max) {
|
|
29068
|
+
return this.test({
|
|
29069
|
+
message,
|
|
29070
|
+
name: 'max',
|
|
29071
|
+
exclusive: true,
|
|
29072
|
+
params: {
|
|
29073
|
+
max
|
|
29074
|
+
},
|
|
29075
|
+
skipAbsent: true,
|
|
29076
|
+
test(value) {
|
|
29077
|
+
return value <= this.resolve(max);
|
|
29078
|
+
}
|
|
29079
|
+
});
|
|
29080
|
+
}
|
|
29081
|
+
lessThan(less, message = number.lessThan) {
|
|
29082
|
+
return this.test({
|
|
29083
|
+
message,
|
|
29084
|
+
name: 'max',
|
|
29085
|
+
exclusive: true,
|
|
29086
|
+
params: {
|
|
29087
|
+
less
|
|
29088
|
+
},
|
|
29089
|
+
skipAbsent: true,
|
|
29090
|
+
test(value) {
|
|
29091
|
+
return value < this.resolve(less);
|
|
29092
|
+
}
|
|
29093
|
+
});
|
|
29094
|
+
}
|
|
29095
|
+
moreThan(more, message = number.moreThan) {
|
|
29096
|
+
return this.test({
|
|
29097
|
+
message,
|
|
29098
|
+
name: 'min',
|
|
29099
|
+
exclusive: true,
|
|
29100
|
+
params: {
|
|
29101
|
+
more
|
|
29102
|
+
},
|
|
29103
|
+
skipAbsent: true,
|
|
29104
|
+
test(value) {
|
|
29105
|
+
return value > this.resolve(more);
|
|
29106
|
+
}
|
|
29107
|
+
});
|
|
29108
|
+
}
|
|
29109
|
+
positive(msg = number.positive) {
|
|
29110
|
+
return this.moreThan(0, msg);
|
|
29111
|
+
}
|
|
29112
|
+
negative(msg = number.negative) {
|
|
29113
|
+
return this.lessThan(0, msg);
|
|
29114
|
+
}
|
|
29115
|
+
integer(message = number.integer) {
|
|
29116
|
+
return this.test({
|
|
29117
|
+
name: 'integer',
|
|
29118
|
+
message,
|
|
29119
|
+
skipAbsent: true,
|
|
29120
|
+
test: val => Number.isInteger(val)
|
|
29121
|
+
});
|
|
29122
|
+
}
|
|
29123
|
+
truncate() {
|
|
29124
|
+
return this.transform(value => !isAbsent(value) ? value | 0 : value);
|
|
29125
|
+
}
|
|
29126
|
+
round(method) {
|
|
29127
|
+
var _method;
|
|
29128
|
+
let avail = ['ceil', 'floor', 'round', 'trunc'];
|
|
29129
|
+
method = ((_method = method) == null ? void 0 : _method.toLowerCase()) || 'round';
|
|
29130
|
+
|
|
29131
|
+
// this exists for symemtry with the new Math.trunc
|
|
29132
|
+
if (method === 'trunc') return this.truncate();
|
|
29133
|
+
if (avail.indexOf(method.toLowerCase()) === -1) throw new TypeError('Only valid options for round() are: ' + avail.join(', '));
|
|
29134
|
+
return this.transform(value => !isAbsent(value) ? Math[method](value) : value);
|
|
29135
|
+
}
|
|
29136
|
+
}
|
|
29137
|
+
create$5.prototype = NumberSchema.prototype;
|
|
29138
|
+
|
|
29139
|
+
//
|
|
29140
|
+
// Number Interfaces
|
|
29141
|
+
//
|
|
29142
|
+
|
|
29143
|
+
let invalidDate = new Date('');
|
|
29144
|
+
let isDate = obj => Object.prototype.toString.call(obj) === '[object Date]';
|
|
29145
|
+
function create$4() {
|
|
29146
|
+
return new DateSchema();
|
|
29147
|
+
}
|
|
29148
|
+
class DateSchema extends Schema {
|
|
29149
|
+
constructor() {
|
|
29150
|
+
super({
|
|
29151
|
+
type: 'date',
|
|
29152
|
+
check(v) {
|
|
29153
|
+
return isDate(v) && !isNaN(v.getTime());
|
|
29154
|
+
}
|
|
29155
|
+
});
|
|
29156
|
+
this.withMutation(() => {
|
|
29157
|
+
this.transform((value, _raw, ctx) => {
|
|
29158
|
+
// null -> InvalidDate isn't useful; treat all nulls as null and let it fail on
|
|
29159
|
+
// nullability check vs TypeErrors
|
|
29160
|
+
if (!ctx.spec.coerce || ctx.isType(value) || value === null) return value;
|
|
29161
|
+
value = parseIsoDate(value);
|
|
29162
|
+
|
|
29163
|
+
// 0 is a valid timestamp equivalent to 1970-01-01T00:00:00Z(unix epoch) or before.
|
|
29164
|
+
return !isNaN(value) ? new Date(value) : DateSchema.INVALID_DATE;
|
|
29165
|
+
});
|
|
29166
|
+
});
|
|
29167
|
+
}
|
|
29168
|
+
prepareParam(ref, name) {
|
|
29169
|
+
let param;
|
|
29170
|
+
if (!Reference.isRef(ref)) {
|
|
29171
|
+
let cast = this.cast(ref);
|
|
29172
|
+
if (!this._typeCheck(cast)) throw new TypeError(`\`${name}\` must be a Date or a value that can be \`cast()\` to a Date`);
|
|
29173
|
+
param = cast;
|
|
29174
|
+
} else {
|
|
29175
|
+
param = ref;
|
|
29176
|
+
}
|
|
29177
|
+
return param;
|
|
29178
|
+
}
|
|
29179
|
+
min(min, message = date.min) {
|
|
29180
|
+
let limit = this.prepareParam(min, 'min');
|
|
29181
|
+
return this.test({
|
|
29182
|
+
message,
|
|
29183
|
+
name: 'min',
|
|
29184
|
+
exclusive: true,
|
|
29185
|
+
params: {
|
|
29186
|
+
min
|
|
29187
|
+
},
|
|
29188
|
+
skipAbsent: true,
|
|
29189
|
+
test(value) {
|
|
29190
|
+
return value >= this.resolve(limit);
|
|
29191
|
+
}
|
|
29192
|
+
});
|
|
29193
|
+
}
|
|
29194
|
+
max(max, message = date.max) {
|
|
29195
|
+
let limit = this.prepareParam(max, 'max');
|
|
29196
|
+
return this.test({
|
|
29197
|
+
message,
|
|
29198
|
+
name: 'max',
|
|
29199
|
+
exclusive: true,
|
|
29200
|
+
params: {
|
|
29201
|
+
max
|
|
29202
|
+
},
|
|
29203
|
+
skipAbsent: true,
|
|
29204
|
+
test(value) {
|
|
29205
|
+
return value <= this.resolve(limit);
|
|
29206
|
+
}
|
|
29207
|
+
});
|
|
29208
|
+
}
|
|
29209
|
+
}
|
|
29210
|
+
DateSchema.INVALID_DATE = invalidDate;
|
|
29211
|
+
create$4.prototype = DateSchema.prototype;
|
|
29212
|
+
create$4.INVALID_DATE = invalidDate;
|
|
29213
|
+
|
|
29214
|
+
// @ts-expect-error
|
|
29215
|
+
function sortFields(fields, excludedEdges = []) {
|
|
29216
|
+
let edges = [];
|
|
29217
|
+
let nodes = new Set();
|
|
29218
|
+
let excludes = new Set(excludedEdges.map(([a, b]) => `${a}-${b}`));
|
|
29219
|
+
function addNode(depPath, key) {
|
|
29220
|
+
let node = propertyExprExports.split(depPath)[0];
|
|
29221
|
+
nodes.add(node);
|
|
29222
|
+
if (!excludes.has(`${key}-${node}`)) edges.push([key, node]);
|
|
29223
|
+
}
|
|
29224
|
+
for (const key of Object.keys(fields)) {
|
|
29225
|
+
let value = fields[key];
|
|
29226
|
+
nodes.add(key);
|
|
29227
|
+
if (Reference.isRef(value) && value.isSibling) addNode(value.path, key);else if (isSchema(value) && 'deps' in value) value.deps.forEach(path => addNode(path, key));
|
|
29228
|
+
}
|
|
29229
|
+
return toposort.array(Array.from(nodes), edges).reverse();
|
|
29230
|
+
}
|
|
29231
|
+
|
|
29232
|
+
function findIndex(arr, err) {
|
|
29233
|
+
let idx = Infinity;
|
|
29234
|
+
arr.some((key, ii) => {
|
|
29235
|
+
var _err$path;
|
|
29236
|
+
if ((_err$path = err.path) != null && _err$path.includes(key)) {
|
|
29237
|
+
idx = ii;
|
|
29238
|
+
return true;
|
|
29239
|
+
}
|
|
29240
|
+
});
|
|
29241
|
+
return idx;
|
|
29242
|
+
}
|
|
29243
|
+
function sortByKeyOrder(keys) {
|
|
29244
|
+
return (a, b) => {
|
|
29245
|
+
return findIndex(keys, a) - findIndex(keys, b);
|
|
29246
|
+
};
|
|
29247
|
+
}
|
|
29248
|
+
|
|
29249
|
+
const parseJson = (value, _, ctx) => {
|
|
29250
|
+
if (typeof value !== 'string') {
|
|
29251
|
+
return value;
|
|
29252
|
+
}
|
|
29253
|
+
let parsed = value;
|
|
29254
|
+
try {
|
|
29255
|
+
parsed = JSON.parse(value);
|
|
29256
|
+
} catch (err) {
|
|
29257
|
+
/* */
|
|
29258
|
+
}
|
|
29259
|
+
return ctx.isType(parsed) ? parsed : value;
|
|
29260
|
+
};
|
|
29261
|
+
|
|
29262
|
+
// @ts-ignore
|
|
29263
|
+
function deepPartial(schema) {
|
|
29264
|
+
if ('fields' in schema) {
|
|
29265
|
+
const partial = {};
|
|
29266
|
+
for (const [key, fieldSchema] of Object.entries(schema.fields)) {
|
|
29267
|
+
partial[key] = deepPartial(fieldSchema);
|
|
29268
|
+
}
|
|
29269
|
+
return schema.setFields(partial);
|
|
29270
|
+
}
|
|
29271
|
+
if (schema.type === 'array') {
|
|
29272
|
+
const nextArray = schema.optional();
|
|
29273
|
+
if (nextArray.innerType) nextArray.innerType = deepPartial(nextArray.innerType);
|
|
29274
|
+
return nextArray;
|
|
29275
|
+
}
|
|
29276
|
+
if (schema.type === 'tuple') {
|
|
29277
|
+
return schema.optional().clone({
|
|
29278
|
+
types: schema.spec.types.map(deepPartial)
|
|
29279
|
+
});
|
|
29280
|
+
}
|
|
29281
|
+
if ('optional' in schema) {
|
|
29282
|
+
return schema.optional();
|
|
29283
|
+
}
|
|
29284
|
+
return schema;
|
|
29285
|
+
}
|
|
29286
|
+
const deepHas = (obj, p) => {
|
|
29287
|
+
const path = [...propertyExprExports.normalizePath(p)];
|
|
29288
|
+
if (path.length === 1) return path[0] in obj;
|
|
29289
|
+
let last = path.pop();
|
|
29290
|
+
let parent = propertyExprExports.getter(propertyExprExports.join(path), true)(obj);
|
|
29291
|
+
return !!(parent && last in parent);
|
|
29292
|
+
};
|
|
29293
|
+
let isObject = obj => Object.prototype.toString.call(obj) === '[object Object]';
|
|
29294
|
+
function unknown(ctx, value) {
|
|
29295
|
+
let known = Object.keys(ctx.fields);
|
|
29296
|
+
return Object.keys(value).filter(key => known.indexOf(key) === -1);
|
|
29297
|
+
}
|
|
29298
|
+
const defaultSort = sortByKeyOrder([]);
|
|
29299
|
+
function create$3(spec) {
|
|
29300
|
+
return new ObjectSchema(spec);
|
|
29301
|
+
}
|
|
29302
|
+
class ObjectSchema extends Schema {
|
|
29303
|
+
constructor(spec) {
|
|
29304
|
+
super({
|
|
29305
|
+
type: 'object',
|
|
29306
|
+
check(value) {
|
|
29307
|
+
return isObject(value) || typeof value === 'function';
|
|
29308
|
+
}
|
|
29309
|
+
});
|
|
29310
|
+
this.fields = Object.create(null);
|
|
29311
|
+
this._sortErrors = defaultSort;
|
|
29312
|
+
this._nodes = [];
|
|
29313
|
+
this._excludedEdges = [];
|
|
29314
|
+
this.withMutation(() => {
|
|
29315
|
+
if (spec) {
|
|
29316
|
+
this.shape(spec);
|
|
29317
|
+
}
|
|
29318
|
+
});
|
|
29319
|
+
}
|
|
29320
|
+
_cast(_value, options = {}) {
|
|
29321
|
+
var _options$stripUnknown;
|
|
29322
|
+
let value = super._cast(_value, options);
|
|
29323
|
+
|
|
29324
|
+
//should ignore nulls here
|
|
29325
|
+
if (value === undefined) return this.getDefault(options);
|
|
29326
|
+
if (!this._typeCheck(value)) return value;
|
|
29327
|
+
let fields = this.fields;
|
|
29328
|
+
let strip = (_options$stripUnknown = options.stripUnknown) != null ? _options$stripUnknown : this.spec.noUnknown;
|
|
29329
|
+
let props = [].concat(this._nodes, Object.keys(value).filter(v => !this._nodes.includes(v)));
|
|
29330
|
+
let intermediateValue = {}; // is filled during the transform below
|
|
29331
|
+
let innerOptions = Object.assign({}, options, {
|
|
29332
|
+
parent: intermediateValue,
|
|
29333
|
+
__validating: options.__validating || false
|
|
29334
|
+
});
|
|
29335
|
+
let isChanged = false;
|
|
29336
|
+
for (const prop of props) {
|
|
29337
|
+
let field = fields[prop];
|
|
29338
|
+
let exists = (prop in value);
|
|
29339
|
+
if (field) {
|
|
29340
|
+
let fieldValue;
|
|
29341
|
+
let inputValue = value[prop];
|
|
29342
|
+
|
|
29343
|
+
// safe to mutate since this is fired in sequence
|
|
29344
|
+
innerOptions.path = (options.path ? `${options.path}.` : '') + prop;
|
|
29345
|
+
field = field.resolve({
|
|
29346
|
+
value: inputValue,
|
|
29347
|
+
context: options.context,
|
|
29348
|
+
parent: intermediateValue
|
|
29349
|
+
});
|
|
29350
|
+
let fieldSpec = field instanceof Schema ? field.spec : undefined;
|
|
29351
|
+
let strict = fieldSpec == null ? void 0 : fieldSpec.strict;
|
|
29352
|
+
if (fieldSpec != null && fieldSpec.strip) {
|
|
29353
|
+
isChanged = isChanged || prop in value;
|
|
29354
|
+
continue;
|
|
29355
|
+
}
|
|
29356
|
+
fieldValue = !options.__validating || !strict ?
|
|
29357
|
+
// TODO: use _cast, this is double resolving
|
|
29358
|
+
field.cast(value[prop], innerOptions) : value[prop];
|
|
29359
|
+
if (fieldValue !== undefined) {
|
|
29360
|
+
intermediateValue[prop] = fieldValue;
|
|
29361
|
+
}
|
|
29362
|
+
} else if (exists && !strip) {
|
|
29363
|
+
intermediateValue[prop] = value[prop];
|
|
29364
|
+
}
|
|
29365
|
+
if (exists !== prop in intermediateValue || intermediateValue[prop] !== value[prop]) {
|
|
29366
|
+
isChanged = true;
|
|
29367
|
+
}
|
|
29368
|
+
}
|
|
29369
|
+
return isChanged ? intermediateValue : value;
|
|
29370
|
+
}
|
|
29371
|
+
_validate(_value, options = {}, panic, next) {
|
|
29372
|
+
let {
|
|
29373
|
+
from = [],
|
|
29374
|
+
originalValue = _value,
|
|
29375
|
+
recursive = this.spec.recursive
|
|
29376
|
+
} = options;
|
|
29377
|
+
options.from = [{
|
|
29378
|
+
schema: this,
|
|
29379
|
+
value: originalValue
|
|
29380
|
+
}, ...from];
|
|
29381
|
+
// this flag is needed for handling `strict` correctly in the context of
|
|
29382
|
+
// validation vs just casting. e.g strict() on a field is only used when validating
|
|
29383
|
+
options.__validating = true;
|
|
29384
|
+
options.originalValue = originalValue;
|
|
29385
|
+
super._validate(_value, options, panic, (objectErrors, value) => {
|
|
29386
|
+
if (!recursive || !isObject(value)) {
|
|
29387
|
+
next(objectErrors, value);
|
|
29388
|
+
return;
|
|
29389
|
+
}
|
|
29390
|
+
originalValue = originalValue || value;
|
|
29391
|
+
let tests = [];
|
|
29392
|
+
for (let key of this._nodes) {
|
|
29393
|
+
let field = this.fields[key];
|
|
29394
|
+
if (!field || Reference.isRef(field)) {
|
|
29395
|
+
continue;
|
|
29396
|
+
}
|
|
29397
|
+
tests.push(field.asNestedTest({
|
|
29398
|
+
options,
|
|
29399
|
+
key,
|
|
29400
|
+
parent: value,
|
|
29401
|
+
parentPath: options.path,
|
|
29402
|
+
originalParent: originalValue
|
|
29403
|
+
}));
|
|
29404
|
+
}
|
|
29405
|
+
this.runTests({
|
|
29406
|
+
tests,
|
|
29407
|
+
value,
|
|
29408
|
+
originalValue,
|
|
29409
|
+
options
|
|
29410
|
+
}, panic, fieldErrors => {
|
|
29411
|
+
next(fieldErrors.sort(this._sortErrors).concat(objectErrors), value);
|
|
29412
|
+
});
|
|
29413
|
+
});
|
|
29414
|
+
}
|
|
29415
|
+
clone(spec) {
|
|
29416
|
+
const next = super.clone(spec);
|
|
29417
|
+
next.fields = Object.assign({}, this.fields);
|
|
29418
|
+
next._nodes = this._nodes;
|
|
29419
|
+
next._excludedEdges = this._excludedEdges;
|
|
29420
|
+
next._sortErrors = this._sortErrors;
|
|
29421
|
+
return next;
|
|
29422
|
+
}
|
|
29423
|
+
concat(schema) {
|
|
29424
|
+
let next = super.concat(schema);
|
|
29425
|
+
let nextFields = next.fields;
|
|
29426
|
+
for (let [field, schemaOrRef] of Object.entries(this.fields)) {
|
|
29427
|
+
const target = nextFields[field];
|
|
29428
|
+
nextFields[field] = target === undefined ? schemaOrRef : target;
|
|
29429
|
+
}
|
|
29430
|
+
return next.withMutation(s =>
|
|
29431
|
+
// XXX: excludes here is wrong
|
|
29432
|
+
s.setFields(nextFields, [...this._excludedEdges, ...schema._excludedEdges]));
|
|
29433
|
+
}
|
|
29434
|
+
_getDefault(options) {
|
|
29435
|
+
if ('default' in this.spec) {
|
|
29436
|
+
return super._getDefault(options);
|
|
29437
|
+
}
|
|
29438
|
+
|
|
29439
|
+
// if there is no default set invent one
|
|
29440
|
+
if (!this._nodes.length) {
|
|
29441
|
+
return undefined;
|
|
29442
|
+
}
|
|
29443
|
+
let dft = {};
|
|
29444
|
+
this._nodes.forEach(key => {
|
|
29445
|
+
var _innerOptions;
|
|
29446
|
+
const field = this.fields[key];
|
|
29447
|
+
let innerOptions = options;
|
|
29448
|
+
if ((_innerOptions = innerOptions) != null && _innerOptions.value) {
|
|
29449
|
+
innerOptions = Object.assign({}, innerOptions, {
|
|
29450
|
+
parent: innerOptions.value,
|
|
29451
|
+
value: innerOptions.value[key]
|
|
29452
|
+
});
|
|
29453
|
+
}
|
|
29454
|
+
dft[key] = field && 'getDefault' in field ? field.getDefault(innerOptions) : undefined;
|
|
29455
|
+
});
|
|
29456
|
+
return dft;
|
|
29457
|
+
}
|
|
29458
|
+
setFields(shape, excludedEdges) {
|
|
29459
|
+
let next = this.clone();
|
|
29460
|
+
next.fields = shape;
|
|
29461
|
+
next._nodes = sortFields(shape, excludedEdges);
|
|
29462
|
+
next._sortErrors = sortByKeyOrder(Object.keys(shape));
|
|
29463
|
+
// XXX: this carries over edges which may not be what you want
|
|
29464
|
+
if (excludedEdges) next._excludedEdges = excludedEdges;
|
|
29465
|
+
return next;
|
|
29466
|
+
}
|
|
29467
|
+
shape(additions, excludes = []) {
|
|
29468
|
+
return this.clone().withMutation(next => {
|
|
29469
|
+
let edges = next._excludedEdges;
|
|
29470
|
+
if (excludes.length) {
|
|
29471
|
+
if (!Array.isArray(excludes[0])) excludes = [excludes];
|
|
29472
|
+
edges = [...next._excludedEdges, ...excludes];
|
|
29473
|
+
}
|
|
29474
|
+
|
|
29475
|
+
// XXX: excludes here is wrong
|
|
29476
|
+
return next.setFields(Object.assign(next.fields, additions), edges);
|
|
29477
|
+
});
|
|
29478
|
+
}
|
|
29479
|
+
partial() {
|
|
29480
|
+
const partial = {};
|
|
29481
|
+
for (const [key, schema] of Object.entries(this.fields)) {
|
|
29482
|
+
partial[key] = 'optional' in schema && schema.optional instanceof Function ? schema.optional() : schema;
|
|
29483
|
+
}
|
|
29484
|
+
return this.setFields(partial);
|
|
29485
|
+
}
|
|
29486
|
+
deepPartial() {
|
|
29487
|
+
const next = deepPartial(this);
|
|
29488
|
+
return next;
|
|
29489
|
+
}
|
|
29490
|
+
pick(keys) {
|
|
29491
|
+
const picked = {};
|
|
29492
|
+
for (const key of keys) {
|
|
29493
|
+
if (this.fields[key]) picked[key] = this.fields[key];
|
|
29494
|
+
}
|
|
29495
|
+
return this.setFields(picked, this._excludedEdges.filter(([a, b]) => keys.includes(a) && keys.includes(b)));
|
|
29496
|
+
}
|
|
29497
|
+
omit(keys) {
|
|
29498
|
+
const remaining = [];
|
|
29499
|
+
for (const key of Object.keys(this.fields)) {
|
|
29500
|
+
if (keys.includes(key)) continue;
|
|
29501
|
+
remaining.push(key);
|
|
29502
|
+
}
|
|
29503
|
+
return this.pick(remaining);
|
|
29504
|
+
}
|
|
29505
|
+
from(from, to, alias) {
|
|
29506
|
+
let fromGetter = propertyExprExports.getter(from, true);
|
|
29507
|
+
return this.transform(obj => {
|
|
29508
|
+
if (!obj) return obj;
|
|
29509
|
+
let newObj = obj;
|
|
29510
|
+
if (deepHas(obj, from)) {
|
|
29511
|
+
newObj = Object.assign({}, obj);
|
|
29512
|
+
if (!alias) delete newObj[from];
|
|
29513
|
+
newObj[to] = fromGetter(obj);
|
|
29514
|
+
}
|
|
29515
|
+
return newObj;
|
|
29516
|
+
});
|
|
29517
|
+
}
|
|
29518
|
+
|
|
29519
|
+
/** Parse an input JSON string to an object */
|
|
29520
|
+
json() {
|
|
29521
|
+
return this.transform(parseJson);
|
|
29522
|
+
}
|
|
29523
|
+
noUnknown(noAllow = true, message = object.noUnknown) {
|
|
29524
|
+
if (typeof noAllow !== 'boolean') {
|
|
29525
|
+
message = noAllow;
|
|
29526
|
+
noAllow = true;
|
|
29527
|
+
}
|
|
29528
|
+
let next = this.test({
|
|
29529
|
+
name: 'noUnknown',
|
|
29530
|
+
exclusive: true,
|
|
29531
|
+
message: message,
|
|
29532
|
+
test(value) {
|
|
29533
|
+
if (value == null) return true;
|
|
29534
|
+
const unknownKeys = unknown(this.schema, value);
|
|
29535
|
+
return !noAllow || unknownKeys.length === 0 || this.createError({
|
|
29536
|
+
params: {
|
|
29537
|
+
unknown: unknownKeys.join(', ')
|
|
29538
|
+
}
|
|
29539
|
+
});
|
|
29540
|
+
}
|
|
29541
|
+
});
|
|
29542
|
+
next.spec.noUnknown = noAllow;
|
|
29543
|
+
return next;
|
|
29544
|
+
}
|
|
29545
|
+
unknown(allow = true, message = object.noUnknown) {
|
|
29546
|
+
return this.noUnknown(!allow, message);
|
|
29547
|
+
}
|
|
29548
|
+
transformKeys(fn) {
|
|
29549
|
+
return this.transform(obj => {
|
|
29550
|
+
if (!obj) return obj;
|
|
29551
|
+
const result = {};
|
|
29552
|
+
for (const key of Object.keys(obj)) result[fn(key)] = obj[key];
|
|
29553
|
+
return result;
|
|
29554
|
+
});
|
|
29555
|
+
}
|
|
29556
|
+
camelCase() {
|
|
29557
|
+
return this.transformKeys(tinyCaseExports.camelCase);
|
|
29558
|
+
}
|
|
29559
|
+
snakeCase() {
|
|
29560
|
+
return this.transformKeys(tinyCaseExports.snakeCase);
|
|
29561
|
+
}
|
|
29562
|
+
constantCase() {
|
|
29563
|
+
return this.transformKeys(key => tinyCaseExports.snakeCase(key).toUpperCase());
|
|
29564
|
+
}
|
|
29565
|
+
describe(options) {
|
|
29566
|
+
const next = (options ? this.resolve(options) : this).clone();
|
|
29567
|
+
const base = super.describe(options);
|
|
29568
|
+
base.fields = {};
|
|
29569
|
+
for (const [key, value] of Object.entries(next.fields)) {
|
|
29570
|
+
var _innerOptions2;
|
|
29571
|
+
let innerOptions = options;
|
|
29572
|
+
if ((_innerOptions2 = innerOptions) != null && _innerOptions2.value) {
|
|
29573
|
+
innerOptions = Object.assign({}, innerOptions, {
|
|
29574
|
+
parent: innerOptions.value,
|
|
29575
|
+
value: innerOptions.value[key]
|
|
29576
|
+
});
|
|
29577
|
+
}
|
|
29578
|
+
base.fields[key] = value.describe(innerOptions);
|
|
29579
|
+
}
|
|
29580
|
+
return base;
|
|
29581
|
+
}
|
|
29582
|
+
}
|
|
29583
|
+
create$3.prototype = ObjectSchema.prototype;
|
|
29584
|
+
|
|
29585
|
+
function create$2(type) {
|
|
29586
|
+
return new ArraySchema(type);
|
|
29587
|
+
}
|
|
29588
|
+
class ArraySchema extends Schema {
|
|
29589
|
+
constructor(type) {
|
|
29590
|
+
super({
|
|
29591
|
+
type: 'array',
|
|
29592
|
+
spec: {
|
|
29593
|
+
types: type
|
|
29594
|
+
},
|
|
29595
|
+
check(v) {
|
|
29596
|
+
return Array.isArray(v);
|
|
29597
|
+
}
|
|
29598
|
+
});
|
|
29599
|
+
|
|
29600
|
+
// `undefined` specifically means uninitialized, as opposed to "no subtype"
|
|
29601
|
+
this.innerType = void 0;
|
|
29602
|
+
this.innerType = type;
|
|
29603
|
+
}
|
|
29604
|
+
_cast(_value, _opts) {
|
|
29605
|
+
const value = super._cast(_value, _opts);
|
|
29606
|
+
|
|
29607
|
+
// should ignore nulls here
|
|
29608
|
+
if (!this._typeCheck(value) || !this.innerType) {
|
|
29609
|
+
return value;
|
|
29610
|
+
}
|
|
29611
|
+
let isChanged = false;
|
|
29612
|
+
const castArray = value.map((v, idx) => {
|
|
29613
|
+
const castElement = this.innerType.cast(v, Object.assign({}, _opts, {
|
|
29614
|
+
path: `${_opts.path || ''}[${idx}]`
|
|
29615
|
+
}));
|
|
29616
|
+
if (castElement !== v) {
|
|
29617
|
+
isChanged = true;
|
|
29618
|
+
}
|
|
29619
|
+
return castElement;
|
|
29620
|
+
});
|
|
29621
|
+
return isChanged ? castArray : value;
|
|
29622
|
+
}
|
|
29623
|
+
_validate(_value, options = {}, panic, next) {
|
|
29624
|
+
var _options$recursive;
|
|
29625
|
+
// let sync = options.sync;
|
|
29626
|
+
// let path = options.path;
|
|
29627
|
+
let innerType = this.innerType;
|
|
29628
|
+
// let endEarly = options.abortEarly ?? this.spec.abortEarly;
|
|
29629
|
+
let recursive = (_options$recursive = options.recursive) != null ? _options$recursive : this.spec.recursive;
|
|
29630
|
+
options.originalValue != null ? options.originalValue : _value;
|
|
29631
|
+
super._validate(_value, options, panic, (arrayErrors, value) => {
|
|
29632
|
+
var _options$originalValu2;
|
|
29633
|
+
if (!recursive || !innerType || !this._typeCheck(value)) {
|
|
29634
|
+
next(arrayErrors, value);
|
|
29635
|
+
return;
|
|
29636
|
+
}
|
|
29637
|
+
|
|
29638
|
+
// #950 Ensure that sparse array empty slots are validated
|
|
29639
|
+
let tests = new Array(value.length);
|
|
29640
|
+
for (let index = 0; index < value.length; index++) {
|
|
29641
|
+
var _options$originalValu;
|
|
29642
|
+
tests[index] = innerType.asNestedTest({
|
|
29643
|
+
options,
|
|
29644
|
+
index,
|
|
29645
|
+
parent: value,
|
|
29646
|
+
parentPath: options.path,
|
|
29647
|
+
originalParent: (_options$originalValu = options.originalValue) != null ? _options$originalValu : _value
|
|
29648
|
+
});
|
|
29649
|
+
}
|
|
29650
|
+
this.runTests({
|
|
29651
|
+
value,
|
|
29652
|
+
tests,
|
|
29653
|
+
originalValue: (_options$originalValu2 = options.originalValue) != null ? _options$originalValu2 : _value,
|
|
29654
|
+
options
|
|
29655
|
+
}, panic, innerTypeErrors => next(innerTypeErrors.concat(arrayErrors), value));
|
|
29656
|
+
});
|
|
29657
|
+
}
|
|
29658
|
+
clone(spec) {
|
|
29659
|
+
const next = super.clone(spec);
|
|
29660
|
+
// @ts-expect-error readonly
|
|
29661
|
+
next.innerType = this.innerType;
|
|
29662
|
+
return next;
|
|
29663
|
+
}
|
|
29664
|
+
|
|
29665
|
+
/** Parse an input JSON string to an object */
|
|
29666
|
+
json() {
|
|
29667
|
+
return this.transform(parseJson);
|
|
29668
|
+
}
|
|
29669
|
+
concat(schema) {
|
|
29670
|
+
let next = super.concat(schema);
|
|
29671
|
+
|
|
29672
|
+
// @ts-expect-error readonly
|
|
29673
|
+
next.innerType = this.innerType;
|
|
29674
|
+
if (schema.innerType)
|
|
29675
|
+
// @ts-expect-error readonly
|
|
29676
|
+
next.innerType = next.innerType ?
|
|
29677
|
+
// @ts-expect-error Lazy doesn't have concat and will break
|
|
29678
|
+
next.innerType.concat(schema.innerType) : schema.innerType;
|
|
29679
|
+
return next;
|
|
29680
|
+
}
|
|
29681
|
+
of(schema) {
|
|
29682
|
+
// FIXME: this should return a new instance of array without the default to be
|
|
29683
|
+
let next = this.clone();
|
|
29684
|
+
if (!isSchema(schema)) throw new TypeError('`array.of()` sub-schema must be a valid yup schema not: ' + printValue(schema));
|
|
29685
|
+
|
|
29686
|
+
// @ts-expect-error readonly
|
|
29687
|
+
next.innerType = schema;
|
|
29688
|
+
next.spec = Object.assign({}, next.spec, {
|
|
29689
|
+
types: schema
|
|
29690
|
+
});
|
|
29691
|
+
return next;
|
|
29692
|
+
}
|
|
29693
|
+
length(length, message = array.length) {
|
|
29694
|
+
return this.test({
|
|
29695
|
+
message,
|
|
29696
|
+
name: 'length',
|
|
29697
|
+
exclusive: true,
|
|
29698
|
+
params: {
|
|
29699
|
+
length
|
|
29700
|
+
},
|
|
29701
|
+
skipAbsent: true,
|
|
29702
|
+
test(value) {
|
|
29703
|
+
return value.length === this.resolve(length);
|
|
29704
|
+
}
|
|
29705
|
+
});
|
|
29706
|
+
}
|
|
29707
|
+
min(min, message) {
|
|
29708
|
+
message = message || array.min;
|
|
29709
|
+
return this.test({
|
|
29710
|
+
message,
|
|
29711
|
+
name: 'min',
|
|
29712
|
+
exclusive: true,
|
|
29713
|
+
params: {
|
|
29714
|
+
min
|
|
29715
|
+
},
|
|
29716
|
+
skipAbsent: true,
|
|
29717
|
+
// FIXME(ts): Array<typeof T>
|
|
29718
|
+
test(value) {
|
|
29719
|
+
return value.length >= this.resolve(min);
|
|
29720
|
+
}
|
|
29721
|
+
});
|
|
29722
|
+
}
|
|
29723
|
+
max(max, message) {
|
|
29724
|
+
message = message || array.max;
|
|
29725
|
+
return this.test({
|
|
29726
|
+
message,
|
|
29727
|
+
name: 'max',
|
|
29728
|
+
exclusive: true,
|
|
29729
|
+
params: {
|
|
29730
|
+
max
|
|
29731
|
+
},
|
|
29732
|
+
skipAbsent: true,
|
|
29733
|
+
test(value) {
|
|
29734
|
+
return value.length <= this.resolve(max);
|
|
29735
|
+
}
|
|
29736
|
+
});
|
|
29737
|
+
}
|
|
29738
|
+
ensure() {
|
|
29739
|
+
return this.default(() => []).transform((val, original) => {
|
|
29740
|
+
// We don't want to return `null` for nullable schema
|
|
29741
|
+
if (this._typeCheck(val)) return val;
|
|
29742
|
+
return original == null ? [] : [].concat(original);
|
|
29743
|
+
});
|
|
29744
|
+
}
|
|
29745
|
+
compact(rejector) {
|
|
29746
|
+
let reject = !rejector ? v => !!v : (v, i, a) => !rejector(v, i, a);
|
|
29747
|
+
return this.transform(values => values != null ? values.filter(reject) : values);
|
|
29748
|
+
}
|
|
29749
|
+
describe(options) {
|
|
29750
|
+
const next = (options ? this.resolve(options) : this).clone();
|
|
29751
|
+
const base = super.describe(options);
|
|
29752
|
+
if (next.innerType) {
|
|
29753
|
+
var _innerOptions;
|
|
29754
|
+
let innerOptions = options;
|
|
29755
|
+
if ((_innerOptions = innerOptions) != null && _innerOptions.value) {
|
|
29756
|
+
innerOptions = Object.assign({}, innerOptions, {
|
|
29757
|
+
parent: innerOptions.value,
|
|
29758
|
+
value: innerOptions.value[0]
|
|
29759
|
+
});
|
|
29760
|
+
}
|
|
29761
|
+
base.innerType = next.innerType.describe(innerOptions);
|
|
29762
|
+
}
|
|
29763
|
+
return base;
|
|
29764
|
+
}
|
|
29765
|
+
}
|
|
29766
|
+
create$2.prototype = ArraySchema.prototype;
|
|
29767
|
+
|
|
29768
|
+
// @ts-ignore
|
|
29769
|
+
function create$1(schemas) {
|
|
29770
|
+
return new TupleSchema(schemas);
|
|
29771
|
+
}
|
|
29772
|
+
class TupleSchema extends Schema {
|
|
29773
|
+
constructor(schemas) {
|
|
29774
|
+
super({
|
|
29775
|
+
type: 'tuple',
|
|
29776
|
+
spec: {
|
|
29777
|
+
types: schemas
|
|
29778
|
+
},
|
|
29779
|
+
check(v) {
|
|
29780
|
+
const types = this.spec.types;
|
|
29781
|
+
return Array.isArray(v) && v.length === types.length;
|
|
29782
|
+
}
|
|
29783
|
+
});
|
|
29784
|
+
this.withMutation(() => {
|
|
29785
|
+
this.typeError(tuple.notType);
|
|
29786
|
+
});
|
|
29787
|
+
}
|
|
29788
|
+
_cast(inputValue, options) {
|
|
29789
|
+
const {
|
|
29790
|
+
types
|
|
29791
|
+
} = this.spec;
|
|
29792
|
+
const value = super._cast(inputValue, options);
|
|
29793
|
+
if (!this._typeCheck(value)) {
|
|
29794
|
+
return value;
|
|
29795
|
+
}
|
|
29796
|
+
let isChanged = false;
|
|
29797
|
+
const castArray = types.map((type, idx) => {
|
|
29798
|
+
const castElement = type.cast(value[idx], Object.assign({}, options, {
|
|
29799
|
+
path: `${options.path || ''}[${idx}]`
|
|
29800
|
+
}));
|
|
29801
|
+
if (castElement !== value[idx]) isChanged = true;
|
|
29802
|
+
return castElement;
|
|
29803
|
+
});
|
|
29804
|
+
return isChanged ? castArray : value;
|
|
29805
|
+
}
|
|
29806
|
+
_validate(_value, options = {}, panic, next) {
|
|
29807
|
+
let itemTypes = this.spec.types;
|
|
29808
|
+
super._validate(_value, options, panic, (tupleErrors, value) => {
|
|
29809
|
+
var _options$originalValu2;
|
|
29810
|
+
// intentionally not respecting recursive
|
|
29811
|
+
if (!this._typeCheck(value)) {
|
|
29812
|
+
next(tupleErrors, value);
|
|
29813
|
+
return;
|
|
29814
|
+
}
|
|
29815
|
+
let tests = [];
|
|
29816
|
+
for (let [index, itemSchema] of itemTypes.entries()) {
|
|
29817
|
+
var _options$originalValu;
|
|
29818
|
+
tests[index] = itemSchema.asNestedTest({
|
|
29819
|
+
options,
|
|
29820
|
+
index,
|
|
29821
|
+
parent: value,
|
|
29822
|
+
parentPath: options.path,
|
|
29823
|
+
originalParent: (_options$originalValu = options.originalValue) != null ? _options$originalValu : _value
|
|
29824
|
+
});
|
|
29825
|
+
}
|
|
29826
|
+
this.runTests({
|
|
29827
|
+
value,
|
|
29828
|
+
tests,
|
|
29829
|
+
originalValue: (_options$originalValu2 = options.originalValue) != null ? _options$originalValu2 : _value,
|
|
29830
|
+
options
|
|
29831
|
+
}, panic, innerTypeErrors => next(innerTypeErrors.concat(tupleErrors), value));
|
|
29832
|
+
});
|
|
29833
|
+
}
|
|
29834
|
+
describe(options) {
|
|
29835
|
+
const next = (options ? this.resolve(options) : this).clone();
|
|
29836
|
+
const base = super.describe(options);
|
|
29837
|
+
base.innerType = next.spec.types.map((schema, index) => {
|
|
29838
|
+
var _innerOptions;
|
|
29839
|
+
let innerOptions = options;
|
|
29840
|
+
if ((_innerOptions = innerOptions) != null && _innerOptions.value) {
|
|
29841
|
+
innerOptions = Object.assign({}, innerOptions, {
|
|
29842
|
+
parent: innerOptions.value,
|
|
29843
|
+
value: innerOptions.value[index]
|
|
29844
|
+
});
|
|
29845
|
+
}
|
|
29846
|
+
return schema.describe(innerOptions);
|
|
29847
|
+
});
|
|
29848
|
+
return base;
|
|
29849
|
+
}
|
|
29850
|
+
}
|
|
29851
|
+
create$1.prototype = TupleSchema.prototype;
|
|
29852
|
+
|
|
29853
|
+
function create(builder) {
|
|
29854
|
+
return new Lazy(builder);
|
|
29855
|
+
}
|
|
29856
|
+
class Lazy {
|
|
29857
|
+
constructor(builder) {
|
|
29858
|
+
this.type = 'lazy';
|
|
29859
|
+
this.__isYupSchema__ = true;
|
|
29860
|
+
this.spec = void 0;
|
|
29861
|
+
this._resolve = (value, options = {}) => {
|
|
29862
|
+
let schema = this.builder(value, options);
|
|
29863
|
+
if (!isSchema(schema)) throw new TypeError('lazy() functions must return a valid schema');
|
|
29864
|
+
if (this.spec.optional) schema = schema.optional();
|
|
29865
|
+
return schema.resolve(options);
|
|
29866
|
+
};
|
|
29867
|
+
this.builder = builder;
|
|
29868
|
+
this.spec = {
|
|
29869
|
+
meta: undefined,
|
|
29870
|
+
optional: false
|
|
29871
|
+
};
|
|
29872
|
+
}
|
|
29873
|
+
clone(spec) {
|
|
29874
|
+
const next = new Lazy(this.builder);
|
|
29875
|
+
next.spec = Object.assign({}, this.spec, spec);
|
|
29876
|
+
return next;
|
|
29877
|
+
}
|
|
29878
|
+
optionality(optional) {
|
|
29879
|
+
const next = this.clone({
|
|
29880
|
+
optional
|
|
29881
|
+
});
|
|
29882
|
+
return next;
|
|
29883
|
+
}
|
|
29884
|
+
optional() {
|
|
29885
|
+
return this.optionality(true);
|
|
29886
|
+
}
|
|
29887
|
+
resolve(options) {
|
|
29888
|
+
return this._resolve(options.value, options);
|
|
29889
|
+
}
|
|
29890
|
+
cast(value, options) {
|
|
29891
|
+
return this._resolve(value, options).cast(value, options);
|
|
29892
|
+
}
|
|
29893
|
+
asNestedTest(config) {
|
|
29894
|
+
let {
|
|
29895
|
+
key,
|
|
29896
|
+
index,
|
|
29897
|
+
parent,
|
|
29898
|
+
options
|
|
29899
|
+
} = config;
|
|
29900
|
+
let value = parent[index != null ? index : key];
|
|
29901
|
+
return this._resolve(value, Object.assign({}, options, {
|
|
29902
|
+
value,
|
|
29903
|
+
parent
|
|
29904
|
+
})).asNestedTest(config);
|
|
29905
|
+
}
|
|
29906
|
+
validate(value, options) {
|
|
29907
|
+
return this._resolve(value, options).validate(value, options);
|
|
29908
|
+
}
|
|
29909
|
+
validateSync(value, options) {
|
|
29910
|
+
return this._resolve(value, options).validateSync(value, options);
|
|
29911
|
+
}
|
|
29912
|
+
validateAt(path, value, options) {
|
|
29913
|
+
return this._resolve(value, options).validateAt(path, value, options);
|
|
29914
|
+
}
|
|
29915
|
+
validateSyncAt(path, value, options) {
|
|
29916
|
+
return this._resolve(value, options).validateSyncAt(path, value, options);
|
|
29917
|
+
}
|
|
29918
|
+
isValid(value, options) {
|
|
29919
|
+
return this._resolve(value, options).isValid(value, options);
|
|
29920
|
+
}
|
|
29921
|
+
isValidSync(value, options) {
|
|
29922
|
+
return this._resolve(value, options).isValidSync(value, options);
|
|
29923
|
+
}
|
|
29924
|
+
describe(options) {
|
|
29925
|
+
return options ? this.resolve(options).describe(options) : {
|
|
29926
|
+
type: 'lazy',
|
|
29927
|
+
meta: this.spec.meta,
|
|
29928
|
+
label: undefined
|
|
29929
|
+
};
|
|
29930
|
+
}
|
|
29931
|
+
meta(...args) {
|
|
29932
|
+
if (args.length === 0) return this.spec.meta;
|
|
29933
|
+
let next = this.clone();
|
|
29934
|
+
next.spec.meta = Object.assign(next.spec.meta || {}, args[0]);
|
|
29935
|
+
return next;
|
|
29936
|
+
}
|
|
29937
|
+
}
|
|
29938
|
+
|
|
29939
|
+
function setLocale(custom) {
|
|
29940
|
+
Object.keys(custom).forEach(type => {
|
|
29941
|
+
// @ts-ignore
|
|
29942
|
+
Object.keys(custom[type]).forEach(method => {
|
|
29943
|
+
// @ts-ignore
|
|
29944
|
+
locale[type][method] = custom[type][method];
|
|
29945
|
+
});
|
|
29946
|
+
});
|
|
29947
|
+
}
|
|
29948
|
+
|
|
29949
|
+
function addMethod(schemaType, name, fn) {
|
|
29950
|
+
if (!schemaType || !isSchema(schemaType.prototype)) throw new TypeError('You must provide a yup schema constructor function');
|
|
29951
|
+
if (typeof name !== 'string') throw new TypeError('A Method name must be provided');
|
|
29952
|
+
if (typeof fn !== 'function') throw new TypeError('Method function must be provided');
|
|
29953
|
+
schemaType.prototype[name] = fn;
|
|
29954
|
+
}
|
|
29955
|
+
|
|
29956
|
+
var index_esm = /*#__PURE__*/Object.freeze({
|
|
29957
|
+
__proto__: null,
|
|
29958
|
+
ArraySchema: ArraySchema,
|
|
29959
|
+
BooleanSchema: BooleanSchema,
|
|
29960
|
+
DateSchema: DateSchema,
|
|
29961
|
+
MixedSchema: MixedSchema,
|
|
29962
|
+
NumberSchema: NumberSchema,
|
|
29963
|
+
ObjectSchema: ObjectSchema,
|
|
29964
|
+
Schema: Schema,
|
|
29965
|
+
StringSchema: StringSchema,
|
|
29966
|
+
TupleSchema: TupleSchema,
|
|
29967
|
+
ValidationError: ValidationError,
|
|
29968
|
+
addMethod: addMethod,
|
|
29969
|
+
array: create$2,
|
|
29970
|
+
bool: create$7,
|
|
29971
|
+
boolean: create$7,
|
|
29972
|
+
date: create$4,
|
|
29973
|
+
defaultLocale: locale,
|
|
29974
|
+
getIn: getIn,
|
|
29975
|
+
isSchema: isSchema,
|
|
29976
|
+
lazy: create,
|
|
29977
|
+
mixed: create$8,
|
|
29978
|
+
number: create$5,
|
|
29979
|
+
object: create$3,
|
|
29980
|
+
printValue: printValue,
|
|
29981
|
+
reach: reach,
|
|
29982
|
+
ref: create$9,
|
|
29983
|
+
setLocale: setLocale,
|
|
29984
|
+
string: create$6,
|
|
29985
|
+
tuple: create$1
|
|
29986
|
+
});
|
|
29987
|
+
|
|
29988
|
+
export { Controller, Form, FormProvider, FormProvider$1 as FormProviderController, RHFCheckbox, RHFMultiCheckbox, RHFRadioGroup, RHFSelect, RHFSlider, RHFSwitch, RHFTextField, Simple, index_esm as Yup, appendErrors, get, set, useController, useFieldArray, useForm, useFormContext, useFormState, useWatch, o as yupResolver };
|
|
27232
29989
|
//# sourceMappingURL=index.es.js.map
|