1;!function(){try { var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof global?global:"undefined"!=typeof window?window:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&((e._debugIds|| (e._debugIds={}))[n]="163bbc01-2a51-0193-5676-54368d21691e")}catch(e){}}(); 2(globalThis["TURBOPACK"] || (globalThis["TURBOPACK"] = [])).push([typeof document === "object" ? document.currentScript : undefined, 3437472, ((__turbopack_context__, module, exports) => { 4"use strict"; 5 6/** 7 * Based on Kendo UI Core expression code <https://github.com/telerik/kendo-ui-core#license-information> 8 */ function Cache(maxSize) { 9 this._maxSize = maxSize; 10 this.clear(); 11} 12Cache.prototype.clear = function() { 13 this._size = 0; 14 this._values = Object.create(null); 15}; 16Cache.prototype.get = function(key) { 17 return this._values[key]; 18}; 19Cache.prototype.set = function(key, value) { 20 this._size >= this._maxSize && this.clear(); 21 if (!(key in this._values)) this._size++; 22 return this._values[key] = value; 23}; 24var SPLIT_REGEX = /[^.^\]^[]+|(?=\[\]|\.\.)/g, DIGIT_REGEX = /^\d+$/, LEAD_DIGIT_REGEX = /^\d/, SPEC_CHAR_REGEX = /[~`!#$%\^&*+=\-\[\]\\';,/{}|\\":<>\?]/g, CLEAN_QUOTES_REGEX = /^\s*(['"]?)(.*?)(\1)\s*$/, MAX_CACHE_SIZE = 512; 25var pathCache = new Cache(MAX_CACHE_SIZE), setCache = new Cache(MAX_CACHE_SIZE), getCache = new Cache(MAX_CACHE_SIZE); 26var config; 27module.exports = { 28 Cache: Cache, 29 split: split, 30 normalizePath: normalizePath, 31 setter: function(path) { 32 var parts = normalizePath(path); 33 return setCache.get(path) || setCache.set(path, function setter(obj, value) { 34 var index = 0; 35 var len = parts.length; 36 var data = obj; 37 while(index < len - 1){ 38 var part = parts[index]; 39 if (part === '__proto__' || part === 'constructor' || part === 'prototype') { 40 return obj; 41 } 42 data = data[parts[index++]]; 43 } 44 data[parts[index]] = value; 45 }); 46 }, 47 getter: function(path, safe) { 48 var parts = normalizePath(path); 49 return getCache.get(path) || getCache.set(path, function getter(data) { 50 var index = 0, len = parts.length; 51 while(index < len){ 52 if (data != null || !safe) data = data[parts[index++]]; 53 else return; 54 } 55 return data; 56 }); 57 }, 58 join: function(segments) { 59 return segments.reduce(function(path, part) { 60 return path + (isQuoted(part) || DIGIT_REGEX.test(part) ? '[' + part + ']' : (path ? '.' : '') + part); 61 }, ''); 62 }, 63 forEach: function(path, cb, thisArg) { 64 forEach(Array.isArray(path) ? path : split(path), cb, thisArg); 65 } 66}; 67function normalizePath(path) { 68 return pathCache.get(path) || pathCache.set(path, split(path).map(function(part) { 69 return part.replace(CLEAN_QUOTES_REGEX, '$2'); 70 })); 71} 72function split(path) { 73 return path.match(SPLIT_REGEX) || [ 74 '' 75 ]; 76} 77function forEach(parts, iter, thisArg) { 78 var len = parts.length, part, idx, isArray, isBracket; 79 for(idx = 0; idx < len; idx++){ 80 part = parts[idx]; 81 if (part) { 82 if (shouldBeQuoted(part)) { 83 part = '"' + part + '"'; 84 } 85 isBracket = isQuoted(part); 86 isArray = !isBracket && /^\d+$/.test(part); 87 iter.call(thisArg, part, isBracket, isArray, idx, parts); 88 } 89 } 90} 91function isQuoted(str) { 92 return typeof str === 'string' && str && [ 93 "'", 94 '"' 95 ].indexOf(str.charAt(0)) !== -1; 96} 97function hasLeadingNumber(part) { 98 return part.match(LEAD_DIGIT_REGEX) && !part.match(DIGIT_REGEX); 99} 100function hasSpecialChars(part) { 101 return SPEC_CHAR_REGEX.test(part); 102} 103function shouldBeQuoted(part) { 104 return !isQuoted(part) && (hasLeadingNumber(part) || hasSpecialChars(part)); 105} 106}), 107303873, ((__turbopack_context__, module, exports) => { 108 109const 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; 110const words = (str)=>str.match(reWords) || []; 111const upperFirst = (str)=>str[0].toUpperCase() + str.slice(1); 112const join = (str, d)=>words(str).join(d).toLowerCase(); 113const camelCase = (str)=>words(str).reduce((acc, next)=>"".concat(acc).concat(!acc ? next.toLowerCase() : next[0].toUpperCase() + next.slice(1).toLowerCase()), ''); 114const pascalCase = (str)=>upperFirst(camelCase(str)); 115const snakeCase = (str)=>join(str, '_'); 116const kebabCase = (str)=>join(str, '-'); 117const sentenceCase = (str)=>upperFirst(join(str, ' ')); 118const titleCase = (str)=>words(str).map(upperFirst).join(' '); 119module.exports = { 120 words, 121 upperFirst, 122 camelCase, 123 pascalCase, 124 snakeCase,
125 kebabCase, 126 sentenceCase, 127 titleCase 128}; 129}), 130301439, ((__turbopack_context__, module, exports) => { 131 132/** 133 * Topological sorting function 134 * 135 * @param {Array} edges 136 * @returns {Array} 137 */ module.exports = function(edges) { 138 return toposort(uniqueNodes(edges), edges); 139}; 140module.exports.array = toposort; 141function toposort(nodes, edges) { 142 var cursor = nodes.length, sorted = new Array(cursor), visited = {}, i = cursor, outgoingEdges = makeOutgoingEdges(edges), nodesHash = makeNodesHash(nodes); 143 // check for unknown nodes 144 edges.forEach(function(edge) { 145 if (!nodesHash.has(edge[0]) || !nodesHash.has(edge[1])) { 146 throw new Error('Unknown node. There is an unknown node in the supplied edges.'); 147 } 148 }); 149 while(i--){ 150 if (!visited[i]) visit(nodes[i], i, new Set()); 151 } 152 return sorted; 153 //TURBOPACK unreachable 154 ; 155 function visit(node, i, predecessors) { 156 if (predecessors.has(node)) { 157 var nodeRep; 158 try { 159 nodeRep = ", node was:" + JSON.stringify(node); 160 } catch (e) { 161 nodeRep = ""; 162 } 163 throw new Error('Cyclic dependency' + nodeRep); 164 } 165 if (!nodesHash.has(node)) { 166 throw new Error('Found unknown node. Make sure to provided all involved nodes. Unknown node: ' + JSON.stringify(node)); 167 } 168 if (visited[i]) return; 169 visited[i] = true; 170 var outgoing = outgoingEdges.get(node) || new Set(); 171 outgoing = Array.from(outgoing); 172 if (i = outgoing.length) { 173 predecessors.add(node); 174 do { 175 var child = outgoing[--i]; 176 visit(child, nodesHash.get(child), predecessors); 177 }while (i) 178 predecessors.delete(node); 179 } 180 sorted[--cursor] = node; 181 } 182} 183function uniqueNodes(arr) { 184 var res = new Set(); 185 for(var i = 0, len = arr.length; i < len; i++){ 186 var edge = arr[i]; 187 res.add(edge[0]); 188 res.add(edge[1]); 189 } 190 return Array.from(res); 191} 192function makeOutgoingEdges(arr) { 193 var edges = new Map(); 194 for(var i = 0, len = arr.length; i < len; i++){ 195 var edge = arr[i]; 196 if (!edges.has(edge[0])) edges.set(edge[0], new Set()); 197 if (!edges.has(edge[1])) edges.set(edge[1], new Set()); 198 edges.get(edge[0]).add(edge[1]); 199 } 200 return edges; 201} 202function makeNodesHash(arr) { 203 var res = new Map(); 204 for(var i = 0, len = arr.length; i < len; i++){ 205 res.set(arr[i], i); 206 } 207 return res; 208} 209}), 210499683, ((__turbopack_context__) => { 211"use strict"; 212 213var __TURBOPACK__imported__module__437472__ = __turbopack_context__.i(437472); 214var __TURBOPACK__imported__module__303873__ = __turbopack_context__.i(303873); 215var __TURBOPACK__imported__module__301439__ = __turbopack_context__.i(301439); 216; 217; 218; 219const toString = Object.prototype.toString; 220const errorToString = Error.prototype.toString; 221const regExpToString = RegExp.prototype.toString; 222const symbolToString = typeof Symbol !== 'undefined' ? Symbol.prototype.toString : ()=>''; 223const SYMBOL_REGEXP = /^Symbol\((.*)\)(.*)$/; 224function printNumber(val) { 225 if (val != +val) return 'NaN'; 226 const isNegativeZero = val === 0 && 1 / val < 0; 227 return isNegativeZero ? '-0' : '' + val; 228} 229function printSimpleValue(val) { 230 let quoteStrings = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false; 231 if (val == null || val === true || val === false) return '' + val; 232 const typeOf = typeof val; 233 if (typeOf === 'number') return printNumber(val); 234 if (typeOf === 'string') return quoteStrings ? '"'.concat(val, '"') : val; 235 if (typeOf === 'function') return '[Function ' + (val.name || 'anonymous') + ']'; 236 if (typeOf === 'symbol') return symbolToString.call(val).replace(SYMBOL_REGEXP, 'Symbol($1)'); 237 const tag = toString.call(val).slice(8, -1); 238 if (tag === 'Date') return isNaN(val.getTime()) ? '' + val : val.toISOString(val); 239 if (tag === 'Error' || val instanceof Error) return '[' + errorToString.call(val) + ']'; 240 if (tag === 'RegExp') return regExpToString.call(val); 241 return null; 242} 243function printValue(value, quoteStrings) { 244 let result = printSimpleValue(value, quoteStrings); 245 if (result !== null) return result; 246 return JSON.stringify(value, function(key, value) { 247 let result = printSimpleValue(this[key], quoteStrings); 248 if (result !== null) return result; 249 return value; 250 }, 2); 251} 252function toArray(value) { 253 return value == null ? [] : [].concat(value); 254} 255let _Symbol$toStringTag, _Symbol$hasInstance, _Symbol$toStringTag2; 256let strReg = /\$\{\s*(\w+)\s*\}/g;
257_Symbol$toStringTag = Symbol.toStringTag; 258class ValidationErrorNoStack { 259 constructor(errorOrErrors, value, field, type){ 260 this.name = void 0; 261 this.message = void 0; 262 this.value = void 0; 263 this.path = void 0; 264 this.type = void 0; 265 this.params = void 0; 266 this.errors = void 0; 267 this.inner = void 0; 268 this[_Symbol$toStringTag] = 'Error'; 269 this.name = 'ValidationError'; 270 this.value = value; 271 this.path = field; 272 this.type = type; 273 this.errors = []; 274 this.inner = []; 275 toArray(errorOrErrors).forEach((err)=>{ 276 if (ValidationError.isError(err)) { 277 this.errors.push(...err.errors); 278 const innerErrors = err.inner.length ? err.inner : [ 279 err 280 ]; 281 this.inner.push(...innerErrors); 282 } else { 283 this.errors.push(err); 284 } 285 }); 286 this.message = this.errors.length > 1 ? "".concat(this.errors.length, " errors occurred") : this.errors[0]; 287 } 288} 289_Symbol$hasInstance = Symbol.hasInstance; 290_Symbol$toStringTag2 = Symbol.toStringTag; 291class ValidationError extends Error { 292 static formatError(message, params) { 293 // Attempt to make the path more friendly for error message interpolation. 294 const path = params.label || params.path || 'this'; 295 // Store the original path under `originalPath` so it isn't lost to custom 296 // message functions; e.g., ones provided in `setLocale()` calls. 297 params = Object.assign({}, params, { 298 path, 299 originalPath: params.path 300 }); 301 if (typeof message === 'string') return message.replace(strReg, (_, key)=>printValue(params[key])); 302 if (typeof message === 'function') return message(params); 303 return message; 304 } 305 static isError(err) { 306 return err && err.name === 'ValidationError'; 307 } 308 static [_Symbol$hasInstance](inst) { 309 return ValidationErrorNoStack[Symbol.hasInstance](inst) || super[Symbol.hasInstance](inst); 310 } 311 constructor(errorOrErrors, value, field, type, disableStack){ 312 const errorNoStack = new ValidationErrorNoStack(errorOrErrors, value, field, type); 313 if (disableStack) { 314 return errorNoStack; 315 } 316 super(); 317 this.value = void 0; 318 this.path = void 0; 319 this.type = void 0; 320 this.params = void 0; 321 this.errors = []; 322 this.inner = []; 323 this[_Symbol$toStringTag2] = 'Error'; 324 this.name = errorNoStack.name; 325 this.message = errorNoStack.message; 326 this.type = errorNoStack.type; 327 this.value = errorNoStack.value; 328 this.path = errorNoStack.path; 329 this.errors = errorNoStack.errors; 330 this.inner = errorNoStack.inner; 331 if (Error.captureStackTrace) { 332 Error.captureStackTrace(this, ValidationError); 333 } 334 } 335} 336let mixed = { 337 default: '${path} is invalid', 338 required: '${path} is a required field', 339 defined: '${path} must be defined', 340 notNull: '${path} cannot be null', 341 oneOf: '${path} must be one of the following values: ${values}', 342 notOneOf: '${path} must not be one of the following values: ${values}', 343 notType: (param)=>{ 344 let { path, type, value, originalValue } = param; 345 const castMsg = originalValue != null && originalValue !== value ? " (cast from the value `".concat(printValue(originalValue, true), "`).") : '.'; 346 return type !== 'mixed' ? "".concat(path, " must be a `").concat(type, "` type, ") + "but the final value was: `".concat(printValue(value, true), "`") + castMsg : "".concat(path, " must match the configured type. ") + "The validated value was: `".concat(printValue(value, true), "`") + castMsg; 347 } 348}; 349let string = { 350 length: '${path} must be exactly ${length} characters', 351 min: '${path} must be at least ${min} characters', 352 max: '${path} must be at most ${max} characters', 353 matches: '${path} must match the following: "${regex}"', 354 email: '${path} must be a valid email', 355 url: '${path} must be a valid URL', 356 uuid: '${path} must be a valid UUID', 357 datetime: '${path} must be a valid ISO date-time', 358 datetime_precision: '${path} must be a valid ISO date-time with a sub-second precision of exactly ${precision} digits', 359 datetime_offset: '${path} must be a valid ISO date-time with UTC "Z" timezone', 360 trim: '${path} must be a trimmed string', 361 lowercase: '${path} must be a lowercase string', 362 uppercase: '${path} must be a upper case string' 363}; 364let number = { 365 min: '${path} must be greater than or equal to ${min}', 366 max: '${path} must be less than or equal to ${max}', 367 lessThan: '${path} must be less than ${less}', 368 moreThan: '${path} must be greater than ${more}', 369 positive: '${path} must be a positive number', 370 negative: '${path} must be a negative number', 371 integer: '${path} must be an integer' 372}; 373let date = { 374 min: '${path} field must be later than ${min}', 375 max: '${path} field must be at earlier than ${max}' 376}; 377let boolean = { 378 isValue: '${path} field must be ${value}' 379}; 380let object = { 381 noUnknown: '${path} field has unspecified keys: ${unknown}', 382 exact: '${path}
382 object contains unknown properties: ${properties}' 383}; 384let array = { 385 min: '${path} field must have at least ${min} items', 386 max: '${path} field must have less than or equal to ${max} items', 387 length: '${path} must have ${length} items' 388}; 389let tuple = { 390 notType: (params)=>{ 391 const { path, value, spec } = params; 392 const typeLen = spec.types.length; 393 if (Array.isArray(value)) { 394 if (value.length < typeLen) return "".concat(path, " tuple value has too few items, expected a length of ").concat(typeLen, " but got ").concat(value.length, " for value: `").concat(printValue(value, true), "`"); 395 if (value.length > typeLen) return "".concat(path, " tuple value has too many items, expected a length of ").concat(typeLen, " but got ").concat(value.length, " for value: `").concat(printValue(value, true), "`"); 396 } 397 return ValidationError.formatError(mixed.notType, params); 398 } 399}; 400var locale = Object.assign(Object.create(null), { 401 mixed, 402 string, 403 number, 404 date, 405 object, 406 array, 407 boolean, 408 tuple 409}); 410const isSchema = (obj)=>obj && obj.__isYupSchema__; 411class Condition { 412 static fromOptions(refs, config) { 413 if (!config.then && !config.otherwise) throw new TypeError('either `then:` or `otherwise:` is required for `when()` conditions'); 414 let { is, then, otherwise } = config; 415 let check = typeof is === 'function' ? is : function() { 416 for(var _len = arguments.length, values = new Array(_len), _key = 0; _key < _len; _key++){ 417 values[_key] = arguments[_key]; 418 } 419 return values.every((value)=>value === is); 420 }; 421 return new Condition(refs, (values, schema)=>{ 422 var _branch; 423 let branch = check(...values) ? then : otherwise; 424 return (_branch = branch == null ? void 0 : branch(schema)) != null ? _branch : schema; 425 }); 426 } 427 resolve(base, options) { 428 let values = this.refs.map((ref)=>// TODO: ? operator here? 429 ref.getValue(options == null ? void 0 : options.value, options == null ? void 0 : options.parent, options == null ? void 0 : options.context)); 430 let schema = this.fn(values, base, options); 431 if (schema === undefined || // @ts-ignore this can be base 432 schema === base) { 433 return base; 434 } 435 if (!isSchema(schema)) throw new TypeError('conditions must return a schema object'); 436 return schema.resolve(options); 437 } 438 constructor(refs, builder){ 439 this.fn = void 0; 440 this.refs = refs; 441 this.refs = refs; 442 this.fn = builder; 443 } 444} 445const prefixes = { 446 context: '$', 447 value: '.' 448}; 449function create$9(key, options) { 450 return new Reference(key, options); 451} 452class Reference { 453 getValue(value, parent, context) { 454 let result = this.isContext ? context : this.isValue ? value : parent; 455 if (this.getter) result = this.getter(result || {}); 456 if (this.map) result = this.map(result); 457 return result; 458 } 459 /** 460 * 461 * @param {*} value 462 * @param {Object} options 463 * @param {Object=} options.context 464 * @param {Object=} options.parent 465 */ cast(value, options) { 466 return this.getValue(value, options == null ? void 0 : options.parent, options == null ? void 0 : options.context); 467 } 468 resolve() { 469 return this; 470 } 471 describe() { 472 return { 473 type: 'ref', 474 key: this.key 475 }; 476 } 477 toString() { 478 return "Ref(".concat(this.key, ")"); 479 } 480 static isRef(value) { 481 return value && value.__isYupRef; 482 } 483 constructor(key, options = {}){ 484 this.key = void 0; 485 this.isContext = void 0; 486 this.isValue = void 0; 487 this.isSibling = void 0; 488 this.path = void 0; 489 this.getter = void 0; 490 this.map = void 0; 491 if (typeof key !== 'string') throw new TypeError('ref must be a string, got: ' + key); 492 this.key = key.trim(); 493 if (key === '') throw new TypeError('ref must be a non-empty string'); 494 this.isContext = this.key[0] === prefixes.context; 495 this.isValue = this.key[0] === prefixes.value; 496 this.isSibling = !this.isContext && !this.isValue; 497 let prefix = this.isContext ? prefixes.context : this.isValue ? prefixes.value : ''; 498 this.path = this.key.slice(prefix.length); 499 this.getter = this.path && (0, __TURBOPACK__imported__module__437472__["getter"])(this.path, true); 500 this.map = options.map; 501 } 502} 503// @ts-ignore 504Reference.prototype.__isYupRef = true; 505const isAbsent = (value)=>value == null; 506function createValidation(config) { 507 function validate(param, panic, next) { 508 let { value, path = '', options, originalValue, schema } = param; 509 const { name, test, params, message, skipAbsent } = config; 510 let { parent, context, abortEarly = schema.spec.abortEarly, disableStackTrace = schema.spec.disableStackTrace } = options; 511 const resolveOptions = { 512 value, 513 parent, 514 context 515 }; 516 function createError() { 517 let overrides = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}; 518 const nextParams = resolveParams(Object.assign({ 519 value, 520 originalValue, 521 label: schema.spec.label, 522 path: overrides.path || path, 523 spec: schema.spec, 524 disableStackTrace: overrides.disableStackTrace || disableStackTrace 525 }, params, overrides.params), resolveOptions); 526 const error = new ValidationError(ValidationError.formatError(overrides.message || message, nextParams), value, nextParams.path, overrides.type || name, nextParams.disableStackTrace); 527 error.params = nextParams; 528 return error; 529 }
530 const invalid = abortEarly ? panic : next; 531 let ctx = { 532 path, 533 parent, 534 type: name, 535 from: options.from, 536 createError, 537 resolve (item) { 538 return resolveMaybeRef(item, resolveOptions); 539 }, 540 options, 541 originalValue, 542 schema 543 }; 544 const handleResult = (validOrError)=>{ 545 if (ValidationError.isError(validOrError)) invalid(validOrError); 546 else if (!validOrError) invalid(createError()); 547 else next(null); 548 }; 549 const handleError = (err)=>{ 550 if (ValidationError.isError(err)) invalid(err); 551 else panic(err); 552 }; 553 const shouldSkip = skipAbsent && isAbsent(value); 554 if (shouldSkip) { 555 return handleResult(true); 556 } 557 let result; 558 try { 559 var _result; 560 result = test.call(ctx, value, ctx); 561 if (typeof ((_result = result) == null ? void 0 : _result.then) === 'function') { 562 if (options.sync) { 563 throw new Error('Validation test of type: "'.concat(ctx.type, '" returned a Promise during a synchronous validate. ') + "This test will finish after the validate call has returned"); 564 } 565 return Promise.resolve(result).then(handleResult, handleError); 566 } 567 } catch (err) { 568 handleError(err); 569 return; 570 } 571 handleResult(result); 572 } 573 validate.OPTIONS = config; 574 return validate; 575} 576// Warning: mutates the input 577function resolveParams(params, options) { 578 if (!params) return params; 579 for (const key of Object.keys(params)){ 580 params[key] = resolveMaybeRef(params[key], options); 581 } 582 return params; 583} 584function resolveMaybeRef(item, options) { 585 return Reference.isRef(item) ? item.getValue(options.value, options.parent, options.context) : item; 586} 587function getIn(schema, path, value) { 588 let context = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : value; 589 let parent, lastPart, lastPartDebug; 590 // root path: '' 591 if (!path) return { 592 parent, 593 parentPath: path, 594 schema 595 }; 596 (0, __TURBOPACK__imported__module__437472__["forEach"])(path, (_part, isBracket, isArray)=>{ 597 let part = isBracket ? _part.slice(1, _part.length - 1) : _part; 598 schema = schema.resolve({ 599 context, 600 parent, 601 value 602 }); 603 let isTuple = schema.type === 'tuple'; 604 let idx = isArray ? parseInt(part, 10) : 0; 605 if (schema.innerType || isTuple) { 606 if (isTuple && !isArray) throw new Error('Yup.reach cannot implicitly index into a tuple type. the path part "'.concat(lastPartDebug, '" must contain an index to the tuple element, e.g. "').concat(lastPartDebug, '[0]"')); 607 if (value && idx >= value.length) { 608 throw new Error("Yup.reach cannot resolve an array item at index: ".concat(_part, ", in the path: ").concat(path, ". ") + "because there is no value at that index. "); 609 } 610 parent = value; 611 value = value && value[idx]; 612 schema = isTuple ? schema.spec.types[idx] : schema.innerType; 613 } 614 // sometimes the array index part of a path doesn't exist: "nested.arr.child" 615 // in these cases the current part is the next schema and should be processed 616 // in this iteration. For cases where the index signature is included this 617 // check will fail and we'll handle the `child` part on the next iteration like normal 618 if (!isArray) { 619 if (!schema.fields || !schema.fields[part]) throw new Error("The schema does not contain the path: ".concat(path, ". ") + "(failed at: ".concat(lastPartDebug, ' which is a type: "').concat(schema.type, '")')); 620 parent = value; 621 value = value && value[part]; 622 schema = schema.fields[part]; 623 } 624 lastPart = part; 625 lastPartDebug = isBracket ? '[' + _part + ']' : '.' + _part; 626 }); 627 return { 628 schema, 629 parent, 630 parentPath: lastPart 631 }; 632} 633function reach(obj, path, value, context) { 634 return getIn(obj, path, value, context).schema; 635} 636class ReferenceSet extends Set { 637 describe() { 638 const description = []; 639 for (const item of this.values()){ 640 description.push(Reference.isRef(item) ? item.describe() : item); 641 } 642 return description; 643 } 644 resolveAll(resolve) { 645 let result = []; 646 for (const item of this.values()){ 647 result.push(resolve(item)); 648 } 649 return result; 650 } 651 clone() { 652 return new ReferenceSet(this.values()); 653 } 654 merge(newItems, removeItems) { 655 const next = this.clone();
656 newItems.forEach((value)=>next.add(value)); 657 removeItems.forEach((value)=>next.delete(value)); 658 return next; 659 } 660} 661// tweaked from https://github.com/Kelin2025/nanoclone/blob/0abeb7635bda9b68ef2277093f76dbe3bf3948e1/src/index.js 662function clone(src) { 663 let seen = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : new Map(); 664 if (isSchema(src) || !src || typeof src !== 'object') return src; 665 if (seen.has(src)) return seen.get(src); 666 let copy; 667 if (src instanceof Date) { 668 // Date 669 copy = new Date(src.getTime()); 670 seen.set(src, copy); 671 } else if (src instanceof RegExp) { 672 // RegExp 673 copy = new RegExp(src); 674 seen.set(src, copy); 675 } else if (Array.isArray(src)) { 676 // Array 677 copy = new Array(src.length); 678 seen.set(src, copy); 679 for(let i = 0; i < src.length; i++)copy[i] = clone(src[i], seen); 680 } else if (src instanceof Map) { 681 // Map 682 copy = new Map(); 683 seen.set(src, copy); 684 for (const [k, v] of src.entries())copy.set(k, clone(v, seen)); 685 } else if (src instanceof Set) { 686 // Set 687 copy = new Set(); 688 seen.set(src, copy); 689 for (const v of src)copy.add(clone(v, seen)); 690 } else if (src instanceof Object) { 691 // Object 692 copy = {}; 693 seen.set(src, copy); 694 for (const [k, v] of Object.entries(src))copy[k] = clone(v, seen); 695 } else { 696 throw Error("Unable to clone ".concat(src)); 697 } 698 return copy; 699} 700/** 701 * Copied from @standard-schema/spec to avoid having a dependency on it. 702 * https://github.com/standard-schema/standard-schema/blob/main/packages/spec/src/index.ts 703 */ function createStandardPath(path) { 704 if (!(path != null && path.length)) { 705 return undefined; 706 } 707 // Array to store the final path segments 708 const segments = []; 709 // Buffer for building the current segment 710 let currentSegment = ''; 711 // Track if we're inside square brackets (array/property access) 712 let inBrackets = false; 713 // Track if we're inside quotes (for property names with special chars) 714 let inQuotes = false; 715 for(let i = 0; i < path.length; i++){ 716 const char = path[i]; 717 if (char === '[' && !inQuotes) { 718 // When entering brackets, push any accumulated segment after splitting on dots 719 if (currentSegment) { 720 segments.push(...currentSegment.split('.').filter(Boolean)); 721 currentSegment = ''; 722 } 723 inBrackets = true; 724 continue; 725 } 726 if (char === ']' && !inQuotes) { 727 if (currentSegment) { 728 // Handle numeric indices (e.g. arr[0]) 729 if (/^\d+$/.test(currentSegment)) { 730 segments.push(currentSegment); 731 } else { 732 // Handle quoted property names (e.g. obj["foo.bar"]) 733 segments.push(currentSegment.replace(/^"|"$/g, '')); 734 } 735 currentSegment = ''; 736 } 737 inBrackets = false; 738 continue; 739 } 740 if (char === '"') { 741 // Toggle quote state for handling quoted property names 742 inQuotes = !inQuotes; 743 continue; 744 } 745 if (char === '.' && !inBrackets && !inQuotes) { 746 // On dots outside brackets/quotes, push current segment 747 if (currentSegment) { 748 segments.push(currentSegment); 749 currentSegment = ''; 750 } 751 continue; 752 } 753 currentSegment += char; 754 } 755 // Push any remaining segment after splitting on dots 756 if (currentSegment) { 757 segments.push(...currentSegment.split('.').filter(Boolean)); 758 } 759 return segments; 760} 761function createStandardIssues(error, parentPath) { 762 const path = parentPath ? "".concat(parentPath, ".").concat(error.path) : error.path; 763 return error.errors.map((err)=>({ 764 message: err, 765 path: createStandardPath(path) 766 })); 767} 768function issuesFromValidationError(error, parentPath) { 769 var _error$inner; 770 if (!((_error$inner = error.inner) != null && _error$inner.length) && error.errors.length) { 771 return createStandardIssues(error, parentPath); 772 } 773 const path = parentPath ? "".concat(parentPath, ".").concat(error.path) : error.path; 774 return error.inner.flatMap((err)=>issuesFromValidationError(err, path)); 775} 776// If `CustomSchemaMeta` isn't extended with any keys, we'll fall back to a 777// loose Record definition allowing free form usage. 778class Schema { 779 // TODO: remove 780 get _type() { 781 return this.type; 782 } 783 clone(spec) { 784 if (this._mutate) { 785 if (spec) Object.assign(this.spec, spec); 786 return this; 787 } 788 // if the nested value is a schema we can skip cloning, since 789 // they are already immutable 790 const next = Object.create(Object.getPrototypeOf(this)); 791 // @ts-expect-error this is readonly 792 next.type = this.type; 793 next._typeCheck = this._typeCheck; 794 next._whitelist = this._whitelist.clone();
795 next._blacklist = this._blacklist.clone(); 796 next.internalTests = Object.assign({}, this.internalTests); 797 next.exclusiveTests = Object.assign({}, this.exclusiveTests); 798 // @ts-expect-error this is readonly 799 next.deps = [ 800 ...this.deps 801 ]; 802 next.conditions = [ 803 ...this.conditions 804 ]; 805 next.tests = [ 806 ...this.tests 807 ]; 808 next.transforms = [ 809 ...this.transforms 810 ]; 811 next.spec = clone(Object.assign({}, this.spec, spec)); 812 return next; 813 } 814 label(label) { 815 let next = this.clone(); 816 next.spec.label = label; 817 return next; 818 } 819 meta() { 820 for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){ 821 args[_key] = arguments[_key]; 822 } 823 if (args.length === 0) return this.spec.meta; 824 let next = this.clone(); 825 next.spec.meta = Object.assign(next.spec.meta || {}, args[0]); 826 return next; 827 } 828 withMutation(fn) { 829 let before = this._mutate; 830 this._mutate = true; 831 let result = fn(this); 832 this._mutate = before; 833 return result; 834 } 835 concat(schema) { 836 if (!schema || schema === this) return this; 837 if (schema.type !== this.type && this.type !== 'mixed') throw new TypeError("You cannot `concat()` schema's of different types: ".concat(this.type, " and ").concat(schema.type)); 838 let base = this; 839 let combined = schema.clone(); 840 const mergedSpec = Object.assign({}, base.spec, combined.spec); 841 combined.spec = mergedSpec; 842 combined.internalTests = Object.assign({}, base.internalTests, combined.internalTests); 843 // manually merge the blacklist/whitelist (the other `schema` takes 844 // precedence in case of conflicts) 845 combined._whitelist = base._whitelist.merge(schema._whitelist, schema._blacklist); 846 combined._blacklist = base._blacklist.merge(schema._blacklist, schema._whitelist); 847 // start with the current tests 848 combined.tests = base.tests; 849 combined.exclusiveTests = base.exclusiveTests; 850 // manually add the new tests to ensure 851 // the deduping logic is consistent 852 combined.withMutation((next)=>{ 853 schema.tests.forEach((fn)=>{ 854 next.test(fn.OPTIONS); 855 }); 856 }); 857 combined.transforms = [ 858 ...base.transforms, 859 ...combined.transforms 860 ]; 861 return combined; 862 } 863 isType(v) { 864 if (v == null) { 865 if (this.spec.nullable && v === null) return true; 866 if (this.spec.optional && v === undefined) return true; 867 return false; 868 } 869 return this._typeCheck(v); 870 } 871 resolve(options) { 872 let schema = this; 873 if (schema.conditions.length) { 874 let conditions = schema.conditions; 875 schema = schema.clone(); 876 schema.conditions = []; 877 schema = conditions.reduce((prevSchema, condition)=>condition.resolve(prevSchema, options), schema); 878 schema = schema.resolve(options); 879 } 880 return schema; 881 } 882 resolveOptions(options) { 883 var _options$strict, _options$abortEarly, _options$recursive, _options$disableStack; 884 return Object.assign({}, options, { 885 from: options.from || [], 886 strict: (_options$strict = options.strict) != null ? _options$strict : this.spec.strict, 887 abortEarly: (_options$abortEarly = options.abortEarly) != null ? _options$abortEarly : this.spec.abortEarly, 888 recursive: (_options$recursive = options.recursive) != null ? _options$recursive : this.spec.recursive, 889 disableStackTrace: (_options$disableStack = options.disableStackTrace) != null ? _options$disableStack : this.spec.disableStackTrace 890 }); 891 } 892 /** 893 * Run the configured transform pipeline over an input value. 894 */ cast(value) { 895 let options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}; 896 let resolvedSchema = this.resolve(Object.assign({}, options, { 897 value 898 })); 899 let allowOptionality = options.assert === 'ignore-optionality'; 900 let result = resolvedSchema._cast(value, options); 901 if (options.assert !== false && !resolvedSchema.isType(result)) { 902 if (allowOptionality && isAbsent(result)) { 903 return result; 904 } 905 let formattedValue = printValue(value); 906 let formattedResult = printValue(result); 907 throw new TypeError("The value of ".concat(options.path || 'field', "
907could not be cast to a value ") + 'that satisfies the schema type: "'.concat(resolvedSchema.type, '". \n\n') + "attempted value: ".concat(formattedValue, " \n") + (formattedResult !== formattedValue ? "result of cast: ".concat(formattedResult) : '')); 908 } 909 return result; 910 } 911 _cast(rawValue, options) { 912 let value = rawValue === undefined ? rawValue : this.transforms.reduce((prevValue, fn)=>fn.call(this, prevValue, rawValue, this, options), rawValue); 913 if (value === undefined) { 914 value = this.getDefault(options); 915 } 916 return value; 917 } 918 _validate(_value) { 919 let options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, panic = arguments.length > 2 ? arguments[2] : void 0, next = arguments.length > 3 ? arguments[3] : void 0; 920 let { path, originalValue = _value, strict = this.spec.strict } = options; 921 let value = _value; 922 if (!strict) { 923 value = this._cast(value, Object.assign({ 924 assert: false 925 }, options)); 926 } 927 let initialTests = []; 928 for (let test of Object.values(this.internalTests)){ 929 if (test) initialTests.push(test); 930 } 931 this.runTests({ 932 path, 933 value, 934 originalValue, 935 options, 936 tests: initialTests 937 }, panic, (initialErrors)=>{ 938 // even if we aren't ending early we can't proceed further if the types aren't correct 939 if (initialErrors.length) { 940 return next(initialErrors, value); 941 } 942 this.runTests({ 943 path, 944 value, 945 originalValue, 946 options, 947 tests: this.tests 948 }, panic, next); 949 }); 950 } 951 /** 952 * Executes a set of validations, either schema, produced Tests or a nested 953 * schema validate result. 954 */ runTests(runOptions, panic, next) { 955 let fired = false; 956 let { tests, value, originalValue, path, options } = runOptions; 957 let panicOnce = (arg)=>{ 958 if (fired) return; 959 fired = true; 960 panic(arg, value); 961 }; 962 let nextOnce = (arg)=>{ 963 if (fired) return; 964 fired = true; 965 next(arg, value); 966 }; 967 let count = tests.length; 968 let nestedErrors = []; 969 if (!count) return nextOnce([]); 970 let args = { 971 value, 972 originalValue, 973 path, 974 options, 975 schema: this 976 }; 977 for(let i = 0; i < tests.length; i++){ 978 const test = tests[i]; 979 test(args, panicOnce, function finishTestRun(err) { 980 if (err) { 981 Array.isArray(err) ? nestedErrors.push(...err) : nestedErrors.push(err); 982 } 983 if (--count <= 0) { 984 nextOnce(nestedErrors); 985 } 986 }); 987 } 988 } 989 asNestedTest(param) { 990 let { key, index, parent, parentPath, originalParent, options } = param; 991 const k = key != null ? key : index; 992 if (k == null) { 993 throw TypeError('Must include `key` or `index` for nested validations'); 994 } 995 const isIndex = typeof k === 'number'; 996 let value = parent[k]; 997 const testOptions = Object.assign({}, options, { 998 // Nested validations fields are always strict: 999 // 1. parent isn't strict so the casting will also have cast inner values 1000 // 2. parent is strict in which case the nested values weren't cast either 1001 strict: true, 1002 parent, 1003 value, 1004 originalValue: originalParent[k], 1005 // FIXME: tests depend on `index` being passed around deeply, 1006 // we should not let the options.key/index bleed through 1007 key: undefined, 1008 // index: undefined, 1009 [isIndex ? 'index' : 'key']: k, 1010 path: isIndex || k.includes('.') ? "".concat(parentPath || '', "[").concat(isIndex ? k : '"'.concat(k, '"'), "]") : (parentPath ? "".concat(parentPath, ".") : '') + key 1011 }); 1012 return (_, panic, next)=>this.resolve(testOptions)._validate(value, testOptions, panic, next); 1013 } 1014 validate(value, options) { 1015 var _options$disableStack2; 1016 let schema = this.resolve(Object.assign({}, options, { 1017 value 1018 })); 1019 let disableStackTrace = (_options$disableStack2 = options == null ? void 0 : options.disableStackTrace) != null ? _options$disableStack2 : schema.spec.disableStackTrace; 1020 return new Promise((resolve, reject)=>schema._validate(value, options, (error, parsed)=>{ 1021 if (ValidationError.isError(error)) error.value = parsed; 1022 reject(error); 1023 }, (errors, validated)=>{ 1024 if (errors.length) reject(new ValidationError(errors, validated, undefined, undefined, disableStackTrace)); 1025 else resolve(validated); 1026 })); 1027 } 1028 validateSync(value, options) { 1029 var _options$disableStack3; 1030 let schema = this.resolve(Object.assign({}, options, { 1031 value 1032 })); 1033 let result; 1034 let disableStackTrace = (_options$disableStack3 = options == null ? void 0 : options.disableStackTrace) != null ? _options$disableStack3 : schema.spec.disableStackTrace; 1035 schema._validate(value, Object.assign({}, options, { 1036 sync: true 1037 }), (error, parsed)=>{ 1038 if (ValidationError.isError(error)) error.value = parsed; 1039 throw error; 1040 }, (errors, validated)=>{ 1041 if (errors.length) throw new ValidationError(errors, value, undefined, undefined, disableStackTrace); 1042 result = validated; 1043 }); 1044 return result; 1045 } 1046 isValid(value, options) { 1047 return this.validate(value, options).then(()=>true, (err)=>{ 1048 if (ValidationError.isError(err)) return false;
1049 throw err; 1050 }); 1051 } 1052 isValidSync(value, options) { 1053 try { 1054 this.validateSync(value, options); 1055 return true; 1056 } catch (err) { 1057 if (ValidationError.isError(err)) return false; 1058 throw err; 1059 } 1060 } 1061 _getDefault(options) { 1062 let defaultValue = this.spec.default; 1063 if (defaultValue == null) { 1064 return defaultValue; 1065 } 1066 return typeof defaultValue === 'function' ? defaultValue.call(this, options) : clone(defaultValue); 1067 } 1068 getDefault(options) { 1069 let schema = this.resolve(options || {}); 1070 return schema._getDefault(options); 1071 } 1072 default(def) { 1073 if (arguments.length === 0) { 1074 return this._getDefault(); 1075 } 1076 let next = this.clone({ 1077 default: def 1078 }); 1079 return next; 1080 } 1081 strict() { 1082 let isStrict = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : true; 1083 return this.clone({ 1084 strict: isStrict 1085 }); 1086 } 1087 nullability(nullable, message) { 1088 const next = this.clone({ 1089 nullable 1090 }); 1091 next.internalTests.nullable = createValidation({ 1092 message, 1093 name: 'nullable', 1094 test (value) { 1095 return value === null ? this.schema.spec.nullable : true; 1096 } 1097 }); 1098 return next; 1099 } 1100 optionality(optional, message) { 1101 const next = this.clone({ 1102 optional 1103 }); 1104 next.internalTests.optionality = createValidation({ 1105 message, 1106 name: 'optionality', 1107 test (value) { 1108 return value === undefined ? this.schema.spec.optional : true; 1109 } 1110 }); 1111 return next; 1112 } 1113 optional() { 1114 return this.optionality(true); 1115 } 1116 defined() { 1117 let message = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : mixed.defined; 1118 return this.optionality(false, message); 1119 } 1120 nullable() { 1121 return this.nullability(true); 1122 } 1123 nonNullable() { 1124 let message = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : mixed.notNull; 1125 return this.nullability(false, message); 1126 } 1127 required() { 1128 let message = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : mixed.required; 1129 return this.clone().withMutation((next)=>next.nonNullable(message).defined(message)); 1130 } 1131 notRequired() { 1132 return this.clone().withMutation((next)=>next.nullable().optional()); 1133 } 1134 transform(fn) { 1135 let next = this.clone(); 1136 next.transforms.push(fn); 1137 return next; 1138 } 1139 /** 1140 * Adds a test function to the schema's queue of tests. 1141 * tests can be exclusive or non-exclusive. 1142 * 1143 * - exclusive tests, will replace any existing tests of the same name. 1144 * - non-exclusive: can be stacked 1145 * 1146 * If a non-exclusive test is added to a schema with an exclusive test of the same name 1147 * the exclusive test is removed and further tests of the same name will be stacked. 1148 * 1149 * If an exclusive test is added to a schema with non-exclusive tests of the same name 1150 * the previous tests are removed and further tests of the same name will replace each other. 1151 */ test() { 1152 for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){ 1153 args[_key] = arguments[_key]; 1154 } 1155 let opts; 1156 if (args.length === 1) { 1157 if (typeof args[0] === 'function') { 1158 opts = { 1159 test: args[0] 1160 }; 1161 } else { 1162 opts = args[0]; 1163 } 1164 } else if (args.length === 2) { 1165 opts = { 1166 name: args[0], 1167 test: args[1] 1168 }; 1169 } else { 1170 opts = { 1171 name: args[0], 1172 message: args[1], 1173 test: args[2] 1174 }; 1175 } 1176 if (opts.message === undefined) opts.message = mixed.default; 1177 if (typeof opts.test !== 'function') throw new TypeError('`test` is a required parameters'); 1178 let next = this.clone(); 1179 let validate = createValidation(opts); 1180 let isExclusive = opts.exclusive || opts.name && next.exclusiveTests[opts.name] === true; 1181 if (opts.exclusive) { 1182 if (!opts.name) throw new TypeError('Exclusive tests must provide a unique `name` identifying the test'); 1183 } 1184 if (opts.name) next.exclusiveTests[opts.name] = !!opts.exclusive; 1185 next.tests = next.tests.filter((fn)=>{ 1186 if (fn.OPTIONS.name === opts.name) { 1187 if (isExclusive) return false;
1188 if (fn.OPTIONS.test === validate.OPTIONS.test) return false; 1189 } 1190 return true; 1191 }); 1192 next.tests.push(validate); 1193 return next; 1194 } 1195 when(keys, options) { 1196 if (!Array.isArray(keys) && typeof keys !== 'string') { 1197 options = keys; 1198 keys = '.'; 1199 } 1200 let next = this.clone(); 1201 let deps = toArray(keys).map((key)=>new Reference(key)); 1202 deps.forEach((dep)=>{ 1203 // @ts-ignore readonly array 1204 if (dep.isSibling) next.deps.push(dep.key); 1205 }); 1206 next.conditions.push(typeof options === 'function' ? new Condition(deps, options) : Condition.fromOptions(deps, options)); 1207 return next; 1208 } 1209 typeError(message) { 1210 let next = this.clone(); 1211 next.internalTests.typeError = createValidation({ 1212 message, 1213 name: 'typeError', 1214 skipAbsent: true, 1215 test (value) { 1216 if (!this.schema._typeCheck(value)) return this.createError({ 1217 params: { 1218 type: this.schema.type 1219 } 1220 }); 1221 return true; 1222 } 1223 }); 1224 return next; 1225 } 1226 oneOf(enums) { 1227 let message = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : mixed.oneOf; 1228 let next = this.clone(); 1229 enums.forEach((val)=>{ 1230 next._whitelist.add(val); 1231 next._blacklist.delete(val); 1232 }); 1233 next.internalTests.whiteList = createValidation({ 1234 message, 1235 name: 'oneOf', 1236 skipAbsent: true, 1237 test (value) { 1238 let valids = this.schema._whitelist; 1239 let resolved = valids.resolveAll(this.resolve); 1240 return resolved.includes(value) ? true : this.createError({ 1241 params: { 1242 values: Array.from(valids).join(', '), 1243 resolved 1244 } 1245 }); 1246 } 1247 }); 1248 return next; 1249 } 1250 notOneOf(enums) { 1251 let message = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : mixed.notOneOf; 1252 let next = this.clone(); 1253 enums.forEach((val)=>{ 1254 next._blacklist.add(val); 1255 next._whitelist.delete(val); 1256 }); 1257 next.internalTests.blacklist = createValidation({ 1258 message, 1259 name: 'notOneOf', 1260 test (value) { 1261 let invalids = this.schema._blacklist; 1262 let resolved = invalids.resolveAll(this.resolve); 1263 if (resolved.includes(value)) return this.createError({ 1264 params: { 1265 values: Array.from(invalids).join(', '), 1266 resolved 1267 } 1268 }); 1269 return true; 1270 } 1271 }); 1272 return next; 1273 } 1274 strip() { 1275 let strip = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : true; 1276 let next = this.clone(); 1277 next.spec.strip = strip; 1278 return next; 1279 } 1280 /** 1281 * Return a serialized description of the schema including validations, flags, types etc. 1282 * 1283 * @param options Provide any needed context for resolving runtime schema alterations (lazy, when conditions, etc). 1284 */ describe(options) { 1285 const next = (options ? this.resolve(options) : this).clone(); 1286 const { label, meta, optional, nullable } = next.spec; 1287 const description = { 1288 meta, 1289 label, 1290 optional, 1291 nullable, 1292 default: next.getDefault(options), 1293 type: next.type, 1294 oneOf: next._whitelist.describe(), 1295 notOneOf: next._blacklist.describe(), 1296 tests: next.tests.filter((n, idx, list)=>list.findIndex((c)=>c.OPTIONS.name === n.OPTIONS.name) === idx).map((fn)=>{ 1297 const params = fn.OPTIONS.params && options ? resolveParams(Object.assign({}, fn.OPTIONS.params), options) : fn.OPTIONS.params; 1298 return { 1299 name: fn.OPTIONS.name, 1300 params 1301 }; 1302 }) 1303 }; 1304 return description; 1305 } 1306 get ['~standard']() { 1307 const schema = this; 1308 const standard = { 1309 version: 1, 1310 vendor: 'yup', 1311 async validate (value) { 1312 try { 1313 const result = await schema.validate(value, { 1314 abortEarly: false 1315 }); 1316 return { 1317 value: result 1318 }; 1319 } catch (err) { 1320 if (err instanceof ValidationError) { 1321 return { 1322 issues: issuesFromValidationError(err) 1323 }; 1324 } 1325 throw err; 1326 } 1327 } 1328 }; 1329 return standard; 1330 } 1331 constructor(options){ 1332 this.type = void 0; 1333 this.deps = []; 1334 this.tests = void 0; 1335 this.transforms = void 0; 1336 this.conditions = []; 1337 this._mutate = void 0; 1338 this.internalTests = {}; 1339 this._whitelist = new ReferenceSet(); 1340 this._blacklist = new ReferenceSet(); 1341 this.exclusiveTests = Object.create(null); 1342 this._typeCheck = void 0; 1343 this.spec = void 0; 1344 this.tests = []; 1345 this.transforms = []; 1346 this.withMutation(()=>{ 1347 this.typeError(mixed.notType); 1348 }); 1349 this.type = options.type; 1350 this._typeCheck = options.check; 1351 this.spec = Object.assign({
1352 strip: false, 1353 strict: false, 1354 abortEarly: true, 1355 recursive: true, 1356 disableStackTrace: false, 1357 nullable: false, 1358 optional: true, 1359 coerce: true 1360 }, options == null ? void 0 : options.spec); 1361 this.withMutation((s)=>{ 1362 s.nonNullable(); 1363 }); 1364 } 1365} 1366// @ts-expect-error 1367Schema.prototype.__isYupSchema__ = true; 1368for (const method of [ 1369 'validate', 1370 'validateSync' 1371])Schema.prototype["".concat(method, "At")] = function(path, value) { 1372 let options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {}; 1373 const { parent, parentPath, schema } = getIn(this, path, value, options.context); 1374 return schema[method](parent && parent[parentPath], Object.assign({}, options, { 1375 parent, 1376 path 1377 })); 1378}; 1379for (const alias of [ 1380 'equals', 1381 'is' 1382])Schema.prototype[alias] = Schema.prototype.oneOf; 1383for (const alias of [ 1384 'not', 1385 'nope' 1386])Schema.prototype[alias] = Schema.prototype.notOneOf; 1387const returnsTrue = ()=>true; 1388function create$8(spec) { 1389 return new MixedSchema(spec); 1390} 1391class MixedSchema extends Schema { 1392 constructor(spec){ 1393 super(typeof spec === 'function' ? { 1394 type: 'mixed', 1395 check: spec 1396 } : Object.assign({ 1397 type: 'mixed', 1398 check: returnsTrue 1399 }, spec)); 1400 } 1401} 1402create$8.prototype = MixedSchema.prototype; 1403function create$7() { 1404 return new BooleanSchema(); 1405} 1406class BooleanSchema extends Schema { 1407 isTrue() { 1408 let message = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : boolean.isValue; 1409 return this.test({ 1410 message, 1411 name: 'is-value', 1412 exclusive: true, 1413 params: { 1414 value: 'true' 1415 }, 1416 test (value) { 1417 return isAbsent(value) || value === true; 1418 } 1419 }); 1420 } 1421 isFalse() { 1422 let message = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : boolean.isValue; 1423 return this.test({ 1424 message, 1425 name: 'is-value', 1426 exclusive: true, 1427 params: { 1428 value: 'false' 1429 }, 1430 test (value) { 1431 return isAbsent(value) || value === false; 1432 } 1433 }); 1434 } 1435 default(def) { 1436 return super.default(def); 1437 } 1438 defined(msg) { 1439 return super.defined(msg); 1440 } 1441 optional() { 1442 return super.optional(); 1443 } 1444 required(msg) { 1445 return super.required(msg); 1446 } 1447 notRequired() { 1448 return super.notRequired(); 1449 } 1450 nullable() { 1451 return super.nullable(); 1452 } 1453 nonNullable(msg) { 1454 return super.nonNullable(msg); 1455 } 1456 strip(v) { 1457 return super.strip(v); 1458 } 1459 constructor(){ 1460 super({ 1461 type: 'boolean', 1462 check (v) { 1463 if (v instanceof Boolean) v = v.valueOf(); 1464 return typeof v === 'boolean'; 1465 } 1466 }); 1467 this.withMutation(()=>{ 1468 this.transform((value, _raw)=>{ 1469 if (this.spec.coerce && !this.isType(value)) { 1470 if (/^(true|1)$/i.test(String(value))) return true; 1471 if (/^(false|0)$/i.test(String(value))) return false; 1472 } 1473 return value; 1474 }); 1475 }); 1476 } 1477} 1478create$7.prototype = BooleanSchema.prototype; 1479/** 1480 * This file is a modified version of the file from the following repository: 1481 * Date.parse with progressive enhancement for ISO 8601 <https://github.com/csnover/js-iso8601> 1482 * NON-CONFORMANT EDITION. 1483 * © 2011 Colin Snover <http://zetafleet.com> 1484 * Released under MIT license. 1485 */ // prettier-ignore 1486// 1 YYYY 2 MM 3 DD 4 HH 5 mm 6 ss 7 msec 8 Z 9 ± 10 tzHH 11 tzmm 1487const isoReg = /^(\d{4}|[+-]\d{6})(?:-?(\d{2})(?:-?(\d{2}))?)?(?:[ T]?(\d{2}):?(\d{2})(?::?(\d{2})(?:[,.](\d{1,}))?)?(?:(Z)|([+-])(\d{2})(?::?(\d{2}))?)?)?$/; 1488function parseIsoDate(date) { 1489 const struct = parseDateStruct(date);
1490 if (!struct) return Date.parse ? Date.parse(date) : Number.NaN; 1491 // timestamps without timezone identifiers should be considered local time 1492 if (struct.z === undefined && struct.plusMinus === undefined) { 1493 return new Date(struct.year, struct.month, struct.day, struct.hour, struct.minute, struct.second, struct.millisecond).valueOf(); 1494 } 1495 let totalMinutesOffset = 0; 1496 if (struct.z !== 'Z' && struct.plusMinus !== undefined) { 1497 totalMinutesOffset = struct.hourOffset * 60 + struct.minuteOffset; 1498 if (struct.plusMinus === '+') totalMinutesOffset = 0 - totalMinutesOffset; 1499 } 1500 return Date.UTC(struct.year, struct.month, struct.day, struct.hour, struct.minute + totalMinutesOffset, struct.second, struct.millisecond); 1501} 1502function parseDateStruct(date) { 1503 var _regexResult$7$length, _regexResult$; 1504 const regexResult = isoReg.exec(date); 1505 if (!regexResult) return null; 1506 // use of toNumber() avoids NaN timestamps caused by âundefinedâ 1507 // values being passed to Date constructor 1508 return { 1509 year: toNumber(regexResult[1]), 1510 month: toNumber(regexResult[2], 1) - 1, 1511 day: toNumber(regexResult[3], 1), 1512 hour: toNumber(regexResult[4]), 1513 minute: toNumber(regexResult[5]), 1514 second: toNumber(regexResult[6]), 1515 millisecond: regexResult[7] ? // allow arbitrary sub-second precision beyond milliseconds 1516 toNumber(regexResult[7].substring(0, 3)) : 0, 1517 precision: (_regexResult$7$length = (_regexResult$ = regexResult[7]) == null ? void 0 : _regexResult$.length) != null ? _regexResult$7$length : undefined, 1518 z: regexResult[8] || undefined, 1519 plusMinus: regexResult[9] || undefined, 1520 hourOffset: toNumber(regexResult[10]), 1521 minuteOffset: toNumber(regexResult[11]) 1522 }; 1523} 1524function toNumber(str) { 1525 let defaultValue = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 0; 1526 return Number(str) || defaultValue; 1527} 1528// Taken from HTML spec: https://html.spec.whatwg.org/multipage/input.html#valid-e-mail-address 1529let rEmail = // eslint-disable-next-line 1530/^[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])?)*$/; 1531let rUrl = // eslint-disable-next-line 1532/^((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; 1533// eslint-disable-next-line 1534let 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; 1535let yearMonthDay = '^\\d{4}-\\d{2}-\\d{2}'; 1536let hourMinuteSecond = '\\d{2}:\\d{2}:\\d{2}'; 1537let zOrOffset = '(([+-]\\d{2}(:?\\d{2})?)|Z)'; 1538let rIsoDateTime = new RegExp("".concat(yearMonthDay, "T").concat(hourMinuteSecond, "(\\.\\d+)?").concat(zOrOffset, "$")); 1539let isTrimmed = (value)=>isAbsent(value) || value === value.trim(); 1540let objStringTag = ({}).toString(); 1541function create$6() { 1542 return new StringSchema(); 1543} 1544class StringSchema extends Schema { 1545 required(message) { 1546 return super.required(message).withMutation((schema)=>schema.test({ 1547 message: message || mixed.required, 1548 name: 'required', 1549 skipAbsent: true, 1550 test: (value)=>!!value.length 1551 })); 1552 } 1553 notRequired() { 1554 return super.notRequired().withMutation((schema)=>{ 1555 schema.tests = schema.tests.filter((t)=>t.OPTIONS.name !== 'required'); 1556 return schema; 1557 }); 1558 } 1559 length(length) { 1560 let message = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : string.length; 1561 return this.test({ 1562 message, 1563 name: 'length', 1564 exclusive: true, 1565 params: { 1566 length 1567 }, 1568 skipAbsent: true, 1569 test (value) { 1570 return value.length === this.resolve(length); 1571 } 1572 }); 1573 } 1574 min(min) { 1575 let message = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : string.min; 1576 return this.test({ 1577 message, 1578 name: 'min', 1579 exclusive: true, 1580 params: { 1581 min 1582 }, 1583 skipAbsent: true, 1584 test (value) { 1585 return value.length >= this.resolve(min); 1586 } 1587 }); 1588 } 1589 max(max) { 1590 let message = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : string.max; 1591 return this.test({ 1592 name: 'max', 1593 exclusive: true, 1594 message, 1595 params: { 1596 max 1597 }, 1598 skipAbsent: true, 1599 test (value) { 1600 return value.length <= this.resolve(max); 1601 } 1602 }); 1603 } 1604 matches(regex, options) { 1605 let excludeEmptyString = false;
1606 let message; 1607 let name; 1608 if (options) { 1609 if (typeof options === 'object') { 1610 ({ excludeEmptyString = false, message, name } = options); 1611 } else { 1612 message = options; 1613 } 1614 } 1615 return this.test({ 1616 name: name || 'matches', 1617 message: message || string.matches, 1618 params: { 1619 regex 1620 }, 1621 skipAbsent: true, 1622 test: (value)=>value === '' && excludeEmptyString || value.search(regex) !== -1 1623 }); 1624 } 1625 email() { 1626 let message = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : string.email; 1627 return this.matches(rEmail, { 1628 name: 'email', 1629 message, 1630 excludeEmptyString: true 1631 }); 1632 } 1633 url() { 1634 let message = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : string.url; 1635 return this.matches(rUrl, { 1636 name: 'url', 1637 message, 1638 excludeEmptyString: true 1639 }); 1640 } 1641 uuid() { 1642 let message = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : string.uuid; 1643 return this.matches(rUUID, { 1644 name: 'uuid', 1645 message, 1646 excludeEmptyString: false 1647 }); 1648 } 1649 datetime(options) { 1650 let message = ''; 1651 let allowOffset; 1652 let precision; 1653 if (options) { 1654 if (typeof options === 'object') { 1655 ({ message = '', allowOffset = false, precision = undefined } = options); 1656 } else { 1657 message = options; 1658 } 1659 } 1660 return this.matches(rIsoDateTime, { 1661 name: 'datetime', 1662 message: message || string.datetime, 1663 excludeEmptyString: true 1664 }).test({ 1665 name: 'datetime_offset', 1666 message: message || string.datetime_offset, 1667 params: { 1668 allowOffset 1669 }, 1670 skipAbsent: true, 1671 test: (value)=>{ 1672 if (!value || allowOffset) return true; 1673 const struct = parseDateStruct(value); 1674 if (!struct) return false; 1675 return !!struct.z; 1676 } 1677 }).test({ 1678 name: 'datetime_precision', 1679 message: message || string.datetime_precision, 1680 params: { 1681 precision 1682 }, 1683 skipAbsent: true, 1684 test: (value)=>{ 1685 if (!value || precision == undefined) return true; 1686 const struct = parseDateStruct(value); 1687 if (!struct) return false; 1688 return struct.precision === precision; 1689 } 1690 }); 1691 } 1692 //-- transforms -- 1693 ensure() { 1694 return this.default('').transform((val)=>val === null ? '' : val); 1695 } 1696 trim() { 1697 let message = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : string.trim; 1698 return this.transform((val)=>val != null ? val.trim() : val).test({ 1699 message, 1700 name: 'trim', 1701 test: isTrimmed 1702 }); 1703 } 1704 lowercase() { 1705 let message = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : string.lowercase; 1706 return this.transform((value)=>!isAbsent(value) ? value.toLowerCase() : value).test({ 1707 message, 1708 name: 'string_case', 1709 exclusive: true, 1710 skipAbsent: true, 1711 test: (value)=>isAbsent(value) || value === value.toLowerCase() 1712 }); 1713 } 1714 uppercase() { 1715 let message = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : string.uppercase; 1716 return this.transform((value)=>!isAbsent(value) ? value.toUpperCase() : value).test({ 1717 message, 1718 name: 'string_case', 1719 exclusive: true, 1720 skipAbsent: true, 1721 test: (value)=>isAbsent(value) || value === value.toUpperCase() 1722 }); 1723 } 1724 constructor(){ 1725 super({ 1726 type: 'string', 1727 check (value) { 1728 if (value instanceof String) value = value.valueOf(); 1729 return typeof value === 'string'; 1730 } 1731 }); 1732 this.withMutation(()=>{ 1733 this.transform((value, _raw)=>{ 1734 if (!this.spec.coerce || this.isType(value)) return value; 1735 // don't ever convert arrays 1736 if (Array.isArray(value)) return value; 1737 const strValue = value != null && value.toString ? value.toString() : value; 1738 // no one wants plain objects converted to [Object object] 1739 if (strValue === objStringTag) return value; 1740 return strValue; 1741 }); 1742 }); 1743 } 1744} 1745create$6.prototype = StringSchema.prototype; 1746// 1747// String Interfaces 1748// 1749let isNaN$1 = (value)=>value != +value; 1750function create$5() { 1751 return new NumberSchema(); 1752} 1753class NumberSchema extends Schema { 1754 min(min) { 1755 let message = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : number.min; 1756 return this.test({ 1757 message, 1758 name: 'min', 1759 exclusive: true, 1760 params: { 1761 min 1762 }, 1763 skipAbsent: true, 1764 test (value) { 1765 return value >= this.resolve(min); 1766 } 1767 }); 1768 } 1769 max(max) { 1770 let message = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : number.max; 1771 return this.test({ 1772 message, 1773 name: 'max', 1774 exclusive: true, 1775 params: { 1776 max 1777 }, 1778 skipAbsent: true, 1779 test (value) { 1780 return value <= this.resolve(max); 1781 } 1782 }); 1783 } 1784 lessThan(less) { 1785 let message = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : number.lessThan; 1786 return this.test({ 1787 message, 1788 name: 'max', 1789 exclusive: true, 1790 params: { 1791 less 1792 }, 1793 skipAbsent: true, 1794 test (value) { 1795 return value < this.resolve(less); 1796 } 1797 }); 1798 } 1799 moreThan(more) { 1800 let message = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : number.moreThan; 1801 return this.test({ 1802 message, 1803 name: 'min', 1804 exclusive: true, 1805 params: { 1806 more 1807 }, 1808 skipAbsent: true, 1809 test (value) { 1810 return value > this.resolve(more); 1811 } 1812 }); 1813 } 1814 positive() { 1815 let msg = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : number.positive; 1816 return this.moreThan(0, msg); 1817 } 1818 negative() { 1819 let msg = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : number.negative; 1820 return this.lessThan(0, msg); 1821 } 1822 integer() { 1823 let message = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : number.integer; 1824 return this.test({ 1825 name: 'integer', 1826 message, 1827 skipAbsent: true, 1828 test: (val)=>
1828Number.isInteger(val) 1829 }); 1830 } 1831 truncate() { 1832 return this.transform((value)=>!isAbsent(value) ? value | 0 : value); 1833 } 1834 round(method) { 1835 var _method; 1836 let avail = [ 1837 'ceil', 1838 'floor', 1839 'round', 1840 'trunc' 1841 ]; 1842 method = ((_method = method) == null ? void 0 : _method.toLowerCase()) || 'round'; 1843 // this exists for symemtry with the new Math.trunc 1844 if (method === 'trunc') return this.truncate(); 1845 if (avail.indexOf(method.toLowerCase()) === -1) throw new TypeError('Only valid options for round() are: ' + avail.join(', ')); 1846 return this.transform((value)=>!isAbsent(value) ? Math[method](value) : value); 1847 } 1848 constructor(){ 1849 super({ 1850 type: 'number', 1851 check (value) { 1852 if (value instanceof Number) value = value.valueOf(); 1853 return typeof value === 'number' && !isNaN$1(value); 1854 } 1855 }); 1856 this.withMutation(()=>{ 1857 this.transform((value, _raw)=>{ 1858 if (!this.spec.coerce) return value; 1859 let parsed = value; 1860 if (typeof parsed === 'string') { 1861 parsed = parsed.replace(/\s/g, ''); 1862 if (parsed === '') return NaN; 1863 // don't use parseFloat to avoid positives on alpha-numeric strings 1864 parsed = +parsed; 1865 } 1866 // null -> NaN isn't useful; treat all nulls as null and let it fail on 1867 // nullability check vs TypeErrors 1868 if (this.isType(parsed) || parsed === null) return parsed; 1869 return parseFloat(parsed); 1870 }); 1871 }); 1872 } 1873} 1874create$5.prototype = NumberSchema.prototype; 1875// 1876// Number Interfaces 1877// 1878let invalidDate = new Date(''); 1879let isDate = (obj)=>Object.prototype.toString.call(obj) === '[object Date]'; 1880function create$4() { 1881 return new DateSchema(); 1882} 1883class DateSchema extends Schema { 1884 prepareParam(ref, name) { 1885 let param; 1886 if (!Reference.isRef(ref)) { 1887 let cast = this.cast(ref); 1888 if (!this._typeCheck(cast)) throw new TypeError("`".concat(name, "` must be a Date or a value that can be `cast()` to a Date")); 1889 param = cast; 1890 } else { 1891 param = ref; 1892 } 1893 return param; 1894 } 1895 min(min) { 1896 let message = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : date.min; 1897 let limit = this.prepareParam(min, 'min'); 1898 return this.test({ 1899 message, 1900 name: 'min', 1901 exclusive: true, 1902 params: { 1903 min 1904 }, 1905 skipAbsent: true, 1906 test (value) { 1907 return value >= this.resolve(limit); 1908 } 1909 }); 1910 } 1911 max(max) { 1912 let message = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : date.max; 1913 let limit = this.prepareParam(max, 'max'); 1914 return this.test({ 1915 message, 1916 name: 'max', 1917 exclusive: true, 1918 params: { 1919 max 1920 }, 1921 skipAbsent: true, 1922 test (value) { 1923 return value <= this.resolve(limit); 1924 } 1925 }); 1926 } 1927 constructor(){ 1928 super({ 1929 type: 'date', 1930 check (v) { 1931 return isDate(v) && !isNaN(v.getTime()); 1932 } 1933 }); 1934 this.withMutation(()=>{ 1935 this.transform((value, _raw)=>{ 1936 // null -> InvalidDate isn't useful; treat all nulls as null and let it fail on 1937 // nullability check vs TypeErrors 1938 if (!this.spec.coerce || this.isType(value) || value === null) return value; 1939 value = parseIsoDate(value); 1940 // 0 is a valid timestamp equivalent to 1970-01-01T00:00:00Z(unix epoch) or before. 1941 return !isNaN(value) ? new Date(value) : DateSchema.INVALID_DATE; 1942 }); 1943 }); 1944 } 1945} 1946DateSchema.INVALID_DATE = invalidDate; 1947create$4.prototype = DateSchema.prototype; 1948create$4.INVALID_DATE = invalidDate; 1949// @ts-expect-error 1950function sortFields(fields) { 1951 let excludedEdges = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : []; 1952 let edges = []; 1953 let nodes = new Set(); 1954 let excludes = new Set(excludedEdges.map((param)=>{ 1955 let [a, b] = param; 1956 return "".concat(a, "-").concat(b); 1957 })); 1958 function addNode(depPath, key) { 1959 let node = (0, __TURBOPACK__imported__module__437472__["split"])(depPath)[0]; 1960 nodes.add(node); 1961 if (!excludes.has("".concat(key, "-").concat(node))) edges.push([ 1962 key, 1963 node 1964 ]); 1965 } 1966 for (const key of Object.keys(fields)){ 1967 let value = fields[key]; 1968 nodes.add(key); 1969 if (Reference.isRef(value) && value.isSibling) addNode(value.path, key); 1970 else if (isSchema(value) && 'deps' in value) value.deps.forEach((path)=>addNode(path, key)); 1971 } 1972 return __TURBOPACK__imported__module__301439__["default"].array(Array.from(nodes), edges).reverse(); 1973} 1974function findIndex(arr, err) { 1975 let idx = Infinity; 1976 arr.some((key, ii)=>{ 1977 var _err$path; 1978 if ((_err$path = err.path) != null && _err$path.includes(key)) { 1979 idx = ii; 1980 return true; 1981 } 1982 }); 1983 return idx; 1984} 1985function sortByKeyOrder(keys) { 1986 return (a, b)=>{ 1987 return findIndex(keys, a) - findIndex(keys, b); 1988 }; 1989} 1990const parseJson = (value, _, schema)=>{ 1991 if (typeof value !== 'string') { 1992 return value; 1993 } 1994 let parsed = value; 1995 try { 1996 parsed = JSON.parse(value); 1997 } catch (err) { 1998 /* */ } 1999 return schema.isType(parsed) ? parsed : value; 2000}; 2001// @ts-ignore 2002function deepPartial(schema) { 2003 if ('fields' in schema) { 2004 const partial = {}; 2005 for (const [key, fieldSchema] of Object.entries(schema.fields)){ 2006 partial[key] = deepPartial(fieldSchema); 2007 } 2008 return schema.setFields(partial); 2009 } 2010 if (schema.type === 'array') { 2011 const nextArray = schema.optional(); 2012 if (nextArray.innerType) nextArray.innerType = deepPartial(nextArray.innerType); 2013 return nextArray; 2014 } 2015 if (schema.type === 'tuple') { 2016 return schema.optional().clone({ 2017 types: schema.spec.types.map(deepPartial) 2018 }); 2019 } 2020 if ('optional' in schema) { 2021 return schema.optional(); 2022 } 2023 return schema; 2024} 2025const deepHas = (obj, p)=>{ 2026 const path = [ 2027 ...(0, __TURBOPACK__imported__module__437472__["normalizePath"])(p) 2028 ]; 2029 if (path.length === 1) return path[0] in obj; 2030 let last = path.pop(); 2031 let parent = (0, __TURBOPACK__imported__module__437472__["getter"])((0, __TURBOPACK__imported__module__437472__["join"])(path), true)(obj); 2032 return !!(parent && last in parent); 2033}; 2034let isObject = (obj)=>Object.prototype.toString.call(obj) === '[object Object]'; 2035function unknown(ctx, value) { 2036 let known = Object.keys(ctx.fields); 2037 return Object.keys(value).filter((key)=>known.indexOf(key) === -1); 2038} 2039const defaultSort = sortByKeyOrder([]); 2040function create$3(spec) { 2041 return new ObjectSchema(spec); 2042} 2043class ObjectSchema extends Schema { 2044 _cast(_value) { 2045 let options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}; 2046 var _options$stripUnknown; 2047 let value = super._cast(_value, options); 2048 //should ignore nulls here 2049 if (value === undefined) return this.getDefault(options); 2050 if (!this._typeCheck(value)) return value; 2051 let fields = this.fields; 2052 let strip = (_options$stripUnknown = options.stripUnknown) != null ? _options$stripUnknown : this.spec.noUnknown; 2053 let props = [].concat(this._nodes, Object.keys(value).filter((v)=>!this._nodes.includes(v))); 2054 let intermediateValue = {}; // is filled during the transform below 2055 let innerOptions = Object.assign({}, options, { 2056 parent: intermediateValue, 2057 __validating: options.__validating || false 2058 }); 2059 let isChanged = false;
2060 for (const prop of props){ 2061 let field = fields[prop]; 2062 let exists = prop in value; 2063 let inputValue = value[prop]; 2064 if (field) { 2065 let fieldValue; 2066 // safe to mutate since this is fired in sequence 2067 innerOptions.path = (options.path ? "".concat(options.path, ".") : '') + prop; 2068 field = field.resolve({ 2069 value: inputValue, 2070 context: options.context, 2071 parent: intermediateValue 2072 }); 2073 let fieldSpec = field instanceof Schema ? field.spec : undefined; 2074 let strict = fieldSpec == null ? void 0 : fieldSpec.strict; 2075 if (fieldSpec != null && fieldSpec.strip) { 2076 isChanged = isChanged || prop in value; 2077 continue; 2078 } 2079 fieldValue = !options.__validating || !strict ? field.cast(inputValue, innerOptions) : inputValue; 2080 if (fieldValue !== undefined) { 2081 intermediateValue[prop] = fieldValue; 2082 } 2083 } else if (exists && !strip) { 2084 intermediateValue[prop] = inputValue; 2085 } 2086 if (exists !== prop in intermediateValue || intermediateValue[prop] !== inputValue) { 2087 isChanged = true; 2088 } 2089 } 2090 return isChanged ? intermediateValue : value; 2091 } 2092 _validate(_value) { 2093 let options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, panic = arguments.length > 2 ? arguments[2] : void 0, next = arguments.length > 3 ? arguments[3] : void 0; 2094 let { from = [], originalValue = _value, recursive = this.spec.recursive } = options; 2095 options.from = [ 2096 { 2097 schema: this, 2098 value: originalValue 2099 }, 2100 ...from 2101 ]; 2102 // this flag is needed for handling `strict` correctly in the context of 2103 // validation vs just casting. e.g strict() on a field is only used when validating 2104 options.__validating = true; 2105 options.originalValue = originalValue; 2106 super._validate(_value, options, panic, (objectErrors, value)=>{ 2107 if (!recursive || !isObject(value)) { 2108 next(objectErrors, value); 2109 return; 2110 } 2111 originalValue = originalValue || value; 2112 let tests = []; 2113 for (let key of this._nodes){ 2114 let field = this.fields[key]; 2115 if (!field || Reference.isRef(field)) { 2116 continue; 2117 } 2118 tests.push(field.asNestedTest({ 2119 options, 2120 key, 2121 parent: value, 2122 parentPath: options.path, 2123 originalParent: originalValue 2124 })); 2125 } 2126 this.runTests({ 2127 tests, 2128 value, 2129 originalValue, 2130 options 2131 }, panic, (fieldErrors)=>{ 2132 next(fieldErrors.sort(this._sortErrors).concat(objectErrors), value); 2133 }); 2134 }); 2135 } 2136 clone(spec) { 2137 const next = super.clone(spec); 2138 next.fields = Object.assign({}, this.fields); 2139 next._nodes = this._nodes; 2140 next._excludedEdges = this._excludedEdges; 2141 next._sortErrors = this._sortErrors; 2142 return next; 2143 } 2144 concat(schema) { 2145 let next = super.concat(schema); 2146 let nextFields = next.fields; 2147 for (let [field, schemaOrRef] of Object.entries(this.fields)){ 2148 const target = nextFields[field]; 2149 nextFields[field] = target === undefined ? schemaOrRef : target; 2150 } 2151 return next.withMutation((s)=>// XXX: excludes here is wrong 2152 s.setFields(nextFields, [ 2153 ...this._excludedEdges, 2154 ...schema._excludedEdges 2155 ])); 2156 } 2157 _getDefault(options) { 2158 if ('default' in this.spec) { 2159 return super._getDefault(options); 2160 } 2161 // if there is no default set invent one 2162 if (!this._nodes.length) { 2163 return undefined; 2164 } 2165 let dft = {};
2166 this._nodes.forEach((key)=>{ 2167 var _innerOptions; 2168 const field = this.fields[key]; 2169 let innerOptions = options; 2170 if ((_innerOptions = innerOptions) != null && _innerOptions.value) { 2171 innerOptions = Object.assign({}, innerOptions, { 2172 parent: innerOptions.value, 2173 value: innerOptions.value[key] 2174 }); 2175 } 2176 dft[key] = field && 'getDefault' in field ? field.getDefault(innerOptions) : undefined; 2177 }); 2178 return dft; 2179 } 2180 setFields(shape, excludedEdges) { 2181 let next = this.clone(); 2182 next.fields = shape; 2183 next._nodes = sortFields(shape, excludedEdges); 2184 next._sortErrors = sortByKeyOrder(Object.keys(shape)); 2185 // XXX: this carries over edges which may not be what you want 2186 if (excludedEdges) next._excludedEdges = excludedEdges; 2187 return next; 2188 } 2189 shape(additions) { 2190 let excludes = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : []; 2191 return this.clone().withMutation((next)=>{ 2192 let edges = next._excludedEdges; 2193 if (excludes.length) { 2194 if (!Array.isArray(excludes[0])) excludes = [ 2195 excludes 2196 ]; 2197 edges = [ 2198 ...next._excludedEdges, 2199 ...excludes 2200 ]; 2201 } 2202 // XXX: excludes here is wrong 2203 return next.setFields(Object.assign(next.fields, additions), edges); 2204 }); 2205 } 2206 partial() { 2207 const partial = {}; 2208 for (const [key, schema] of Object.entries(this.fields)){ 2209 partial[key] = 'optional' in schema && schema.optional instanceof Function ? schema.optional() : schema; 2210 } 2211 return this.setFields(partial); 2212 } 2213 deepPartial() { 2214 const next = deepPartial(this); 2215 return next; 2216 } 2217 pick(keys) { 2218 const picked = {}; 2219 for (const key of keys){ 2220 if (this.fields[key]) picked[key] = this.fields[key]; 2221 } 2222 return this.setFields(picked, this._excludedEdges.filter((param)=>{ 2223 let [a, b] = param; 2224 return keys.includes(a) && keys.includes(b); 2225 })); 2226 } 2227 omit(keys) { 2228 const remaining = []; 2229 for (const key of Object.keys(this.fields)){ 2230 if (keys.includes(key)) continue; 2231 remaining.push(key); 2232 } 2233 return this.pick(remaining); 2234 } 2235 from(from, to, alias) { 2236 let fromGetter = (0, __TURBOPACK__imported__module__437472__["getter"])(from, true); 2237 return this.transform((obj)=>{ 2238 if (!obj) return obj; 2239 let newObj = obj; 2240 if (deepHas(obj, from)) { 2241 newObj = Object.assign({}, obj); 2242 if (!alias) delete newObj[from]; 2243 newObj[to] = fromGetter(obj); 2244 } 2245 return newObj; 2246 }); 2247 } 2248 /** Parse an input JSON string to an object */ json() { 2249 return this.transform(parseJson); 2250 } 2251 /** 2252 * Similar to `noUnknown` but only validates that an object is the right shape without stripping the unknown keys 2253 */ exact(message) { 2254 return this.test({ 2255 name: 'exact', 2256 exclusive: true, 2257 message: message || object.exact, 2258 test (value) { 2259 if (value == null) return true; 2260 const unknownKeys = unknown(this.schema, value); 2261 return unknownKeys.length === 0 || this.createError({ 2262 params: { 2263 properties: unknownKeys.join(', ') 2264 } 2265 }); 2266 } 2267 }); 2268 } 2269 stripUnknown() { 2270 return this.clone({ 2271 noUnknown: true 2272 }); 2273 } 2274 noUnknown() { 2275 let noAllow = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : true, message = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : object.noUnknown; 2276 if (typeof noAllow !== 'boolean') { 2277 message = noAllow; 2278 noAllow = true; 2279 } 2280 let next = this.test({ 2281 name: 'noUnknown', 2282 exclusive: true, 2283 message: message, 2284 test (value) { 2285 if (value == null) return true; 2286 const unknownKeys = unknown(this.schema, value); 2287 return !noAllow || unknownKeys.length === 0 || this.createError({ 2288 params: { 2289 unknown: unknownKeys.join(', ') 2290 } 2291 }); 2292 } 2293 }); 2294 next.spec.noUnknown = noAllow; 2295 return next; 2296 } 2297 unknown() { 2298 let allow = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : true, message = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : object.noUnknown; 2299 return this.noUnknown(!allow, message); 2300 } 2301 transformKeys(fn) { 2302 return this.transform((obj)=>{ 2303 if (!obj) return obj; 2304 const result = {}; 2305 for (const key of Object.keys(obj))result[fn(key)] = obj[key]; 2306 return result; 2307 }); 2308 } 2309 camelCase() { 2310 return this.transformKeys(__TURBOPACK__imported__module__303873__["camelCase"]); 2311 } 2312 snakeCase() { 2313 return this.transformKeys(__TURBOPACK__imported__module__303873__["snakeCase"]); 2314 } 2315 constantCase() { 2316 return this.transformKeys((key)=>(0, __TURBOPACK__imported__module__303873__["snakeCase"])(key).toUpperCase()); 2317 } 2318 describe(options) { 2319 const next = (options ? this.resolve(options) : this).clone(); 2320 const base = super.describe(options); 2321 base.fields = {}; 2322 for (const [key, value] of Object.entries(next.fields)){ 2323 var _innerOptions2; 2324 let innerOptions = options; 2325 if ((_innerOptions2 = innerOptions) != null && _innerOptions2.value) { 2326 innerOptions = Object.assign({}, innerOptions, { 2327 parent: innerOptions.value, 2328 value: innerOptions.value[key] 2329 }); 2330 } 2331 base.fields[key] = value.describe(innerOptions); 2332 } 2333 return base; 2334 } 2335 constructor(spec){ 2336 super({ 2337 type: 'object', 2338 check (value) { 2339 return isObject(value) || typeof value === 'function'; 2340 } 2341 }); 2342 this.fields = Object.create(null); 2343 this._sortErrors = defaultSort; 2344 this._nodes = []; 2345 this._excludedEdges = []; 2346 this.withMutation(()=>{ 2347 if (spec) { 2348 this.shape(spec); 2349 } 2350 }); 2351 } 2352} 2353create$3.prototype = ObjectSchema.prototype; 2354function create$2(type) { 2355 return new ArraySchema(type); 2356} 2357class ArraySchema extends Schema { 2358 _cast(_value, _opts) { 2359 const value = super._cast(_value, _opts); 2360 // should ignore nulls here 2361 if (!this._typeCheck(value) || !this.innerType) { 2362 return value; 2363 } 2364 let isChanged = false;
2365 const castArray = value.map((v, idx)=>{ 2366 const castElement = this.innerType.cast(v, Object.assign({}, _opts, { 2367 path: "".concat(_opts.path || '', "[").concat(idx, "]"), 2368 parent: value, 2369 originalValue: v, 2370 value: v, 2371 index: idx 2372 })); 2373 if (castElement !== v) { 2374 isChanged = true; 2375 } 2376 return castElement; 2377 }); 2378 return isChanged ? castArray : value; 2379 } 2380 _validate(_value) { 2381 let options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, panic = arguments.length > 2 ? arguments[2] : void 0, next = arguments.length > 3 ? arguments[3] : void 0; 2382 var _options$recursive; 2383 // let sync = options.sync; 2384 // let path = options.path; 2385 let innerType = this.innerType; 2386 // let endEarly = options.abortEarly ?? this.spec.abortEarly; 2387 let recursive = (_options$recursive = options.recursive) != null ? _options$recursive : this.spec.recursive; 2388 options.originalValue != null ? options.originalValue : _value; 2389 super._validate(_value, options, panic, (arrayErrors, value)=>{ 2390 var _options$originalValu2; 2391 if (!recursive || !innerType || !this._typeCheck(value)) { 2392 next(arrayErrors, value); 2393 return; 2394 } 2395 // #950 Ensure that sparse array empty slots are validated 2396 let tests = new Array(value.length); 2397 for(let index = 0; index < value.length; index++){ 2398 var _options$originalValu; 2399 tests[index] = innerType.asNestedTest({ 2400 options, 2401 index, 2402 parent: value, 2403 parentPath: options.path, 2404 originalParent: (_options$originalValu = options.originalValue) != null ? _options$originalValu : _value 2405 }); 2406 } 2407 this.runTests({ 2408 value, 2409 tests, 2410 originalValue: (_options$originalValu2 = options.originalValue) != null ? _options$originalValu2 : _value, 2411 options 2412 }, panic, (innerTypeErrors)=>next(innerTypeErrors.concat(arrayErrors), value)); 2413 }); 2414 } 2415 clone(spec) { 2416 const next = super.clone(spec); 2417 // @ts-expect-error readonly 2418 next.innerType = this.innerType; 2419 return next; 2420 } 2421 /** Parse an input JSON string to an object */ json() { 2422 return this.transform(parseJson); 2423 } 2424 concat(schema) { 2425 let next = super.concat(schema); 2426 // @ts-expect-error readonly 2427 next.innerType = this.innerType; 2428 if (schema.innerType) // @ts-expect-error readonly 2429 next.innerType = next.innerType ? // @ts-expect-error Lazy doesn't have concat and will break 2430 next.innerType.concat(schema.innerType) : schema.innerType; 2431 return next; 2432 } 2433 of(schema) { 2434 // FIXME: this should return a new instance of array without the default to be 2435 let next = this.clone(); 2436 if (!isSchema(schema)) throw new TypeError('`array.of()` sub-schema must be a valid yup schema not: ' + printValue(schema)); 2437 // @ts-expect-error readonly 2438 next.innerType = schema; 2439 next.spec = Object.assign({}, next.spec, { 2440 types: schema 2441 }); 2442 return next; 2443 } 2444 length(length) { 2445 let message = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : array.length; 2446 return this.test({ 2447 message, 2448 name: 'length', 2449 exclusive: true, 2450 params: { 2451 length 2452 }, 2453 skipAbsent: true, 2454 test (value) { 2455 return value.length === this.resolve(length); 2456 } 2457 }); 2458 } 2459 min(min, message) { 2460 message = message || array.min; 2461 return this.test({ 2462 message, 2463 name: 'min', 2464 exclusive: true, 2465 params: { 2466 min 2467 }, 2468 skipAbsent: true, 2469 // FIXME(ts): Array<typeof T> 2470 test (value) { 2471 return value.length >= this.resolve(min); 2472 } 2473 }); 2474 } 2475 max(max, message) { 2476 message = message || array.max; 2477 return this.test({ 2478 message, 2479 name: 'max', 2480 exclusive: true, 2481 params: { 2482 max 2483 }, 2484 skipAbsent: true, 2485 test (value) { 2486 return value.length <= this.resolve(max); 2487 } 2488 }); 2489 } 2490 ensure() { 2491 return this.default(()=>[]).transform((val, original)=>{ 2492 // We don't want to return `null` for nullable schema 2493 if (this._typeCheck(val)) return val; 2494 return original == null ? [] : [].concat(original); 2495 }); 2496 } 2497 compact(rejector) { 2498 let reject = !rejector ? (v)=>!!v : (v, i, a)=>!rejector(v, i, a); 2499 return this.transform((values)=>values != null ? values.filter(reject) : values); 2500 } 2501 describe(options) { 2502 const next = (options ? this.resolve(options) : this).clone(); 2503 const base = super.describe(options); 2504 if (next.innerType) { 2505 var _innerOptions; 2506 let innerOptions = options; 2507 if ((_innerOptions = innerOptions) != null && _innerOptions.value) { 2508 innerOptions = Object.assign({}, innerOptions, { 2509 parent: innerOptions.value, 2510 value: innerOptions.value[0] 2511 }); 2512 } 2513 base.innerType = next.innerType.describe(innerOptions); 2514 } 2515 return base; 2516 } 2517 constructor(type){ 2518 super({ 2519 type: 'array', 2520 spec: { 2521 types: type 2522 }, 2523 check (v) { 2524 return Array.isArray(v); 2525 } 2526 }); 2527 // `undefined` specifically means uninitialized, as opposed to "no subtype" 2528 this.innerType = void 0; 2529 this.innerType = type; 2530 } 2531} 2532create$2.prototype = ArraySchema.prototype; 2533// @ts-ignore 2534function create$1(schemas) { 2535 return new TupleSchema(schemas); 2536} 2537class TupleSchema extends Schema { 2538 _cast(inputValue, options) { 2539 const { types } = this.spec; 2540 const value = super._cast(inputValue, options); 2541 if (!this._typeCheck(value)) { 2542 return value; 2543 } 2544 let isChanged = false;
2545 const castArray = types.map((type, idx)=>{ 2546 const castElement = type.cast(value[idx], Object.assign({}, options, { 2547 path: "".concat(options.path || '', "[").concat(idx, "]"), 2548 parent: value, 2549 originalValue: value[idx], 2550 value: value[idx], 2551 index: idx 2552 })); 2553 if (castElement !== value[idx]) isChanged = true; 2554 return castElement; 2555 }); 2556 return isChanged ? castArray : value; 2557 } 2558 _validate(_value) { 2559 let options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, panic = arguments.length > 2 ? arguments[2] : void 0, next = arguments.length > 3 ? arguments[3] : void 0; 2560 let itemTypes = this.spec.types; 2561 super._validate(_value, options, panic, (tupleErrors, value)=>{ 2562 var _options$originalValu2; 2563 // intentionally not respecting recursive 2564 if (!this._typeCheck(value)) { 2565 next(tupleErrors, value); 2566 return; 2567 } 2568 let tests = []; 2569 for (let [index, itemSchema] of itemTypes.entries()){ 2570 var _options$originalValu; 2571 tests[index] = itemSchema.asNestedTest({ 2572 options, 2573 index, 2574 parent: value, 2575 parentPath: options.path, 2576 originalParent: (_options$originalValu = options.originalValue) != null ? _options$originalValu : _value 2577 }); 2578 } 2579 this.runTests({ 2580 value, 2581 tests, 2582 originalValue: (_options$originalValu2 = options.originalValue) != null ? _options$originalValu2 : _value, 2583 options 2584 }, panic, (innerTypeErrors)=>next(innerTypeErrors.concat(tupleErrors), value)); 2585 }); 2586 } 2587 describe(options) { 2588 const next = (options ? this.resolve(options) : this).clone(); 2589 const base = super.describe(options); 2590 base.innerType = next.spec.types.map((schema, index)=>{ 2591 var _innerOptions; 2592 let innerOptions = options; 2593 if ((_innerOptions = innerOptions) != null && _innerOptions.value) { 2594 innerOptions = Object.assign({}, innerOptions, { 2595 parent: innerOptions.value, 2596 value: innerOptions.value[index] 2597 }); 2598 } 2599 return schema.describe(innerOptions); 2600 }); 2601 return base; 2602 } 2603 constructor(schemas){ 2604 super({ 2605 type: 'tuple', 2606 spec: { 2607 types: schemas 2608 }, 2609 check (v) { 2610 const types = this.spec.types; 2611 return Array.isArray(v) && v.length === types.length; 2612 } 2613 }); 2614 this.withMutation(()=>{ 2615 this.typeError(tuple.notType); 2616 }); 2617 } 2618} 2619create$1.prototype = TupleSchema.prototype; 2620function create(builder) { 2621 return new Lazy(builder); 2622} 2623function catchValidationError(fn) { 2624 try { 2625 return fn(); 2626 } catch (err) { 2627 if (ValidationError.isError(err)) return Promise.reject(err); 2628 throw err; 2629 } 2630} 2631class Lazy { 2632 clone(spec) { 2633 const next = new Lazy(this.builder); 2634 next.spec = Object.assign({}, this.spec, spec); 2635 return next; 2636 } 2637 optionality(optional) { 2638 const next = this.clone({ 2639 optional 2640 }); 2641 return next; 2642 } 2643 optional() { 2644 return this.optionality(true); 2645 } 2646 resolve(options) { 2647 return this._resolve(options.value, options); 2648 } 2649 cast(value, options) { 2650 return this._resolve(value, options).cast(value, options); 2651 } 2652 asNestedTest(config) { 2653 let { key, index, parent, options } = config; 2654 let value = parent[index != null ? index : key]; 2655 return this._resolve(value, Object.assign({}, options, { 2656 value, 2657 parent 2658 })).asNestedTest(config); 2659 } 2660 validate(value, options) { 2661 return catchValidationError(()=>this._resolve(value, options).validate(value, options)); 2662 } 2663 validateSync(value, options) { 2664 return this._resolve(value, options).validateSync(value, options); 2665 } 2666 validateAt(path, value, options) { 2667 return catchValidationError(()=>this._resolve(value, options).validateAt(path, value, options)); 2668 } 2669 validateSyncAt(path, value, options) { 2670 return this._resolve(value, options).validateSyncAt(path, value, options); 2671 } 2672 isValid(value, options) { 2673 try { 2674 return this._resolve(value, options).isValid(value, options); 2675 } catch (err) { 2676 if (ValidationError.isError(err)) { 2677 return Promise.resolve(false); 2678 } 2679 throw err; 2680 } 2681 } 2682 isValidSync(value, options) { 2683 return this._resolve(value, options).isValidSync(value, options); 2684 } 2685 describe(options) { 2686 return options ? this.resolve(options).describe(options) : { 2687 type: 'lazy', 2688 meta: this.spec.meta, 2689 label: undefined 2690 }; 2691 } 2692 meta() { 2693 for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){ 2694 args[_key] = arguments[_key]; 2695 } 2696 if (args.length === 0) return this.spec.meta; 2697 let next = this.clone(); 2698 next.spec.meta = Object.assign(next.spec.meta || {}, args[0]); 2699 return next; 2700 } 2701 get ['~standard']() { 2702 const schema = this; 2703 const standard = { 2704 version: 1, 2705 vendor: 'yup', 2706 async validate (value) { 2707 try { 2708 const result = await schema.validate(value, { 2709 abortEarly: false 2710 }); 2711 return { 2712 value: result 2713 }; 2714 } catch (err) { 2715 if (ValidationError.isError(err)) { 2716 return { 2717 issues: issuesFromValidationError(err) 2718 }; 2719 } 2720 throw err; 2721 } 2722 } 2723 }; 2724 return standard; 2725 } 2726 constructor(builder){ 2727 var _this = this; 2728 this.type = 'lazy'; 2729 this.__isYupSchema__ = true; 2730 this.spec = void 0; 2731 this._resolve = function(value) { 2732 let options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}; 2733 let schema = _this.builder(value, options); 2734 if (!isSchema(schema)) throw new TypeError('lazy() functions must return a valid schema'); 2735 if (_this.spec.optional) schema = schema.optional(); 2736 return schema.resolve(options); 2737 }; 2738 this.builder = builder; 2739 this.spec = { 2740 meta: undefined, 2741 optional: false 2742 }; 2743 } 2744} 2745function setLocale(custom) { 2746 Object.keys(custom).forEach((type)=>{ 2747 // @ts-ignore
2748 Object.keys(custom[type]).forEach((method)=>{ 2749 // @ts-ignore 2750 locale[type][method] = custom[type][method]; 2751 }); 2752 }); 2753} 2754function addMethod(schemaType, name, fn) { 2755 if (!schemaType || !isSchema(schemaType.prototype)) throw new TypeError('You must provide a yup schema constructor function'); 2756 if (typeof name !== 'string') throw new TypeError('A Method name must be provided'); 2757 if (typeof fn !== 'function') throw new TypeError('Method function must be provided'); 2758 schemaType.prototype[name] = fn; 2759} 2760; 2761__turbopack_context__.s([ 2762 "boolean", 2763 0, 2764 create$7, 2765 "date", 2766 0, 2767 create$4, 2768 "number", 2769 0, 2770 create$5, 2771 "object", 2772 0, 2773 create$3, 2774 "ref", 2775 0, 2776 create$9, 2777 "string", 2778 0, 2779 create$6 2780]); 2781}), 2782]); 2783 2784//# debugId=163bbc01-2a51-0193-5676-54368d21691e
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.