superstruct
Advanced tools
Comparing version 0.16.0 to 0.16.1
@@ -86,3 +86,3 @@ /** | ||
*/ | ||
type IsUnion<T, U extends T = T> = (T extends any ? (U extends T ? false : true) : false) extends false ? never : T; | ||
type IsUnion<T, U extends T> = (T extends any ? (U extends T ? false : true) : false) extends false ? never : T; | ||
/** | ||
@@ -174,5 +174,5 @@ * A schema for object structs. | ||
*/ | ||
type InferStructTuple<Tuple extends AnyStruct[], Length extends number = Tuple["length"]> = Length extends Length ? number extends Length ? Tuple : _InferTuple<Tuple, Length, [ | ||
type InferStructTuple<Tuple extends AnyStruct[], Length extends number> = Length extends Length ? number extends Length ? Tuple : _InferTuple<Tuple, Length, [ | ||
]> : never; | ||
type _InferTuple<Tuple extends AnyStruct[], Length extends number, Accumulated extends unknown[], Index extends number = Accumulated["length"]> = Index extends Length ? Accumulated : _InferTuple<Tuple, Length, [ | ||
type _InferTuple<Tuple extends AnyStruct[], Length extends number, Accumulated extends unknown[], Index extends number> = Index extends Length ? Accumulated : _InferTuple<Tuple, Length, [ | ||
...Accumulated, | ||
@@ -186,3 +186,3 @@ Infer<Tuple[Index]> | ||
*/ | ||
declare class Struct<T = unknown, S = unknown> { | ||
declare class Struct<T, S> { | ||
readonly TYPE: T; | ||
@@ -295,3 +295,3 @@ type: string; | ||
*/ | ||
type Coercer<T = unknown> = (value: T, context: Context) => unknown; | ||
type Coercer<T> = (value: T, context: Context) => unknown; | ||
/** | ||
@@ -298,0 +298,0 @@ * A `Validator` takes an unknown value and validates it. |
@@ -23,3 +23,3 @@ /** | ||
} = failure; | ||
const msg = path.length === 0 ? message : "At path: " + path.join('.') + " -- " + message; | ||
const msg = path.length === 0 ? message : `At path: ${path.join('.')} -- ${message}`; | ||
super(msg); | ||
@@ -37,5 +37,3 @@ this.value = void 0; | ||
this.failures = () => { | ||
var _cached; | ||
return (_cached = cached) != null ? _cached : cached = [failure, ...failures()]; | ||
return cached ??= [failure, ...failures()]; | ||
}; | ||
@@ -77,3 +75,3 @@ } | ||
function print(value) { | ||
return typeof value === 'string' ? JSON.stringify(value) : "" + value; | ||
return typeof value === 'string' ? JSON.stringify(value) : `${value}`; | ||
} | ||
@@ -116,3 +114,3 @@ /** | ||
refinement, | ||
message = "Expected a value of type `" + type + "`" + (refinement ? " with refinement `" + refinement + "`" : '') + ", but received: `" + print(value) + "`" | ||
message = `Expected a value of type \`${type}\`${refinement ? ` with refinement \`${refinement}\`` : ''}, but received: \`${print(value)}\`` | ||
} = result; | ||
@@ -209,3 +207,3 @@ return { | ||
} else if (isObject(value)) { | ||
value[k] = v; | ||
if (v !== undefined) value[k] = v; | ||
} | ||
@@ -496,5 +494,3 @@ } | ||
*entries(value, ctx) { | ||
var _struct; | ||
(_struct = struct) != null ? _struct : struct = fn(); | ||
struct ??= fn(); | ||
yield* struct.entries(value, ctx); | ||
@@ -504,5 +500,3 @@ }, | ||
validator(value, ctx) { | ||
var _struct2; | ||
(_struct2 = struct) != null ? _struct2 : struct = fn(); | ||
struct ??= fn(); | ||
return struct.validator(value, ctx); | ||
@@ -512,5 +506,3 @@ }, | ||
coercer(value, ctx) { | ||
var _struct3; | ||
(_struct3 = struct) != null ? _struct3 : struct = fn(); | ||
struct ??= fn(); | ||
return struct.coercer(value, ctx); | ||
@@ -520,5 +512,3 @@ }, | ||
refiner(value, ctx) { | ||
var _struct4; | ||
(_struct4 = struct) != null ? _struct4 : struct = fn(); | ||
struct ??= fn(); | ||
return struct.refiner(value, ctx); | ||
@@ -628,3 +618,3 @@ } | ||
validator(value) { | ||
return Array.isArray(value) || "Expected an array value, but received: " + print(value); | ||
return Array.isArray(value) || `Expected an array value, but received: ${print(value)}`; | ||
} | ||
@@ -661,3 +651,3 @@ | ||
return define('date', value => { | ||
return value instanceof Date && !isNaN(value.getTime()) || "Expected a valid `Date` object, but received: " + print(value); | ||
return value instanceof Date && !isNaN(value.getTime()) || `Expected a valid \`Date\` object, but received: ${print(value)}`; | ||
}); | ||
@@ -678,3 +668,3 @@ } | ||
validator(value) { | ||
return values.includes(value) || "Expected one of `" + description + "`, but received: " + print(value); | ||
return values.includes(value) || `Expected one of \`${description}\`, but received: ${print(value)}`; | ||
} | ||
@@ -690,3 +680,3 @@ | ||
return define('func', value => { | ||
return typeof value === 'function' || "Expected a function, but received: " + print(value); | ||
return typeof value === 'function' || `Expected a function, but received: ${print(value)}`; | ||
}); | ||
@@ -700,3 +690,3 @@ } | ||
return define('instance', value => { | ||
return value instanceof Class || "Expected a `" + Class.name + "` instance, but received: " + print(value); | ||
return value instanceof Class || `Expected a \`${Class.name}\` instance, but received: ${print(value)}`; | ||
}); | ||
@@ -710,3 +700,3 @@ } | ||
return define('integer', value => { | ||
return typeof value === 'number' && !isNaN(value) && Number.isInteger(value) || "Expected an integer, but received: " + print(value); | ||
return typeof value === 'number' && !isNaN(value) && Number.isInteger(value) || `Expected an integer, but received: ${print(value)}`; | ||
}); | ||
@@ -751,3 +741,3 @@ } | ||
validator(value) { | ||
return value === constant || "Expected the literal `" + description + "`, but received: " + print(value); | ||
return value === constant || `Expected the literal \`${description}\`, but received: ${print(value)}`; | ||
} | ||
@@ -776,3 +766,3 @@ | ||
validator(value) { | ||
return value instanceof Map || "Expected a `Map` object, but received: " + print(value); | ||
return value instanceof Map || `Expected a \`Map\` object, but received: ${print(value)}`; | ||
} | ||
@@ -805,3 +795,3 @@ | ||
return define('number', value => { | ||
return typeof value === 'number' && !isNaN(value) || "Expected a number, but received: " + print(value); | ||
return typeof value === 'number' && !isNaN(value) || `Expected a number, but received: ${print(value)}`; | ||
}); | ||
@@ -832,3 +822,3 @@ } | ||
validator(value) { | ||
return isObject(value) || "Expected an object, but received: " + print(value); | ||
return isObject(value) || `Expected an object, but received: ${print(value)}`; | ||
}, | ||
@@ -876,3 +866,3 @@ | ||
validator(value) { | ||
return isObject(value) || "Expected an object, but received: " + print(value); | ||
return isObject(value) || `Expected an object, but received: ${print(value)}`; | ||
} | ||
@@ -912,3 +902,3 @@ | ||
validator(value) { | ||
return value instanceof Set || "Expected a `Set` object, but received: " + print(value); | ||
return value instanceof Set || `Expected a \`Set\` object, but received: ${print(value)}`; | ||
} | ||
@@ -924,3 +914,3 @@ | ||
return define('string', value => { | ||
return typeof value === 'string' || "Expected a string, but received: " + print(value); | ||
return typeof value === 'string' || `Expected a string, but received: ${print(value)}`; | ||
}); | ||
@@ -950,3 +940,3 @@ } | ||
validator(value) { | ||
return Array.isArray(value) || "Expected an array, but received: " + print(value); | ||
return Array.isArray(value) || `Expected an array, but received: ${print(value)}`; | ||
} | ||
@@ -978,3 +968,3 @@ | ||
validator(value) { | ||
return isObject(value) || "Expected an object, but received: " + print(value); | ||
return isObject(value) || `Expected an object, but received: ${print(value)}`; | ||
} | ||
@@ -1022,3 +1012,3 @@ | ||
return ["Expected the value to satisfy a union of `" + description + "`, but received: " + print(value), ...failures]; | ||
return [`Expected the value to satisfy a union of \`${description}\`, but received: ${print(value)}`, ...failures]; | ||
} | ||
@@ -1111,3 +1101,3 @@ | ||
const size = getSize(value); | ||
return size === 0 || "Expected an empty " + struct.type + " but received one with a size of `" + size + "`"; | ||
return size === 0 || `Expected an empty ${struct.type} but received one with a size of \`${size}\``; | ||
}); | ||
@@ -1137,3 +1127,3 @@ } | ||
return refine(struct, 'max', value => { | ||
return exclusive ? value < threshold : value <= threshold || "Expected a " + struct.type + " less than " + (exclusive ? '' : 'or equal to ') + threshold + " but received `" + value + "`"; | ||
return exclusive ? value < threshold : value <= threshold || `Expected a ${struct.type} less than ${exclusive ? '' : 'or equal to '}${threshold} but received \`${value}\``; | ||
}); | ||
@@ -1154,3 +1144,3 @@ } | ||
return refine(struct, 'min', value => { | ||
return exclusive ? value > threshold : value >= threshold || "Expected a " + struct.type + " greater than " + (exclusive ? '' : 'or equal to ') + threshold + " but received `" + value + "`"; | ||
return exclusive ? value > threshold : value >= threshold || `Expected a ${struct.type} greater than ${exclusive ? '' : 'or equal to '}${threshold} but received \`${value}\``; | ||
}); | ||
@@ -1165,3 +1155,3 @@ } | ||
const size = getSize(value); | ||
return size > 0 || "Expected a nonempty " + struct.type + " but received an empty one"; | ||
return size > 0 || `Expected a nonempty ${struct.type} but received an empty one`; | ||
}); | ||
@@ -1175,3 +1165,3 @@ } | ||
return refine(struct, 'pattern', value => { | ||
return regexp.test(value) || "Expected a " + struct.type + " matching `/" + regexp.source + "/` but received \"" + value + "\""; | ||
return regexp.test(value) || `Expected a ${struct.type} matching \`/${regexp.source}/\` but received "${value}"`; | ||
}); | ||
@@ -1188,7 +1178,7 @@ } | ||
const expected = "Expected a " + struct.type; | ||
const of = min === max ? "of `" + min + "`" : "between `" + min + "` and `" + max + "`"; | ||
const expected = `Expected a ${struct.type}`; | ||
const of = min === max ? `of \`${min}\`` : `between \`${min}\` and \`${max}\``; | ||
return refine(struct, 'size', value => { | ||
if (typeof value === 'number' || value instanceof Date) { | ||
return min <= value && value <= max || expected + " " + of + " but received `" + value + "`"; | ||
return min <= value && value <= max || `${expected} ${of} but received \`${value}\``; | ||
} else if (value instanceof Map || value instanceof Set) { | ||
@@ -1198,3 +1188,3 @@ const { | ||
} = value; | ||
return min <= size && size <= max || expected + " with a size " + of + " but received one with a size of `" + size + "`"; | ||
return min <= size && size <= max || `${expected} with a size ${of} but received one with a size of \`${size}\``; | ||
} else { | ||
@@ -1204,3 +1194,3 @@ const { | ||
} = value; | ||
return min <= length && length <= max || expected + " with a length " + of + " but received one with a length of `" + length + "`"; | ||
return min <= length && length <= max || `${expected} with a length ${of} but received one with a length of \`${length}\``; | ||
} | ||
@@ -1207,0 +1197,0 @@ }); |
@@ -5,3 +5,3 @@ { | ||
"description": "A simple and composable way to validate data in JavaScript (and TypeScript).", | ||
"version": "0.16.0", | ||
"version": "0.16.1", | ||
"license": "MIT", | ||
@@ -11,7 +11,7 @@ "repository": "git://github.com/ianstormtaylor/superstruct.git", | ||
"types": "./lib/index.d.ts", | ||
"main": "./lib/index.cjs", | ||
"main": "./lib/index.cjs.js", | ||
"module": "./lib/index.es.js", | ||
"exports": { | ||
"import": "./lib/index.es.js", | ||
"require": "./lib/index.cjs" | ||
"require": "./lib/index.cjs.js" | ||
}, | ||
@@ -33,8 +33,10 @@ "sideEffects": false, | ||
"@babel/register": "^7.6.2", | ||
"@types/expect": "^24.3.0", | ||
"@types/lodash": "^4.14.144", | ||
"@types/mocha": "^9.0.0", | ||
"@types/node": "^17.0.21", | ||
"@types/mocha": "^9.1.1", | ||
"@types/node": "^18.7.14", | ||
"@typescript-eslint/eslint-plugin": "^4.33.0", | ||
"@typescript-eslint/parser": "^4.33.0", | ||
"babel-eslint": "^10.0.3", | ||
"cross-env": "^7.0.3", | ||
"eslint": "^7.14.0", | ||
@@ -58,2 +60,3 @@ "eslint-config-prettier": "^7.2.0", | ||
"rollup-plugin-ts": "^3.0.1", | ||
"ts-mocha": "^10.0.0", | ||
"typescript": "^4.1.2" | ||
@@ -76,4 +79,3 @@ }, | ||
"release": "yarn build && yarn lint && np", | ||
"test": "yarn build:types && yarn test:types && yarn build:cjs && yarn test:mocha", | ||
"test:mocha": "mocha --require ./test/register.cjs --require source-map-support/register ./test/index.ts", | ||
"test": "cross-env TS_NODE_COMPILER_OPTIONS='{ \"module\": \"commonjs\", \"target\": \"es2019\" }' ts-mocha -p ./test/tsconfig.json ./test/index.ts", | ||
"test:types": "tsc --noEmit && tsc --project ./test/tsconfig.json --noEmit", | ||
@@ -80,0 +82,0 @@ "watch": "yarn build:cjs --watch", |
@@ -101,2 +101,4 @@ <p align="center"> | ||
let i = 0 | ||
const User = object({ | ||
@@ -114,3 +116,3 @@ id: defaulted(number(), () => i++), | ||
// { | ||
// id: 1, | ||
// id: 0, | ||
// name: 'Jane', | ||
@@ -117,0 +119,0 @@ // } |
@@ -29,3 +29,3 @@ (function (global, factory) { | ||
} = failure; | ||
const msg = path.length === 0 ? message : "At path: " + path.join('.') + " -- " + message; | ||
const msg = path.length === 0 ? message : `At path: ${path.join('.')} -- ${message}`; | ||
super(msg); | ||
@@ -43,5 +43,3 @@ this.value = void 0; | ||
this.failures = () => { | ||
var _cached; | ||
return (_cached = cached) != null ? _cached : cached = [failure, ...failures()]; | ||
return cached ??= [failure, ...failures()]; | ||
}; | ||
@@ -83,3 +81,3 @@ } | ||
function print(value) { | ||
return typeof value === 'string' ? JSON.stringify(value) : "" + value; | ||
return typeof value === 'string' ? JSON.stringify(value) : `${value}`; | ||
} | ||
@@ -122,3 +120,3 @@ /** | ||
refinement, | ||
message = "Expected a value of type `" + type + "`" + (refinement ? " with refinement `" + refinement + "`" : '') + ", but received: `" + print(value) + "`" | ||
message = `Expected a value of type \`${type}\`${refinement ? ` with refinement \`${refinement}\`` : ''}, but received: \`${print(value)}\`` | ||
} = result; | ||
@@ -215,3 +213,3 @@ return { | ||
} else if (isObject(value)) { | ||
value[k] = v; | ||
if (v !== undefined) value[k] = v; | ||
} | ||
@@ -502,5 +500,3 @@ } | ||
*entries(value, ctx) { | ||
var _struct; | ||
(_struct = struct) != null ? _struct : struct = fn(); | ||
struct ??= fn(); | ||
yield* struct.entries(value, ctx); | ||
@@ -510,5 +506,3 @@ }, | ||
validator(value, ctx) { | ||
var _struct2; | ||
(_struct2 = struct) != null ? _struct2 : struct = fn(); | ||
struct ??= fn(); | ||
return struct.validator(value, ctx); | ||
@@ -518,5 +512,3 @@ }, | ||
coercer(value, ctx) { | ||
var _struct3; | ||
(_struct3 = struct) != null ? _struct3 : struct = fn(); | ||
struct ??= fn(); | ||
return struct.coercer(value, ctx); | ||
@@ -526,5 +518,3 @@ }, | ||
refiner(value, ctx) { | ||
var _struct4; | ||
(_struct4 = struct) != null ? _struct4 : struct = fn(); | ||
struct ??= fn(); | ||
return struct.refiner(value, ctx); | ||
@@ -634,3 +624,3 @@ } | ||
validator(value) { | ||
return Array.isArray(value) || "Expected an array value, but received: " + print(value); | ||
return Array.isArray(value) || `Expected an array value, but received: ${print(value)}`; | ||
} | ||
@@ -667,3 +657,3 @@ | ||
return define('date', value => { | ||
return value instanceof Date && !isNaN(value.getTime()) || "Expected a valid `Date` object, but received: " + print(value); | ||
return value instanceof Date && !isNaN(value.getTime()) || `Expected a valid \`Date\` object, but received: ${print(value)}`; | ||
}); | ||
@@ -684,3 +674,3 @@ } | ||
validator(value) { | ||
return values.includes(value) || "Expected one of `" + description + "`, but received: " + print(value); | ||
return values.includes(value) || `Expected one of \`${description}\`, but received: ${print(value)}`; | ||
} | ||
@@ -696,3 +686,3 @@ | ||
return define('func', value => { | ||
return typeof value === 'function' || "Expected a function, but received: " + print(value); | ||
return typeof value === 'function' || `Expected a function, but received: ${print(value)}`; | ||
}); | ||
@@ -706,3 +696,3 @@ } | ||
return define('instance', value => { | ||
return value instanceof Class || "Expected a `" + Class.name + "` instance, but received: " + print(value); | ||
return value instanceof Class || `Expected a \`${Class.name}\` instance, but received: ${print(value)}`; | ||
}); | ||
@@ -716,3 +706,3 @@ } | ||
return define('integer', value => { | ||
return typeof value === 'number' && !isNaN(value) && Number.isInteger(value) || "Expected an integer, but received: " + print(value); | ||
return typeof value === 'number' && !isNaN(value) && Number.isInteger(value) || `Expected an integer, but received: ${print(value)}`; | ||
}); | ||
@@ -757,3 +747,3 @@ } | ||
validator(value) { | ||
return value === constant || "Expected the literal `" + description + "`, but received: " + print(value); | ||
return value === constant || `Expected the literal \`${description}\`, but received: ${print(value)}`; | ||
} | ||
@@ -782,3 +772,3 @@ | ||
validator(value) { | ||
return value instanceof Map || "Expected a `Map` object, but received: " + print(value); | ||
return value instanceof Map || `Expected a \`Map\` object, but received: ${print(value)}`; | ||
} | ||
@@ -811,3 +801,3 @@ | ||
return define('number', value => { | ||
return typeof value === 'number' && !isNaN(value) || "Expected a number, but received: " + print(value); | ||
return typeof value === 'number' && !isNaN(value) || `Expected a number, but received: ${print(value)}`; | ||
}); | ||
@@ -838,3 +828,3 @@ } | ||
validator(value) { | ||
return isObject(value) || "Expected an object, but received: " + print(value); | ||
return isObject(value) || `Expected an object, but received: ${print(value)}`; | ||
}, | ||
@@ -882,3 +872,3 @@ | ||
validator(value) { | ||
return isObject(value) || "Expected an object, but received: " + print(value); | ||
return isObject(value) || `Expected an object, but received: ${print(value)}`; | ||
} | ||
@@ -918,3 +908,3 @@ | ||
validator(value) { | ||
return value instanceof Set || "Expected a `Set` object, but received: " + print(value); | ||
return value instanceof Set || `Expected a \`Set\` object, but received: ${print(value)}`; | ||
} | ||
@@ -930,3 +920,3 @@ | ||
return define('string', value => { | ||
return typeof value === 'string' || "Expected a string, but received: " + print(value); | ||
return typeof value === 'string' || `Expected a string, but received: ${print(value)}`; | ||
}); | ||
@@ -956,3 +946,3 @@ } | ||
validator(value) { | ||
return Array.isArray(value) || "Expected an array, but received: " + print(value); | ||
return Array.isArray(value) || `Expected an array, but received: ${print(value)}`; | ||
} | ||
@@ -984,3 +974,3 @@ | ||
validator(value) { | ||
return isObject(value) || "Expected an object, but received: " + print(value); | ||
return isObject(value) || `Expected an object, but received: ${print(value)}`; | ||
} | ||
@@ -1028,3 +1018,3 @@ | ||
return ["Expected the value to satisfy a union of `" + description + "`, but received: " + print(value), ...failures]; | ||
return [`Expected the value to satisfy a union of \`${description}\`, but received: ${print(value)}`, ...failures]; | ||
} | ||
@@ -1117,3 +1107,3 @@ | ||
const size = getSize(value); | ||
return size === 0 || "Expected an empty " + struct.type + " but received one with a size of `" + size + "`"; | ||
return size === 0 || `Expected an empty ${struct.type} but received one with a size of \`${size}\``; | ||
}); | ||
@@ -1143,3 +1133,3 @@ } | ||
return refine(struct, 'max', value => { | ||
return exclusive ? value < threshold : value <= threshold || "Expected a " + struct.type + " less than " + (exclusive ? '' : 'or equal to ') + threshold + " but received `" + value + "`"; | ||
return exclusive ? value < threshold : value <= threshold || `Expected a ${struct.type} less than ${exclusive ? '' : 'or equal to '}${threshold} but received \`${value}\``; | ||
}); | ||
@@ -1160,3 +1150,3 @@ } | ||
return refine(struct, 'min', value => { | ||
return exclusive ? value > threshold : value >= threshold || "Expected a " + struct.type + " greater than " + (exclusive ? '' : 'or equal to ') + threshold + " but received `" + value + "`"; | ||
return exclusive ? value > threshold : value >= threshold || `Expected a ${struct.type} greater than ${exclusive ? '' : 'or equal to '}${threshold} but received \`${value}\``; | ||
}); | ||
@@ -1171,3 +1161,3 @@ } | ||
const size = getSize(value); | ||
return size > 0 || "Expected a nonempty " + struct.type + " but received an empty one"; | ||
return size > 0 || `Expected a nonempty ${struct.type} but received an empty one`; | ||
}); | ||
@@ -1181,3 +1171,3 @@ } | ||
return refine(struct, 'pattern', value => { | ||
return regexp.test(value) || "Expected a " + struct.type + " matching `/" + regexp.source + "/` but received \"" + value + "\""; | ||
return regexp.test(value) || `Expected a ${struct.type} matching \`/${regexp.source}/\` but received "${value}"`; | ||
}); | ||
@@ -1194,7 +1184,7 @@ } | ||
const expected = "Expected a " + struct.type; | ||
const of = min === max ? "of `" + min + "`" : "between `" + min + "` and `" + max + "`"; | ||
const expected = `Expected a ${struct.type}`; | ||
const of = min === max ? `of \`${min}\`` : `between \`${min}\` and \`${max}\``; | ||
return refine(struct, 'size', value => { | ||
if (typeof value === 'number' || value instanceof Date) { | ||
return min <= value && value <= max || expected + " " + of + " but received `" + value + "`"; | ||
return min <= value && value <= max || `${expected} ${of} but received \`${value}\``; | ||
} else if (value instanceof Map || value instanceof Set) { | ||
@@ -1204,3 +1194,3 @@ const { | ||
} = value; | ||
return min <= size && size <= max || expected + " with a size " + of + " but received one with a size of `" + size + "`"; | ||
return min <= size && size <= max || `${expected} with a size ${of} but received one with a size of \`${size}\``; | ||
} else { | ||
@@ -1210,3 +1200,3 @@ const { | ||
} = value; | ||
return min <= length && length <= max || expected + " with a length " + of + " but received one with a length of `" + length + "`"; | ||
return min <= length && length <= max || `${expected} with a length ${of} but received one with a length of \`${length}\``; | ||
} | ||
@@ -1213,0 +1203,0 @@ }); |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).Superstruct={})}(this,(function(e){"use strict";class t extends TypeError{constructor(e,t){let n;const{message:r,...i}=e,{path:o}=e;super(0===o.length?r:"At path: "+o.join(".")+" -- "+r),this.value=void 0,this.key=void 0,this.type=void 0,this.refinement=void 0,this.path=void 0,this.branch=void 0,this.failures=void 0,Object.assign(this,i),this.name=this.constructor.name,this.failures=()=>{var r;return null!=(r=n)?r:n=[e,...t()]}}}function n(e){return"object"==typeof e&&null!=e}function r(e){if("[object Object]"!==Object.prototype.toString.call(e))return!1;const t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}function i(e){return"string"==typeof e?JSON.stringify(e):""+e}function o(e,t,n,r){if(!0===e)return;!1===e?e={}:"string"==typeof e&&(e={message:e});const{path:o,branch:c}=t,{type:a}=n,{refinement:s,message:u="Expected a value of type `"+a+"`"+(s?" with refinement `"+s+"`":"")+", but received: `"+i(r)+"`"}=e;return{value:r,type:a,refinement:s,key:o[o.length-1],path:o,branch:c,...e,message:u}}function*c(e,t,r,i){var c;n(c=e)&&"function"==typeof c[Symbol.iterator]||(e=[e]);for(const n of e){const e=o(n,t,r,i);e&&(yield e)}}function*a(e,t,r){void 0===r&&(r={});const{path:i=[],branch:o=[e],coerce:c=!1,mask:s=!1}=r,u={path:i,branch:o};if(c&&(e=t.coercer(e,u),s&&"type"!==t.type&&n(t.schema)&&n(e)&&!Array.isArray(e)))for(const n in e)void 0===t.schema[n]&&delete e[n];let f="valid";for(const n of t.validator(e,u))f="not_valid",yield[n,void 0];for(let[r,d,l]of t.entries(e,u)){const t=a(d,l,{path:void 0===r?i:[...i,r],branch:void 0===r?o:[...o,d],coerce:c,mask:s});for(const i of t)i[0]?(f=null!=i[0].refinement?"not_refined":"not_valid",yield[i[0],void 0]):c&&(d=i[1],void 0===r?e=d:e instanceof Map?e.set(r,d):e instanceof Set?e.add(d):n(e)&&(e[r]=d))}if("not_valid"!==f)for(const n of t.refiner(e,u))f="not_refined",yield[n,void 0];"valid"===f&&(yield[void 0,e])}class s{constructor(e){this.TYPE=void 0,this.type=void 0,this.schema=void 0,this.coercer=void 0,this.validator=void 0,this.refiner=void 0,this.entries=void 0;const{type:t,schema:n,validator:r,refiner:i,coercer:o=(e=>e),entries:a=function*(){}}=e;this.type=t,this.schema=n,this.entries=a,this.coercer=o,this.validator=r?(e,t)=>c(r(e,t),t,this,e):()=>[],this.refiner=i?(e,t)=>c(i(e,t),t,this,e):()=>[]}assert(e){return u(e,this)}create(e){return f(e,this)}is(e){return l(e,this)}mask(e){return d(e,this)}validate(e,t){return void 0===t&&(t={}),p(e,this,t)}}function u(e,t){const n=p(e,t);if(n[0])throw n[0]}function f(e,t){const n=p(e,t,{coerce:!0});if(n[0])throw n[0];return n[1]}function d(e,t){const n=p(e,t,{coerce:!0,mask:!0});if(n[0])throw n[0];return n[1]}function l(e,t){return!p(e,t)[0]}function p(e,n,r){void 0===r&&(r={});const i=a(e,n,r),o=function(e){const{done:t,value:n}=e.next();return t?void 0:n}(i);if(o[0]){return[new t(o[0],(function*(){for(const e of i)e[0]&&(yield e[0])})),void 0]}return[void 0,o[1]]}function y(e,t){return new s({type:e,schema:null,validator:t})}function v(){return y("never",(()=>!1))}function h(e){const t=e?Object.keys(e):[],r=v();return new s({type:"object",schema:e||null,*entries(i){if(e&&n(i)){const n=new Set(Object.keys(i));for(const r of t)n.delete(r),yield[r,i[r],e[r]];for(const e of n)yield[e,i[e],r]}},validator:e=>n(e)||"Expected an object, but received: "+i(e),coercer:e=>n(e)?{...e}:e})}function m(e){return new s({...e,validator:(t,n)=>void 0===t||e.validator(t,n),refiner:(t,n)=>void 0===t||e.refiner(t,n)})}function b(){return y("string",(e=>"string"==typeof e||"Expected a string, but received: "+i(e)))}function g(e){const t=Object.keys(e);return new s({type:"type",schema:e,*entries(r){if(n(r))for(const n of t)yield[n,r[n],e[n]]},validator:e=>n(e)||"Expected an object, but received: "+i(e)})}function w(){return y("unknown",(()=>!0))}function x(e,t,n){return new s({...e,coercer:(r,i)=>l(r,t)?e.coercer(n(r,i),i):e.coercer(r,i)})}function E(e){return e instanceof Map||e instanceof Set?e.size:e.length}function j(e,t,n){return new s({...e,*refiner(r,i){yield*e.refiner(r,i);const o=c(n(r,i),i,e,r);for(const e of o)yield{...e,refinement:t}}})}e.Struct=s,e.StructError=t,e.any=function(){return y("any",(()=>!0))},e.array=function(e){return new s({type:"array",schema:e,*entries(t){if(e&&Array.isArray(t))for(const[n,r]of t.entries())yield[n,r,e]},coercer:e=>Array.isArray(e)?e.slice():e,validator:e=>Array.isArray(e)||"Expected an array value, but received: "+i(e)})},e.assert=u,e.assign=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];const r="type"===t[0].type,i=t.map((e=>e.schema)),o=Object.assign({},...i);return r?g(o):h(o)},e.bigint=function(){return y("bigint",(e=>"bigint"==typeof e))},e.boolean=function(){return y("boolean",(e=>"boolean"==typeof e))},e.coerce=x,e.create=f,e.date=function(){return y("date",(e=>e instanceof Date&&!isNaN(e.getTime())||"Expected a valid `Date` object, but received: "+i(e)))},e.defaulted=function(e,t,n){return void 0===n&&(n={}),x(e,w(),(e=>{const i="function"==typeof t?t():t;if(void 0===e)return i;if(!n.strict&&r(e)&&r(i)){const t={...e};let n=!1;for(const e in i)void 0===t[e]&&(t[e]=i[e],n=!0);if(n)return t}return e}))},e.define=y,e.deprecated=function(e,t){return new s({...e,refiner:(t,n)=>void 0===t||e.refiner(t,n),validator:(n,r)=>void 0===n||(t(n,r),e.validator(n,r))})},e.dynamic=function(e){return new s({type:"dynamic",schema:null,*entries(t,n){const r=e(t,n);yield*r.entries(t,n)},validator:(t,n)=>e(t,n).validator(t,n),coercer:(t,n)=>e(t,n).coercer(t,n),refiner:(t,n)=>e(t,n).refiner(t,n)})},e.empty=function(e){return j(e,"empty",(t=>{const n=E(t);return 0===n||"Expected an empty "+e.type+" but received one with a size of `"+n+"`"}))},e.enums=function(e){const t={},n=e.map((e=>i(e))).join();for(const n of e)t[n]=n;return new s({type:"enums",schema:t,validator:t=>e.includes(t)||"Expected one of `"+n+"`, but received: "+i(t)})},e.func=function(){return y("func",(e=>"function"==typeof e||"Expected a function, but received: "+i(e)))},e.instance=function(e){return y("instance",(t=>t instanceof e||"Expected a `"+e.name+"` instance, but received: "+i(t)))},e.integer=function(){return y("integer",(e=>"number"==typeof e&&!isNaN(e)&&Number.isInteger(e)||"Expected an integer, but received: "+i(e)))},e.intersection=function(e){return new s({type:"intersection",schema:null,*entries(t,n){for(const r of e)yield*r.entries(t,n)},*validator(t,n){for(const r of e)yield*r.validator(t,n)},*refiner(t,n){for(const r of e)yield*r.refiner(t,n)}})},e.is=l,e.lazy=function(e){let t;return new s({type:"lazy",schema:null,*entries(n,r){null!=t||(t=e()),yield*t.entries(n,r)},validator:(n,r)=>(null!=t||(t=e()),t.validator(n,r)),coercer:(n,r)=>(null!=t||(t=e()),t.coercer(n,r)),refiner:(n,r)=>(null!=t||(t=e()),t.refiner(n,r))})},e.literal=function(e){const t=i(e),n=typeof e;return new s({type:"literal",schema:"string"===n||"number"===n||"boolean"===n?e:null,validator:n=>n===e||"Expected the literal `"+t+"`, but received: "+i(n)})},e.map=function(e,t){return new s({type:"map",schema:null,*entries(n){if(e&&t&&n instanceof Map)for(const[r,i]of n.entries())yield[r,r,e],yield[r,i,t]},coercer:e=>e instanceof Map?new Map(e):e,validator:e=>e instanceof Map||"Expected a `Map` object, but received: "+i(e)})},e.mask=d,e.max=function(e,t,n){void 0===n&&(n={});const{exclusive:r}=n;return j(e,"max",(n=>r?n<t:n<=t||"Expected a "+e.type+" less than "+(r?"":"or equal to ")+t+" but received `"+n+"`"))},e.min=function(e,t,n){void 0===n&&(n={});const{exclusive:r}=n;return j(e,"min",(n=>r?n>t:n>=t||"Expected a "+e.type+" greater than "+(r?"":"or equal to ")+t+" but received `"+n+"`"))},e.never=v,e.nonempty=function(e){return j(e,"nonempty",(t=>E(t)>0||"Expected a nonempty "+e.type+" but received an empty one"))},e.nullable=function(e){return new s({...e,validator:(t,n)=>null===t||e.validator(t,n),refiner:(t,n)=>null===t||e.refiner(t,n)})},e.number=function(){return y("number",(e=>"number"==typeof e&&!isNaN(e)||"Expected a number, but received: "+i(e)))},e.object=h,e.omit=function(e,t){const{schema:n}=e,r={...n};for(const e of t)delete r[e];switch(e.type){case"type":return g(r);default:return h(r)}},e.optional=m,e.partial=function(e){const t=e instanceof s?{...e.schema}:{...e};for(const e in t)t[e]=m(t[e]);return h(t)},e.pattern=function(e,t){return j(e,"pattern",(n=>t.test(n)||"Expected a "+e.type+" matching `/"+t.source+'/` but received "'+n+'"'))},e.pick=function(e,t){const{schema:n}=e,r={};for(const e of t)r[e]=n[e];return h(r)},e.record=function(e,t){return new s({type:"record",schema:null,*entries(r){if(n(r))for(const n in r){const i=r[n];yield[n,n,e],yield[n,i,t]}},validator:e=>n(e)||"Expected an object, but received: "+i(e)})},e.refine=j,e.regexp=function(){return y("regexp",(e=>e instanceof RegExp))},e.set=function(e){return new s({type:"set",schema:null,*entries(t){if(e&&t instanceof Set)for(const n of t)yield[n,n,e]},coercer:e=>e instanceof Set?new Set(e):e,validator:e=>e instanceof Set||"Expected a `Set` object, but received: "+i(e)})},e.size=function(e,t,n){void 0===n&&(n=t);const r="Expected a "+e.type,i=t===n?"of `"+t+"`":"between `"+t+"` and `"+n+"`";return j(e,"size",(e=>{if("number"==typeof e||e instanceof Date)return t<=e&&e<=n||r+" "+i+" but received `"+e+"`";if(e instanceof Map||e instanceof Set){const{size:o}=e;return t<=o&&o<=n||r+" with a size "+i+" but received one with a size of `"+o+"`"}{const{length:o}=e;return t<=o&&o<=n||r+" with a length "+i+" but received one with a length of `"+o+"`"}}))},e.string=b,e.struct=function(e,t){return console.warn("superstruct@0.11 - The `struct` helper has been renamed to `define`."),y(e,t)},e.trimmed=function(e){return x(e,b(),(e=>e.trim()))},e.tuple=function(e){const t=v();return new s({type:"tuple",schema:null,*entries(n){if(Array.isArray(n)){const r=Math.max(e.length,n.length);for(let i=0;i<r;i++)yield[i,n[i],e[i]||t]}},validator:e=>Array.isArray(e)||"Expected an array, but received: "+i(e)})},e.type=g,e.union=function(e){const t=e.map((e=>e.type)).join(" | ");return new s({type:"union",schema:null,coercer:(t,n)=>(e.find((e=>{const[n]=e.validate(t,{coerce:!0});return!n}))||w()).coercer(t,n),validator(n,r){const o=[];for(const t of e){const[...e]=a(n,t,r),[i]=e;if(!i[0])return[];for(const[t]of e)t&&o.push(t)}return["Expected the value to satisfy a union of `"+t+"`, but received: "+i(n),...o]}})},e.unknown=w,e.validate=p,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).Superstruct={})}(this,(function(e){"use strict";class t extends TypeError{constructor(e,t){let n;const{message:r,...i}=e,{path:o}=e;super(0===o.length?r:`At path: ${o.join(".")} -- ${r}`),this.value=void 0,this.key=void 0,this.type=void 0,this.refinement=void 0,this.path=void 0,this.branch=void 0,this.failures=void 0,Object.assign(this,i),this.name=this.constructor.name,this.failures=()=>n??=[e,...t()]}}function n(e){return"object"==typeof e&&null!=e}function r(e){if("[object Object]"!==Object.prototype.toString.call(e))return!1;const t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}function i(e){return"string"==typeof e?JSON.stringify(e):`${e}`}function o(e,t,n,r){if(!0===e)return;!1===e?e={}:"string"==typeof e&&(e={message:e});const{path:o,branch:c}=t,{type:a}=n,{refinement:s,message:u=`Expected a value of type \`${a}\`${s?` with refinement \`${s}\``:""}, but received: \`${i(r)}\``}=e;return{value:r,type:a,refinement:s,key:o[o.length-1],path:o,branch:c,...e,message:u}}function*c(e,t,r,i){var c;n(c=e)&&"function"==typeof c[Symbol.iterator]||(e=[e]);for(const n of e){const e=o(n,t,r,i);e&&(yield e)}}function*a(e,t,r){void 0===r&&(r={});const{path:i=[],branch:o=[e],coerce:c=!1,mask:s=!1}=r,u={path:i,branch:o};if(c&&(e=t.coercer(e,u),s&&"type"!==t.type&&n(t.schema)&&n(e)&&!Array.isArray(e)))for(const n in e)void 0===t.schema[n]&&delete e[n];let f="valid";for(const n of t.validator(e,u))f="not_valid",yield[n,void 0];for(let[r,d,l]of t.entries(e,u)){const t=a(d,l,{path:void 0===r?i:[...i,r],branch:void 0===r?o:[...o,d],coerce:c,mask:s});for(const i of t)i[0]?(f=null!=i[0].refinement?"not_refined":"not_valid",yield[i[0],void 0]):c&&(d=i[1],void 0===r?e=d:e instanceof Map?e.set(r,d):e instanceof Set?e.add(d):n(e)&&void 0!==d&&(e[r]=d))}if("not_valid"!==f)for(const n of t.refiner(e,u))f="not_refined",yield[n,void 0];"valid"===f&&(yield[void 0,e])}class s{constructor(e){this.TYPE=void 0,this.type=void 0,this.schema=void 0,this.coercer=void 0,this.validator=void 0,this.refiner=void 0,this.entries=void 0;const{type:t,schema:n,validator:r,refiner:i,coercer:o=(e=>e),entries:a=function*(){}}=e;this.type=t,this.schema=n,this.entries=a,this.coercer=o,this.validator=r?(e,t)=>c(r(e,t),t,this,e):()=>[],this.refiner=i?(e,t)=>c(i(e,t),t,this,e):()=>[]}assert(e){return u(e,this)}create(e){return f(e,this)}is(e){return l(e,this)}mask(e){return d(e,this)}validate(e,t){return void 0===t&&(t={}),p(e,this,t)}}function u(e,t){const n=p(e,t);if(n[0])throw n[0]}function f(e,t){const n=p(e,t,{coerce:!0});if(n[0])throw n[0];return n[1]}function d(e,t){const n=p(e,t,{coerce:!0,mask:!0});if(n[0])throw n[0];return n[1]}function l(e,t){return!p(e,t)[0]}function p(e,n,r){void 0===r&&(r={});const i=a(e,n,r),o=function(e){const{done:t,value:n}=e.next();return t?void 0:n}(i);if(o[0]){return[new t(o[0],(function*(){for(const e of i)e[0]&&(yield e[0])})),void 0]}return[void 0,o[1]]}function y(e,t){return new s({type:e,schema:null,validator:t})}function v(){return y("never",(()=>!1))}function h(e){const t=e?Object.keys(e):[],r=v();return new s({type:"object",schema:e||null,*entries(i){if(e&&n(i)){const n=new Set(Object.keys(i));for(const r of t)n.delete(r),yield[r,i[r],e[r]];for(const e of n)yield[e,i[e],r]}},validator:e=>n(e)||`Expected an object, but received: ${i(e)}`,coercer:e=>n(e)?{...e}:e})}function m(e){return new s({...e,validator:(t,n)=>void 0===t||e.validator(t,n),refiner:(t,n)=>void 0===t||e.refiner(t,n)})}function b(){return y("string",(e=>"string"==typeof e||`Expected a string, but received: ${i(e)}`))}function $(e){const t=Object.keys(e);return new s({type:"type",schema:e,*entries(r){if(n(r))for(const n of t)yield[n,r[n],e[n]]},validator:e=>n(e)||`Expected an object, but received: ${i(e)}`})}function g(){return y("unknown",(()=>!0))}function w(e,t,n){return new s({...e,coercer:(r,i)=>l(r,t)?e.coercer(n(r,i),i):e.coercer(r,i)})}function x(e){return e instanceof Map||e instanceof Set?e.size:e.length}function E(e,t,n){return new s({...e,*refiner(r,i){yield*e.refiner(r,i);const o=c(n(r,i),i,e,r);for(const e of o)yield{...e,refinement:t}}})}e.Struct=s,e.StructError=t,e.any=function(){return y("any",(()=>!0))},e.array=function(e){return new s({type:"array",schema:e,*entries(t){if(e&&Array.isArray(t))for(const[n,r]of t.entries())yield[n,r,e]},coercer:e=>Array.isArray(e)?e.slice():e,validator:e=>Array.isArray(e)||`Expected an array value, but received: ${i(e)}`})},e.assert=u,e.assign=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];const r="type"===t[0].type,i=t.map((e=>e.schema)),o=Object.assign({},...i);return r?$(o):h(o)},e.bigint=function(){return y("bigint",(e=>"bigint"==typeof e))},e.boolean=function(){return y("boolean",(e=>"boolean"==typeof e))},e.coerce=w,e.create=f,e.date=function(){return y("date",(e=>e instanceof Date&&!isNaN(e.getTime())||`Expected a valid \`Date\` object, but received: ${i(e)}`))},e.defaulted=function(e,t,n){return void 0===n&&(n={}),w(e,g(),(e=>{const i="function"==typeof t?t():t;if(void 0===e)return i;if(!n.strict&&r(e)&&r(i)){const t={...e};let n=!1;for(const e in i)void 0===t[e]&&(t[e]=i[e],n=!0);if(n)return t}return e}))},e.define=y,e.deprecated=function(e,t){return new s({...e,refiner:(t,n)=>void 0===t||e.refiner(t,n),validator:(n,r)=>void 0===n||(t(n,r),e.validator(n,r))})},e.dynamic=function(e){return new s({type:"dynamic",schema:null,*entries(t,n){const r=e(t,n);yield*r.entries(t,n)},validator:(t,n)=>e(t,n).validator(t,n),coercer:(t,n)=>e(t,n).coercer(t,n),refiner:(t,n)=>e(t,n).refiner(t,n)})},e.empty=function(e){return E(e,"empty",(t=>{const n=x(t);return 0===n||`Expected an empty ${e.type} but received one with a size of \`${n}\``}))},e.enums=function(e){const t={},n=e.map((e=>i(e))).join();for(const n of e)t[n]=n;return new s({type:"enums",schema:t,validator:t=>e.includes(t)||`Expected one of \`${n}\`, but received: ${i(t)}`})},e.func=function(){return y("func",(e=>"function"==typeof e||`Expected a function, but received: ${i(e)}`))},e.instance=function(e){return y("instance",(t=>t instanceof e||`Expected a \`${e.name}\` instance, but received: ${i(t)}`))},e.integer=function(){return y("integer",(e=>"number"==typeof e&&!isNaN(e)&&Number.isInteger(e)||`Expected an integer, but received: ${i(e)}`))},e.intersection=function(e){return new s({type:"intersection",schema:null,*entries(t,n){for(const r of e)yield*r.entries(t,n)},*validator(t,n){for(const r of e)yield*r.validator(t,n)},*refiner(t,n){for(const r of e)yield*r.refiner(t,n)}})},e.is=l,e.lazy=function(e){let t;return new s({type:"lazy",schema:null,*entries(n,r){t??=e(),yield*t.entries(n,r)},validator:(n,r)=>(t??=e(),t.validator(n,r)),coercer:(n,r)=>(t??=e(),t.coercer(n,r)),refiner:(n,r)=>(t??=e(),t.refiner(n,r))})},e.literal=function(e){const t=i(e),n=typeof e;return new s({type:"literal",schema:"string"===n||"number"===n||"boolean"===n?e:null,validator:n=>n===e||`Expected the literal \`${t}\`, but received: ${i(n)}`})},e.map=function(e,t){return new s({type:"map",schema:null,*entries(n){if(e&&t&&n instanceof Map)for(const[r,i]of n.entries())yield[r,r,e],yield[r,i,t]},coercer:e=>e instanceof Map?new Map(e):e,validator:e=>e instanceof Map||`Expected a \`Map\` object, but received: ${i(e)}`})},e.mask=d,e.max=function(e,t,n){void 0===n&&(n={});const{exclusive:r}=n;return E(e,"max",(n=>r?n<t:n<=t||`Expected a ${e.type} less than ${r?"":"or equal to "}${t} but received \`${n}\``))},e.min=function(e,t,n){void 0===n&&(n={});const{exclusive:r}=n;return E(e,"min",(n=>r?n>t:n>=t||`Expected a ${e.type} greater than ${r?"":"or equal to "}${t} but received \`${n}\``))},e.never=v,e.nonempty=function(e){return E(e,"nonempty",(t=>x(t)>0||`Expected a nonempty ${e.type} but received an empty one`))},e.nullable=function(e){return new s({...e,validator:(t,n)=>null===t||e.validator(t,n),refiner:(t,n)=>null===t||e.refiner(t,n)})},e.number=function(){return y("number",(e=>"number"==typeof e&&!isNaN(e)||`Expected a number, but received: ${i(e)}`))},e.object=h,e.omit=function(e,t){const{schema:n}=e,r={...n};for(const e of t)delete r[e];return"type"===e.type?$(r):h(r)},e.optional=m,e.partial=function(e){const t=e instanceof s?{...e.schema}:{...e};for(const e in t)t[e]=m(t[e]);return h(t)},e.pattern=function(e,t){return E(e,"pattern",(n=>t.test(n)||`Expected a ${e.type} matching \`/${t.source}/\` but received "${n}"`))},e.pick=function(e,t){const{schema:n}=e,r={};for(const e of t)r[e]=n[e];return h(r)},e.record=function(e,t){return new s({type:"record",schema:null,*entries(r){if(n(r))for(const n in r){const i=r[n];yield[n,n,e],yield[n,i,t]}},validator:e=>n(e)||`Expected an object, but received: ${i(e)}`})},e.refine=E,e.regexp=function(){return y("regexp",(e=>e instanceof RegExp))},e.set=function(e){return new s({type:"set",schema:null,*entries(t){if(e&&t instanceof Set)for(const n of t)yield[n,n,e]},coercer:e=>e instanceof Set?new Set(e):e,validator:e=>e instanceof Set||`Expected a \`Set\` object, but received: ${i(e)}`})},e.size=function(e,t,n){void 0===n&&(n=t);const r=`Expected a ${e.type}`,i=t===n?`of \`${t}\``:`between \`${t}\` and \`${n}\``;return E(e,"size",(e=>{if("number"==typeof e||e instanceof Date)return t<=e&&e<=n||`${r} ${i} but received \`${e}\``;if(e instanceof Map||e instanceof Set){const{size:o}=e;return t<=o&&o<=n||`${r} with a size ${i} but received one with a size of \`${o}\``}{const{length:o}=e;return t<=o&&o<=n||`${r} with a length ${i} but received one with a length of \`${o}\``}}))},e.string=b,e.struct=function(e,t){return console.warn("superstruct@0.11 - The `struct` helper has been renamed to `define`."),y(e,t)},e.trimmed=function(e){return w(e,b(),(e=>e.trim()))},e.tuple=function(e){const t=v();return new s({type:"tuple",schema:null,*entries(n){if(Array.isArray(n)){const r=Math.max(e.length,n.length);for(let i=0;i<r;i++)yield[i,n[i],e[i]||t]}},validator:e=>Array.isArray(e)||`Expected an array, but received: ${i(e)}`})},e.type=$,e.union=function(e){const t=e.map((e=>e.type)).join(" | ");return new s({type:"union",schema:null,coercer:(t,n)=>(e.find((e=>{const[n]=e.validate(t,{coerce:!0});return!n}))||g()).coercer(t,n),validator(n,r){const o=[];for(const t of e){const[...e]=a(n,t,r),[i]=e;if(!i[0])return[];for(const[t]of e)t&&o.push(t)}return[`Expected the value to satisfy a union of \`${t}\`, but received: ${i(n)}`,...o]}})},e.unknown=g,e.validate=p,Object.defineProperty(e,"__esModule",{value:!0})})); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
596758
51
7814
231
34