@me1a/ui 1.2.1 → 1.2.2

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