@amazon/vinyl-validation 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{docs/VALIDATION.md → README.md} +50 -91
- package/dist/index.cjs +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/types/current/tsconfig.tsbuildinfo +1 -1
- package/dist/types/current/validation/FunctionSchema.js +1 -1
- package/dist/types/current/validation/ObjectSchema.d.ts +2 -2
- package/dist/types/current/validation/ObjectSchema.d.ts.map +1 -1
- package/dist/types/current/validation/PropertyValidator.d.ts +1 -1
- package/dist/types/current/validation/PropertyValidator.d.ts.map +1 -1
- package/dist/types/ts3.7/validation/ObjectSchema.d.ts +2 -2
- package/dist/types/ts3.7/validation/PropertyValidator.d.ts +1 -1
- package/dist/types/ts4.1/validation/ObjectSchema.d.ts +2 -2
- package/dist/types/ts4.1/validation/PropertyValidator.d.ts +1 -1
- package/dist/types/ts4.7/validation/ObjectSchema.d.ts +2 -2
- package/dist/types/ts4.7/validation/PropertyValidator.d.ts +1 -1
- package/dist/unit/types/current/tsconfig.tsbuildinfo +1 -0
- package/package.json +8 -11
package/dist/index.cjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/index.ts", "../src/validation/validators.ts", "../src/validation/ArraySchema.ts", "../src/validation/andValidators.ts", "../src/validation/Validator.ts", "../src/validation/orValidators.ts", "../src/validation/SchemaBase.ts", "../src/validation/ValueSchema.ts", "../src/validation/FunctionSchema.ts", "../src/validation/typeOfValidators.ts", "../src/validation/SetSchema.ts", "../src/validation/NumberSchema.ts", "../src/validation/ObjectSchema.ts", "../src/validation/ValidatorWithPartial.ts", "../src/validation/RecordSchema.ts", "../src/validation/StringSchema.ts"],
|
|
4
|
-
"sourcesContent": ["/** Auto-generated from build scripts */\nexport * from './validation/validators'\nexport * from './validation/typeOfValidators'\nexport * from './validation/orValidators'\nexport * from './validation/andValidators'\nexport * from './validation/ValueSchema'\nexport * from './validation/ValidatorWithPartial'\nexport * from './validation/Validator'\nexport * from './validation/StringSchema'\nexport * from './validation/SetSchema'\nexport * from './validation/SchemaBase'\nexport * from './validation/RecordSchema'\nexport * from './validation/PropertyValidator'\nexport * from './validation/ObjectSchema'\nexport * from './validation/NumberSchema'\nexport * from './validation/FunctionSchema'\nexport * from './validation/ArraySchema'\n", "/*\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport {\n type AnyRecord,\n type Fun,\n type Primitive,\n type ReadonlyRecord,\n stringifyForPrint,\n substitute,\n} from '@amazon/vinyl-util'\nimport { ArraySchema } from './ArraySchema'\nimport { FunctionSchema } from './FunctionSchema'\nimport { SetSchema } from './SetSchema'\nimport { ValueSchema, valueValidators } from './ValueSchema'\nimport { NumberSchema } from './NumberSchema'\nimport { type ExtendedPropertyValidators, ObjectSchema } from './ObjectSchema'\nimport { RecordSchema } from './RecordSchema'\nimport { StringSchema } from './StringSchema'\nimport { typeOfValidators } from './typeOfValidators'\nimport type { Validator } from './Validator'\nimport { createValidator } from './Validator'\n\n/**\n * @private\n */\nconst locale = {\n isOneOf: 'one of: {value}',\n instanceOf: 'instance of {value}',\n oneOfSeparator: ' | ',\n} as const\n\n/**\n * Creates a no-op validator. The value can be any type.\n */\nexport function any(): ValueSchema<any> {\n return new ValueSchema(valueValidators.any())\n}\n\n/**\n * Creates a validator that asserts that the input is an array.\n */\nexport function array(): ArraySchema<unknown[]>\n\n/**\n * Creates a validator that asserts that the input is an array and every element passes the\n * given validator.\n *\n * @param elementValidator\n */\nexport function array<U>(elementValidator: Validator<U>): ArraySchema<U[]>\n\nexport function array(\n elementValidator?: Validator<any>\n): ArraySchema<unknown[]> {\n if (!elementValidator) return ArraySchema.base\n else return ArraySchema.base.withElements(elementValidator)\n}\n\n/**\n * Creates a validator that asserts that the input is a boolean.\n */\nexport function boolean(): ValueSchema<boolean> {\n return new ValueSchema(typeOfValidators.boolean)\n}\n\n/**\n * Creates a validator that asserts that the input is a function.\n */\nexport function func(): FunctionSchema<Fun> {\n return FunctionSchema.base\n}\n\n/**\n * Validates that the input is an instanceof the given prototype.\n * @param clazz\n */\nexport function instanceOf<const T>(\n clazz: new (...args: any[]) => T\n): ValueSchema<T> {\n return new ValueSchema(\n createValidator(\n substitute(locale.instanceOf, { value: clazz.name }),\n (input) => input instanceof clazz\n )\n )\n}\n\n/**\n * Creates a validator that asserts that the input is nullish or one of the given possible values.\n *\n * @param possibleValues\n */\nexport function isOneOf<const U extends readonly Primitive[]>(\n ...possibleValues: U\n): ValueSchema<U[number]> {\n return new ValueSchema(\n createValidator(\n substitute(locale.isOneOf, {\n value: possibleValues.join(locale.oneOfSeparator),\n }),\n (input) => possibleValues.includes(input as U[number])\n )\n )\n}\n\n/**\n * Creates a validator that asserts that the input is one of the values of the given enum.\n *\n * @param enumObject The enum to validate against.\n */\nexport function enumOf<const T extends Record<string, Primitive>>(\n enumObject: T\n): ValueSchema<T[keyof T]> {\n return isOneOf(...Object.values(enumObject)) as unknown as ValueSchema<\n T[keyof T]\n >\n}\n\n/**\n * Creates a validator that asserts that the input is null.\n */\nexport function exactlyNull(): Validator<null> {\n return valueValidators.null()\n}\n\n/**\n * Creates a validator that asserts that the input is nullish.\n */\nexport function nullish(): Validator<null | undefined> {\n return valueValidators.nullish()\n}\n\n/**\n * Creates a validator that asserts that the input is a number.\n */\nexport function number(): NumberSchema {\n return NumberSchema.base\n}\n\n/**\n * Creates a validator that validates the input has properties that pass their respective\n * validators.\n */\nexport function object<const U extends object>(\n propertyValidators: NoInfer<ExtendedPropertyValidators<AnyRecord, U>>\n): ObjectSchema<U> {\n return ObjectSchema.base.extend<U>(propertyValidators)\n}\n\n/**\n * Returns a validator that asserts that the object's own enumerable properties has keys and\n * values that match their respective validators.\n *\n * Prototype members are not included.\n * Numeric keys are validated as strings. For example the object `{ [0]: 1 }` will be passed\n * to the key validator as '0'.\n *\n * To assume string keys, use {@link recordValues}\n *\n * @param keyValidator Validates each key.\n * @param valueValidator Validates each value.\n */\nexport function record<const K extends string | symbol, const V>(\n keyValidator: Validator<K>,\n valueValidator: Validator<V>\n): RecordSchema<ReadonlyRecord<K, V>> {\n return RecordSchema.base.record(keyValidator, valueValidator)\n}\n\n/**\n * Returns a validator that asserts that the input object's own enumerable properties has\n * string keys and values that match the given validator.\n *\n * Prototype members are not included.\n *\n * @param valueValidator Validates each value.\n */\nexport function recordValues<const V>(\n valueValidator: Validator<V>\n): RecordSchema<Record<string, V>> {\n return RecordSchema.base.recordValues(valueValidator)\n}\n\n/**\n * Returns a validator that asserts the input is a set with elements that match the given\n * element validator.\n * @param elementValidator\n */\nexport function set<const U>(\n elementValidator: Validator<U>\n): SetSchema<Set<U>> {\n return SetSchema.base.withElements(elementValidator)\n}\n\n/**\n * Creates a validator that asserts that the input is type 'string'.\n */\nexport function string(): StringSchema {\n return StringSchema.base\n}\n\n/**\n * Creates a validator that asserts that the input array is a tuple whose elements match\n * the given validators.\n *\n * @param validators\n */\nexport function tuple<U extends readonly any[]>(\n ...validators: {\n [Index in keyof U]: Validator<U[Index]>\n }\n): ArraySchema<{\n [Index in keyof U]: U[Index]\n}> {\n return ArraySchema.base.tuple(...validators)\n}\n\n/**\n * Creates a validator that asserts that the input is type 'symbol'.\n */\nexport function symbol(): ValueSchema<symbol> {\n return new ValueSchema(typeOfValidators.symbol)\n}\n\n/**\n * Creates a validator that asserts that the input is strictly undefined.\n */\nexport function exactlyUndefined(): ValueSchema<undefined> {\n return new ValueSchema(valueValidators.undefined())\n}\n\n/**\n * Returns a custom\n * @param expectationMessage\n * @param isValid\n * @param inputStringify\n */\nexport function custom<T>(\n expectationMessage: string,\n isValid: (input: unknown) => boolean,\n inputStringify: (input: unknown) => string = (input) =>\n stringifyForPrint(input, 500)\n): ValueSchema<T> {\n return new ValueSchema(\n createValidator(expectationMessage, isValid, inputStringify)\n )\n}\n", "/*\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport type { ElementType } from '@amazon/vinyl-util'\nimport { substitute } from '@amazon/vinyl-util'\nimport { ValueSchema } from './ValueSchema'\nimport type { ValidationErrorMessage, Validator } from './Validator'\nimport { createDeepValidator, createValidator } from './Validator'\n\n/**\n * @private\n */\nconst locale = {\n array: 'array',\n minLength: 'at least {value} elements',\n maxLength: 'at most {value} elements',\n exactlyLength: 'exactly {value} elements',\n actualLength: 'length {value}',\n withElements: '({value})[]',\n tuple: '[{value}]',\n} as const\n\nexport const arrayValidators = {\n /**\n * Creates a validator that asserts that the input is an array.\n *\n * Note: arrays can only be readonly by type system, there is no native readonly\n * js array. This validator assumes mutability, use the ArraySchema readonly() method\n * to cast to a readonly array.\n */\n isArray(): Validator<unknown[]> {\n return createValidator(locale.array, (input: unknown) =>\n Array.isArray(input)\n )\n },\n\n /**\n * Creates a validator that asserts that every element passes the given validator.\n *\n * @param elementValidator\n */\n withElements<U>(\n elementValidator: Validator<U>\n ): Validator<U[], readonly unknown[]> {\n return createDeepValidator(\n substitute(locale.withElements, {\n value: elementValidator.description,\n }),\n (input, options, path) => {\n const errors: ValidationErrorMessage[] = []\n for (let i = 0; i < input.length; i++) {\n const element = input[i]\n errors.push(\n ...elementValidator.validate(\n element,\n options,\n path.concat(i.toString())\n )\n )\n if (!options.all && errors.length) return errors\n }\n return errors\n }\n )\n },\n\n /**\n * Creates a validator that asserts that the input array is a tuple whose elements match\n * the given validators.\n *\n * @param validators\n */\n tuple<U extends readonly any[]>(\n ...validators: {\n [Index in keyof U]: Validator<U[Index]>\n }\n ): Validator<\n {\n [Index in keyof U]: U[Index]\n },\n readonly unknown[]\n > {\n const lengthValidator = createValidator(\n substitute(locale.exactlyLength, {\n value: validators.length,\n }),\n (length: number) => length === validators.length\n )\n return createDeepValidator(\n substitute(locale.tuple, { value: validators.join(', ') }),\n (input, options, path) => {\n const errors: ValidationErrorMessage[] = []\n errors.push(\n ...lengthValidator.validate(input.length, options, path)\n )\n if (!options.all && errors.length) return errors\n const n = Math.min(validators.length, input.length)\n for (let i = 0; i < n; i++) {\n const element = input[i]\n const validator = validators[i]\n errors.push(\n ...validator.validate(\n element,\n options,\n path.concat(i.toString())\n )\n )\n if (!options.all && errors.length) return errors\n }\n return errors\n }\n )\n },\n\n /**\n * Creates a validator that validates the input array has the given minimum length.\n * @param min The minimum number of elements (inclusive)\n */\n minLength(min: number): Validator<readonly unknown[], readonly unknown[]> {\n return createValidator(\n substitute(locale.minLength, { value: min }),\n (input) => input.length >= min,\n (input) => substitute(locale.actualLength, { value: input.length })\n )\n },\n\n /**\n *\n * Creates a validator that validates the input array has the given maximum length.\n * @param max The maximum number of elements (inclusive)\n */\n maxLength(max: number): Validator<readonly unknown[], readonly unknown[]> {\n return createValidator(\n substitute(locale.maxLength, { value: max }),\n (input) => input.length <= max,\n (input) => substitute(locale.actualLength, { value: input.length })\n )\n },\n} as const\n\nexport class ArraySchema<T extends readonly unknown[]> extends ValueSchema<T> {\n private static _base: ArraySchema<unknown[]> | null = null\n\n /**\n * The base ArraySchema instance validating that the input is an Array.\n */\n static get base(): ArraySchema<unknown[]> {\n if (this._base == null)\n this._base = new ArraySchema(arrayValidators.isArray())\n return this._base\n }\n\n /**\n * Creates a validator that asserts that every element passes the given validator.\n *\n * @param elementValidator\n */\n withElements<U>(\n elementValidator: Validator<U>\n ): ArraySchema<(ElementType<T> & U)[]> {\n return this.chain(arrayValidators.withElements(elementValidator))\n }\n\n /**\n * Creates a validator that asserts that the input array is a tuple whose elements match\n * the given validators.\n *\n * @param validators\n */\n tuple<U extends readonly any[]>(\n ...validators: {\n [Index in keyof U]: Validator<U[Index]>\n }\n ): ArraySchema<{\n [Index in keyof U]: U[Index]\n }> {\n return this.chain(arrayValidators.tuple(...validators))\n }\n\n /**\n * Creates a validator that validates the input array has the given minimum length.\n * @param min The minimum number of elements (inclusive)\n */\n minLength(min: number): ArraySchema<T> {\n return this.chain(arrayValidators.minLength(min))\n }\n\n /**\n *\n * Creates a validator that validates the input array has the given maximum length.\n * @param max The maximum number of elements (inclusive)\n */\n maxLength(max: number): ArraySchema<T> {\n return this.chain(arrayValidators.maxLength(max))\n }\n\n /**\n * Casts to a readonly array.\n * This is a shallow cast, elements of the array will not be changed.\n */\n readonly(): ArraySchema<Readonly<T>> {\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n return this as any\n }\n\n /**\n * Casts the type parameter.\n */\n cast<T extends readonly unknown[]>(): ArraySchema<T> {\n return this as any\n }\n}\n", "/*\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { substitute } from '@amazon/vinyl-util'\nimport type { Validator } from './Validator'\nimport { createDeepValidator } from './Validator'\n\n/*\n * @brief\n * andValidators will intersect an arbitrary number of validators.\n *\n * While in most cases validating that an input passes two validators, the asserted output is the\n * intersection of those two validator outputs, this is not always the case.\n * For example, take two validators with outputs `A[]` and `B[]`, their combined validated output\n * type would be `(A & B)[]`, not `A[] & B[]`. Use casting when necessary.\n *\n * Also note that there is no contravariance safety with the chained validator inputs. That is,\n * there's no compile-time checking that validatorB accepts an input that is the super of\n * validatorA's output.\n */\n\n/**\n * @private\n */\nconst locale = {\n /**\n * {value} The child validators' descriptions, joined with `separator`.\n *\n * groupings of and validators is unimportant,\n * and(and(a, b), c) is the same as and(a, and(b, c)), so `a & b & c` is an accurate\n * representation for either.\n */\n template: '{value}',\n\n /**\n * The separator with which to join child validator descriptions.\n */\n separator: ' & ',\n} as const\n\n/**\n * Validates that all the given validators pass.\n */\nexport function andValidators<A extends Input, B, Input>(\n validatorA: Validator<A, Input>,\n validatorB: Validator<B, any>\n): Validator<A & B, Input>\n\n/**\n * Validates that all the given validators pass.\n */\nexport function andValidators<A extends Input, B, C, Input>(\n validatorA: Validator<A, Input>,\n validatorB: Validator<B, any>,\n validatorC: Validator<C, any>\n): Validator<A & B & C, Input>\n\n/**\n * Validates that all the given validators pass.\n */\nexport function andValidators<A extends Input, B, C, D, Input>(\n validatorA: Validator<A, Input>,\n validatorB: Validator<B, any>,\n validatorC: Validator<C, any>,\n validatorD: Validator<D, any>\n): Validator<A & B & C & D, any>\n\n/**\n * Validates that all the given validators pass.\n */\nexport function andValidators<A extends Input, B, C, D, E, Input>(\n validatorA: Validator<A, Input>,\n validatorB: Validator<B, any>,\n validatorC: Validator<C, any>,\n validatorD: Validator<D, any>,\n validatorE: Validator<E, any>\n): Validator<A & B & C & D & E, any>\n\nexport function andValidators(\n ...validators: Validator<any, any>[]\n): Validator<any, any>\n\nexport function andValidators(\n ...validators: Validator<any, any>[]\n): Validator<any, any> {\n return createDeepValidator(\n substitute(locale.template, {\n value: validators.map((v) => v.description).join(locale.separator),\n }),\n (input, options, path) => {\n for (const validator of validators) {\n const errors = validator.validate(input, options, path)\n if (errors.length) return errors\n }\n return []\n }\n )\n}\n", "/*\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { type Invariant, ValidationError } from '@amazon/vinyl-util'\nimport { stringifyForPrint, substitute } from '@amazon/vinyl-util'\n\n/**\n * Represents a validation failure.\n */\nexport interface ValidationErrorMessage {\n readonly message: string\n readonly path: readonly string[]\n}\n\nexport interface ValidationOptions {\n /**\n * If true, collect all validation errors.\n * Default: false\n */\n readonly all?: boolean\n}\n\n/**\n * A Validator can assert that an input matches this validator's schema.\n */\nexport interface Validator<Output extends Input, in Input = unknown> {\n /**\n * Enforces T is in an invariant position.\n * This prevents a validator with more strict rules is assigned to a less strict type, which\n * can cause unexpected validation errors.\n */\n __type?: Invariant<Output>\n\n /**\n * A short description of the validator.\n */\n readonly description: string\n\n /**\n * Returns true if the input is valid according to this validator.\n *\n * @param input\n */\n readonly isValid: (input: Input) => input is Output\n\n /**\n * Validates the provided input, returning a list of error messages, or an empty array if the\n * input passes this validator.\n *\n * @param input The input to validate.\n * @param options Validation options.\n * @param path The current field path to this validator.\n * @return Returns an array of validation failures. If `options.all` is not true, only the\n * first error will be returned.\n */\n readonly validate: (\n input: Input,\n options?: ValidationOptions,\n path?: readonly string[]\n ) => readonly ValidationErrorMessage[]\n\n /**\n * Validates the given input, asserting that the input is type `T`.\n * If the input is not valid, a {@link ValidationError} will be thrown.\n *\n * @param input The input to validate.\n * @param origin The error origin. `ErrorOrigin.API` by default.\n * @param path The current field path to this validator.\n * @return Returns the input, cast as the validated type T\n */\n readonly assert: (\n input: Input,\n origin?: string,\n path?: readonly string[]\n ) => asserts input is Output\n}\n\n/**\n * @private\n */\nconst validatorLocale = {\n /**\n * The expectation template string with the following replacement tokens:\n *\n * `{expected}` - The expected description.\n * `{actual}` - The actual value.\n * `{path}` - The path, dot separated.\n */\n template: 'Expected: {expected}, but was: {actual}. At: {path}',\n}\n\n/**\n * Creates a message string for a ValidationErrorMessage based on the input and its expectation.\n *\n * @param expectationMessage\n * @param input\n * @param path\n * @param inputStringify\n */\nexport function createValidationExpectationMessage<Input>(\n expectationMessage: string,\n input: Input,\n path: readonly string[],\n inputStringify: (input: Input) => string = (input) =>\n stringifyForPrint(input, 500)\n): string {\n return substitute(validatorLocale.template, {\n expected: expectationMessage,\n actual: inputStringify(input),\n path: path.join('.'),\n })\n}\n\n/**\n * Creates a new basic validator.\n *\n * For a deep validator which has sub-fields, use {@link createDeepValidator}.\n *\n * @param expectationMessage The message to use to describe what is expected. This will be used in\n * the error message template.\n * @param isValid Returns true if the given input is valid.\n * @param inputStringify Stringifies the input for use as the actual `{actual}` token in the validation\n * expectation template. Default is `stringifyForPrint` with a 500 character max length.\n */\nexport function createValidator<Output extends Input, Input = unknown>(\n expectationMessage: string,\n isValid: (input: Input) => boolean,\n inputStringify: (input: Input) => string = (input) =>\n stringifyForPrint(input, 500)\n): Validator<Output, Input> {\n return {\n description: expectationMessage,\n\n isValid(input: Input): input is Output {\n return isValid(input)\n },\n\n validate(\n input: Input,\n _?: ValidationOptions,\n path: readonly string[] = []\n ): readonly ValidationErrorMessage[] {\n if (!isValid(input)) {\n return [\n {\n message: createValidationExpectationMessage(\n expectationMessage,\n input,\n path,\n inputStringify\n ),\n path,\n },\n ]\n }\n return []\n },\n\n assert: (\n input: Input,\n origin?: string,\n path: readonly string[] = []\n ): asserts input is Output => {\n if (!isValid(input)) {\n throw new ValidationError(\n createValidationExpectationMessage(\n expectationMessage,\n input,\n path,\n inputStringify\n ),\n origin,\n path\n )\n }\n },\n }\n}\n\n/**\n * Creates a new deep validator.\n *\n * For a shallow validator which validates one value, use {@link createValidator}.\n *\n * @param description Describes the validator.\n * @param validate Returns an array of validation failures.\n */\nexport function createDeepValidator<Output extends Input, Input = unknown>(\n description: string,\n validate: (\n input: Input,\n options: ValidationOptions,\n path: readonly string[]\n ) => readonly ValidationErrorMessage[]\n): Validator<Output, Input> {\n return {\n description,\n\n isValid(input: Input): input is Output {\n return validate(input, { all: false }, []).length === 0\n },\n\n validate(\n input: Input,\n options?: ValidationOptions,\n path: readonly string[] = []\n ): readonly ValidationErrorMessage[] {\n return validate(input, options ?? { all: false }, path)\n },\n\n assert: (\n input: Input,\n origin?: string,\n path: readonly string[] = []\n ): asserts input is Output => {\n const errors = validate(input, { all: false }, path)\n if (errors.length) {\n const error = errors[0]\n throw new ValidationError(error.message, origin, error.path)\n }\n },\n }\n}\n", "/*\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { substitute } from '@amazon/vinyl-util'\nimport type { ValidationErrorMessage, Validator } from './Validator'\nimport {\n createDeepValidator,\n createValidationExpectationMessage,\n} from './Validator'\n\n/*\n * @brief\n * orValidators will union an arbitrary number of validators.\n * input type is always type any; it's not strictly necessary for all validators to accept the same\n * input type. For example, if validatorA asserts that a value is not null, validatorB can safely\n * assume its input is not null.\n * output type will be the union of the validator outputs up to 5 validators, 6 or more will be\n * type any.\n */\n\n/**\n * @private\n */\nconst locale = {\n /**\n * {value} - The child validators' descriptions, joined with `separator`.\n */\n template: '({value})',\n\n /**\n * The separator with which to join child validator descriptions.\n */\n separator: ' | ',\n} as const\n\n/**\n * Validates that one of the given validators pass.\n */\nexport function orValidators<A, B>(\n validatorA: Validator<A, any>,\n validatorB: Validator<B, any>\n): Validator<A | B, any>\n\n/**\n * Validates that one of the given validators pass.\n */\nexport function orValidators<A, B, C>(\n validatorA: Validator<A, any>,\n validatorB: Validator<B, any>,\n validatorC: Validator<C, any>\n): Validator<A | B | C, any>\n\n/**\n * Validates that one of the given validators pass.\n */\nexport function orValidators<A, B, C, D>(\n validatorA: Validator<A, any>,\n validatorB: Validator<B, any>,\n validatorC: Validator<C, any>,\n validatorD: Validator<D, any>\n): Validator<A | B | C | D, any>\n\n/**\n * Validates that one of the given validators pass.\n */\nexport function orValidators<A, B, C, D, E>(\n validatorA: Validator<A, any>,\n validatorB: Validator<B, any>,\n validatorC: Validator<C, any>,\n validatorD: Validator<D, any>,\n validatorE: Validator<E, any>\n): Validator<A | B | C | D | E, any>\n\nexport function orValidators(\n ...validators: Validator<any, any>[]\n): Validator<any, any>\n\n/**\n * Validates that one of the given validators pass.\n *\n * If all validators fail, the validator that produced an error at the deepest path will have its\n * error message bubbled. If all validators failed at the current depth, a concatenation of\n * validator descriptions will be used.\n *\n * For example:\n * `orValidators(number(), string()).validate(false)` will produce the message:\n * 'Expected (number | string), but was false, At: '\n *\n * And:\n * `orValidators(number(), object({ childProp: number() })).validate({ childProp: 'not-a-number' })`\n * will produce:\n * 'Expected number, but was \"not-a-number\", At: childProp'\n *\n * @param validators The validators to test.\n */\nexport function orValidators(\n ...validators: Validator<any, any>[]\n): Validator<any, any> {\n const description = substitute(locale.template, {\n value: validators.map((v) => v.description).join(locale.separator),\n })\n\n return createDeepValidator(description, (input, options, path) => {\n let longestErrors: readonly ValidationErrorMessage[] = []\n let longestPath = 0\n for (const validator of validators) {\n const errors = validator.validate(input, options, path)\n if (!errors.length) return errors\n // Take the deepest error to bubble.\n const pathLength = errors.reduce(\n (max, m) => Math.max(m.path.length, max),\n 0\n )\n if (pathLength >= longestPath) {\n longestErrors = errors\n longestPath = pathLength\n }\n }\n return longestPath > path.length\n ? longestErrors\n : [\n {\n message: createValidationExpectationMessage(\n description,\n input,\n path\n ),\n path,\n },\n ]\n })\n}\n", "/*\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { IllegalArgumentError, invariant, type Maybe } from '@amazon/vinyl-util'\nimport { andValidators } from './andValidators'\nimport type {\n ValidationErrorMessage,\n ValidationOptions,\n Validator,\n} from './Validator'\nimport type {\n PropertyValidator,\n PropertyValidatorOptions,\n PropertyValidatorWithOptions,\n} from './PropertyValidator'\n\nconst requiredValidationOptions = {\n optional: false,\n} as const satisfies PropertyValidatorOptions\n\n/**\n * A base class for validation state.\n * Provides methods for chaining.\n *\n * Subclasses should not override constructors.\n */\nexport abstract class SchemaBase<T> implements PropertyValidator<\n T,\n { readonly optional: false }\n> {\n __type = /* @__PURE__ */ invariant<T>()\n\n private readonly validator: Validator<T>\n private _options = requiredValidationOptions\n\n get options() {\n return this._options\n }\n\n /**\n * Constructs the first link in a schema chain.\n *\n * @param currentValidator\n */\n constructor(currentValidator: Validator<any, any>)\n\n /**\n * Constructs linking to the given previous schema.\n *\n * @param currentValidator\n * @param previousSchema\n * @param operation\n */\n constructor(\n currentValidator: Validator<any, any>,\n previousSchema: SchemaBase<any>,\n operation: (\n validatorA: Validator<any>,\n validatorB: Validator<any, any>\n ) => Validator<T>\n )\n\n constructor(\n private readonly currentValidator: Validator<any, any>,\n private readonly previousSchema?: Maybe<SchemaBase<any>>,\n private readonly operation?: Maybe<\n (\n validatorA: Validator<any>,\n validatorB: Validator<any, any>\n ) => Validator<T>\n >\n ) {\n this.validator =\n operation == null\n ? currentValidator\n : operation(previousSchema!, currentValidator)\n }\n\n get description(): string {\n return this.validator.description\n }\n\n readonly assert: (\n input: unknown,\n origin?: string,\n path?: readonly string[]\n ) => asserts input is T = (input, origin?, path?): asserts input is T => {\n this.validator.assert(input, origin, path)\n }\n\n readonly isValid: (input: unknown) => input is T = (\n input: unknown\n ): input is T => this.validator.isValid(input)\n\n readonly validate = (\n input: unknown,\n options?: ValidationOptions,\n path?: readonly string[]\n ): readonly ValidationErrorMessage[] =>\n this.validator.validate(input, options, path)\n\n /**\n * Clones this schema, transforming all validators with the given mutator.\n *\n * @param transform A transformer which takes an existing validator in the chain and returns\n * a new one. Validators should be considered to be immutable; transform should not change the\n * input but instead return a new validator.\n */\n protected clone(\n transform: (validator: Validator<any>) => Validator<any> = (v) => v\n ): any {\n const cloned = this.operation\n ? this.self(\n transform(this.currentValidator),\n this.previousSchema!.clone(transform),\n this.operation\n )\n : this.self(transform(this.currentValidator))\n cloned._options = this._options\n return cloned\n }\n\n protected self(current: Validator<any, any>): any\n\n protected self(\n currentValidator: Validator<any, any>,\n previousSchema: SchemaBase<any> | undefined,\n operation:\n | ((\n validatorA: Validator<any>,\n validatorB: Validator<any, any>\n ) => Validator<T>)\n | undefined\n ): any\n\n protected self(\n current: Validator<any, any>,\n previous?: SchemaBase<any>,\n operation?: (\n validatorA: Validator<any>,\n validatorB: Validator<any, any>\n ) => Validator<T> | undefined\n ): any {\n if (this.constructor.length > 3) {\n throw new IllegalArgumentError(\n 'constructor should have at most three required arguments'\n )\n }\n return new (this.constructor as any)(current, previous, operation)\n }\n\n /**\n * Constructs a new schema with a validator chaining the current validator with the\n * provided next in an AND operation.\n *\n * @param nextValidator The validator to run after the current.\n * @return Returns a new Schema instance the same class with a new validator chaining the\n * current validator with the given next in an AND operation.\n */\n protected chain(nextValidator: Validator<any, any>): any {\n return this.self(nextValidator, this, andValidators)\n }\n\n optional(): PropertyValidatorWithOptions<\n this,\n T,\n { readonly optional: true }\n > {\n const cloned = this.clone()\n cloned._options = {\n ...cloned.options,\n optional: true,\n }\n return cloned\n }\n\n required(): PropertyValidatorWithOptions<\n this,\n T,\n { readonly optional: false }\n > {\n const cloned = this.clone()\n cloned._options = {\n ...cloned.options,\n optional: false,\n }\n return cloned\n }\n}\n", "/*\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { andValidators } from './andValidators'\nimport { orValidators } from './orValidators'\nimport { SchemaBase } from './SchemaBase'\nimport type { Validator } from './Validator'\nimport { createValidator } from './Validator'\n\nconst locale = {\n null: 'null',\n nullish: 'nullish',\n undefined: 'undefined',\n} as const\n\nexport const valueValidators = {\n any(): Validator<any> {\n // no need for localization, validator cannot fail.\n return createValidator('', () => true)\n },\n\n /**\n * Creates a validator that asserts that the input is nullish.\n */\n nullish(): Validator<null | undefined> {\n return createValidator(locale.nullish, (input) => input == null)\n },\n\n /**\n * Creates a validator that asserts that the input is strictly null.\n */\n null(): Validator<null> {\n return createValidator(locale.null, (input) => input === null)\n },\n\n /**\n * Creates a validator that asserts that the input is strictly undefined.\n */\n undefined(): Validator<undefined> {\n return createValidator(locale.undefined, (input) => input === undefined)\n },\n} as const\n\nexport class ValueSchema<T> extends SchemaBase<T> {\n /**\n * Prepends this validator allowing for null or undefined.\n */\n maybe(): ValueSchema<T | undefined | null> {\n return this.or(valueValidators.nullish())\n }\n\n /**\n * Prepends this validator allowing for null.\n */\n orNull(): ValueSchema<T | null> {\n return this.or(valueValidators.null())\n }\n\n /**\n * Prepends this validator allowing for undefined.\n */\n orUndefined(): ValueSchema<T | undefined> {\n return this.or(valueValidators.undefined())\n }\n\n /**\n * Returns a validator that asserts if this validator and the next passes.\n *\n * @see andValidators\n *\n * @param nextValidator The validator to run after the current.\n * @return Returns a new ValueSchema intersecting this validator and the next.\n */\n and<U>(nextValidator: Validator<U>): ValueSchema<T & U> {\n return new ValueSchema(nextValidator, this, andValidators)\n }\n\n /**\n * Returns a validator that asserts if this validator or the next passes.\n *\n * Implementation note:\n * subclasses should not change the schema instance returned unless all chainable validators\n * accept input type 'unknown'.\n *\n * @param nextValidator The validator to run after the current.\n * @return Returns a new ValueSchema providing the union of this validator and the next.\n */\n or<U>(nextValidator: Validator<U, any>): ValueSchema<T | U> {\n return new ValueSchema(nextValidator, this, orValidators)\n }\n}\n", "/*\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport type { Fun } from '@amazon/vinyl-util'\nimport { substitute } from '@amazon/vinyl-util'\nimport { ValueSchema } from './ValueSchema'\nimport type { Validator } from './Validator'\nimport { createValidator } from './Validator'\nimport { typeOfValidators } from '@/validation/typeOfValidators'\n\n/**\n * @private\n */\nconst locale = {\n length: 'at most {value} arguments',\n actualLength: '{value} arguments',\n} as const\n\nexport const functionValidators = {\n length(max: number): Validator<Fun, Fun> {\n return createValidator(\n substitute(locale.length, { value: max }),\n (input) => input.length <= max,\n (input) => substitute(locale.actualLength, { value: input.length })\n )\n },\n} as const\n\nexport class FunctionSchema<T extends Fun> extends ValueSchema<T> {\n private static _base: FunctionSchema<Fun> | null = null\n\n /**\n * The base Function validator validating that the input is a function.\n */\n static get base(): FunctionSchema<Fun> {\n if (this._base == null)\n this._base = new FunctionSchema(typeOfValidators.func)\n return this._base\n }\n\n length(max: number): FunctionSchema<T> {\n return this.chain(functionValidators.length(max))\n }\n\n /**\n * Casts the function signature.\n * Function signatures, except for their required number of parameters, cannot be\n * meaningfully validated.\n */\n cast<T extends Fun>(): FunctionSchema<T> {\n return this as any\n }\n}\n", "/*\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport type { FromTypeof, Typeof } from '@amazon/vinyl-util'\nimport { substitute } from '@amazon/vinyl-util'\nimport type { Validator } from './Validator'\nimport { createValidator } from './Validator'\n\n/**\n * @private\n */\nconst locale = {\n template: 'type {value}',\n} as const\n\n/**\n * Creates a validator that validates that the input is not nullish and its `typeof` matches the\n * expected value.\n *\n * Note: while `typeof null === 'object'`, `typeOfValidator('object')` will assert that its\n * input is not nullish.\n *\n * @param expected\n */\nfunction typeOfValidator<T extends Typeof>(\n expected: T\n): Validator<NonNullable<FromTypeof<T>>> {\n return createValidator(\n substitute(locale.template, { value: expected }),\n (input: unknown): input is NonNullable<FromTypeof<T>> => {\n return input != null && typeof input === expected\n }\n )\n}\n\nconst typeOfValidatorCache: any = {}\n\nfunction cachedTypeOfValidator<T extends Typeof>(\n type: T\n): Validator<NonNullable<FromTypeof<T>>> {\n if (!(type in typeOfValidatorCache)) {\n typeOfValidatorCache[type] = typeOfValidator(type)\n }\n return typeOfValidatorCache[type]\n}\n\n/**\n * Validators asserting typeof input matches the expected value.\n *\n * Note: bigint is omitted; not all supported platforms can use BigInt.\n */\nexport const typeOfValidators = {\n get boolean() {\n return cachedTypeOfValidator('boolean')\n },\n get func() {\n return cachedTypeOfValidator('function')\n },\n get number() {\n return cachedTypeOfValidator('number')\n },\n get object() {\n return cachedTypeOfValidator('object')\n },\n get string() {\n return cachedTypeOfValidator('string')\n },\n get symbol() {\n return cachedTypeOfValidator('symbol')\n },\n} as const\n", "/*\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport type { SetElementType } from '@amazon/vinyl-util'\nimport { substitute } from '@amazon/vinyl-util'\nimport type { ValidationErrorMessage, Validator } from './Validator'\nimport { createDeepValidator, createValidator } from './Validator'\nimport { ValueSchema } from './ValueSchema'\n\n/**\n * @private\n */\nconst locale = {\n set: 'Set',\n withElements: 'Set<{value}>',\n} as const\n\nexport const setValidators = {\n /**\n * Creates a validator that asserts that the input is a set.\n */\n isSet(): Validator<Set<unknown>> {\n return createValidator(\n locale.set,\n (input: unknown) => input instanceof Set\n )\n },\n\n /**\n * Creates a validator that asserts that every element passes the given validator.\n *\n * @param elementValidator\n */\n withElements<U>(\n elementValidator: Validator<U>\n ): Validator<Set<U>, ReadonlySet<unknown>> {\n return createDeepValidator(\n substitute(locale.withElements, {\n value: elementValidator.description,\n }),\n (input, options, path) => {\n const errors: ValidationErrorMessage[] = []\n let i = 0\n for (const element of input) {\n errors.push(\n ...elementValidator.validate(\n element,\n options,\n path.concat(i.toString())\n )\n )\n if (!options.all && errors.length) return errors\n i++\n }\n return errors\n }\n )\n },\n} as const\n\nexport class SetSchema<T extends ReadonlySet<unknown>> extends ValueSchema<T> {\n private static _base: SetSchema<Set<unknown>> | null = null\n\n /**\n * The base SetSchema instance validating that the input is a Set.\n */\n static get base(): SetSchema<Set<unknown>> {\n if (this._base == null)\n this._base = new SetSchema(setValidators.isSet())\n return this._base\n }\n\n /**\n * Creates a validator that asserts that every element passes the given validator.\n *\n * @param elementValidator\n */\n withElements<U>(\n elementValidator: Validator<U>\n ): SetSchema<Set<SetElementType<T> & U>> {\n return this.chain(setValidators.withElements(elementValidator))\n }\n\n /**\n * Casts to a readonly set.\n * This is a shallow cast, elements of the array will not be changed.\n */\n readonly(): SetSchema<ReadonlySet<SetElementType<T>>> {\n return this as any\n }\n\n /**\n * Casts the parameter type.\n */\n cast<T extends ReadonlySet<unknown>>(): SetSchema<T> {\n return this as any\n }\n}\n", "/*\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { substitute } from '@amazon/vinyl-util'\nimport { ValueSchema } from './ValueSchema'\nimport { typeOfValidators } from './typeOfValidators'\nimport type { Validator } from './Validator'\nimport { createValidator } from './Validator'\n\nconst locale = {\n gte: 'at least {value}',\n gt: 'greater than {value}',\n lte: 'at most {value}',\n lt: 'less than {value}',\n within: 'within {min} and {max}',\n safeInteger: 'safe integer',\n finite: 'finite',\n} as const\n\nexport const numberValidators = {\n /**\n * Creates a validator that asserts that the input number is at least the provided minimum\n * value.\n *\n * @param min The minimum (inclusive) the value may be.\n */\n gte(min: number): Validator<number, number> {\n return createValidator(\n substitute(locale.gte, { value: min }),\n (input) => input >= min\n )\n },\n\n /**\n * Creates a validator that asserts that the input number is greater than the provided minimum\n * value.\n *\n * @param min The minimum (exclusive) the value may be.\n */\n gt(min: number): Validator<number, number> {\n return createValidator(\n substitute(locale.gt, { value: min }),\n (input) => input > min\n )\n },\n\n /**\n * Creates a validator that asserts that the input number is at most the provided maximum\n * value.\n *\n * @param max The maximum (inclusive) the value may be.\n */\n lte(max: number): Validator<number, number> {\n return createValidator(\n substitute(locale.lte, { value: max }),\n (input) => input <= max\n )\n },\n\n /**\n * Creates a validator that asserts that the input number is less than the provided maximum\n * value.\n *\n * @param max The maximum (exclusive) the value may be.\n */\n lt(max: number): Validator<number, number> {\n return createValidator(\n substitute(locale.lt, { value: max }),\n (input) => input < max\n )\n },\n\n /**\n * Creates a validator that asserts that the input number is at least the provided minimum\n * and at most the provided maximum values.\n *\n * @param min The minimum (inclusive) value the input may be.\n * @param max The maximum (inclusive) value the input may be.\n */\n within(min: number, max: number): Validator<number, number> {\n return createValidator(\n substitute(locale.within, { min, max }),\n (input) => input >= min && input <= max\n )\n },\n\n /**\n * Creates a validator that asserts that the input number is finite.\n */\n finite(): Validator<number, number> {\n return createValidator(locale.finite, (input) => Number.isFinite(input))\n },\n\n /**\n * Creates a validator that asserts that the input number is a safe integer.\n */\n safeInteger(): Validator<number, number> {\n return createValidator(locale.safeInteger, (input) =>\n Number.isSafeInteger(input)\n )\n },\n} as const\n\nexport class NumberSchema extends ValueSchema<number> {\n private static _base: NumberSchema | null = null\n\n /**\n * The base Object validator validating that the input is an object.\n */\n static get base(): NumberSchema {\n if (this._base == null)\n this._base = new NumberSchema(typeOfValidators.number)\n return this._base\n }\n\n /**\n * Creates a validator that asserts that the input number is at least the provided minimum\n * value.\n *\n * @param min The minimum (inclusive) the value may be.\n */\n gte(min: number): this {\n return this.chain(numberValidators.gte(min))\n }\n\n /**\n * Creates a validator that asserts that the input number is greater than the provided minimum\n * value.\n *\n * @param min The minimum (exclusive) the value may be.\n */\n gt(min: number): this {\n return this.chain(numberValidators.gt(min))\n }\n\n /**\n * Creates a validator that asserts that the input number is at most the provided maximum\n * value.\n *\n * @param max The maximum (inclusive) the value may be.\n */\n lte(max: number): this {\n return this.chain(numberValidators.lte(max))\n }\n\n /**\n * Creates a validator that asserts that the input number is less than the provided maximum\n * value.\n *\n * @param max The maximum (exclusive) the value may be.\n */\n lt(max: number): this {\n return this.chain(numberValidators.lt(max))\n }\n\n /**\n * Creates a validator that asserts that the input number is at least the provided minimum\n * and at most the provided maximum values.\n *\n * @param min The minimum (inclusive) value the input may be.\n * @param max The maximum (inclusive) value the input may be.\n */\n within(min: number, max: number): this {\n return this.chain(numberValidators.within(min, max))\n }\n\n /**\n * Creates a validator that asserts that the input number is finite.\n */\n finite(): this {\n return this.chain(numberValidators.finite())\n }\n\n /**\n * Creates a validator that asserts that the input number is a safe integer.\n */\n safeInteger(): this {\n return this.chain(numberValidators.safeInteger())\n }\n}\n", "/*\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport type {\n AnyRecord,\n IsPropertyOptional,\n PartialDeep,\n} from '@amazon/vinyl-util'\nimport { merge, ownKeys, substitute } from '@amazon/vinyl-util'\nimport type { ValidatorWithPartial } from './ValidatorWithPartial'\nimport { maybeToDeepPartial, maybeToPartial } from './ValidatorWithPartial'\nimport { ValueSchema } from './ValueSchema'\nimport { typeOfValidators } from './typeOfValidators'\nimport type { ValidationErrorMessage } from './Validator'\nimport { createDeepValidator } from './Validator'\nimport type { PropertyValidator } from '@/validation/PropertyValidator'\nimport type { Equal } from '@amazon/vinyl-util/browserTestUtil'\n\n/**\n * @private\n */\nconst locale = {\n extend: '{\\n{body}\\n}',\n prop: '{key}: {value}',\n propSeparator: ',\\n',\n indent: ' ',\n required: `property '{key}' is required`,\n} as const\n\nexport const objectValidators = {\n /**\n * Creates a validator that validates the input has properties that pass their respective\n * validators.\n *\n * @param propertyValidators\n */\n properties<U extends object>(propertyValidators: {\n readonly [P in keyof U]-?: PropertyValidator<\n Required<U>[P],\n { optional: IsPropertyOptional<U, P> }\n >\n }): ValidatorWithPartial<U, object> {\n const propertiesDescriptions: string[] = []\n const keys = ownKeys(propertyValidators)\n for (const key of keys) {\n const validator = propertyValidators[key]\n propertiesDescriptions.push(\n substitute(locale.prop, {\n key: String(key) + (validator.options.optional ? '?' : ''),\n value: validator.description,\n })\n )\n }\n const description = substitute(locale.extend, {\n body: propertiesDescriptions\n .join(locale.propSeparator)\n .split('\\n')\n .map((line) => locale.indent + line)\n .join('\\n'),\n })\n const validator = createDeepValidator(\n description,\n (input: any, options, path) => {\n const errors: ValidationErrorMessage[] = []\n for (const key of keys) {\n const validator = propertyValidators[key]\n if (key in input) {\n const value = input[key]\n errors.push(\n ...validator.validate(\n value,\n options,\n path.concat(String(key))\n )\n )\n } else {\n // Missing property\n if (!validator.options.optional) {\n errors.push({\n message: substitute(locale.required, { key }),\n path: path.concat(String(key)),\n })\n }\n }\n if (!options.all && errors.length) return errors\n }\n return errors\n }\n )\n return merge(validator, {\n partial(): ValidatorWithPartial<Partial<U>, object> {\n const optionalPropertyValidators = {} as any\n for (const key of keys) {\n optionalPropertyValidators[key] =\n propertyValidators[key].optional()\n }\n return objectValidators.properties<Partial<U>>(\n optionalPropertyValidators\n )\n },\n\n partialDeep(): ValidatorWithPartial<PartialDeep<U>, object> {\n const optionalPropertyValidators = {} as any\n for (const key of keys) {\n optionalPropertyValidators[key] = maybeToDeepPartial(\n propertyValidators[key].optional()\n )\n }\n return objectValidators.properties<PartialDeep<U>>(\n optionalPropertyValidators\n )\n },\n })\n },\n} as const\n\n/**\n * Chainable object validators.\n */\nexport class ObjectSchema<T extends object>\n extends ValueSchema<T>\n implements ValidatorWithPartial<T, unknown>\n{\n private static _base: ObjectSchema<AnyRecord> | null = null\n\n /**\n * The base Object validator validating that the input is an object.\n */\n static get base(): ObjectSchema<AnyRecord> {\n if (this._base == null)\n this._base = new ObjectSchema(typeOfValidators.object)\n return this._base\n }\n\n /**\n * Creates a validator that validates the input has properties that pass their respective\n * validators.\n *\n * @param propertyValidators\n */\n extend<U extends object>(\n propertyValidators: NoInfer<ExtendedPropertyValidators<T, U>>\n ): ObjectSchema<U> {\n return this.chain(objectValidators.properties(propertyValidators))\n }\n\n /**\n * Allows all properties to be undefined.\n */\n partial(): ObjectSchema<Partial<T>> {\n return this.clone(maybeToPartial)\n }\n\n /**\n * Allows all recursive properties to be undefined.\n */\n partialDeep(): ObjectSchema<PartialDeep<T>> {\n return this.clone(maybeToDeepPartial)\n }\n\n /**\n * Casts the type parameter.\n */\n cast<T extends object>(): ObjectSchema<T> {\n return this as any\n }\n}\n\nexport type ExtendedPropertyValidators<T extends object, U extends object> = {\n // REQUIRED:\n // - Keys in U but not in T\n // - Keys in both where U[K] !== T[K]\n [K in keyof U as K extends keyof T\n ? Equal<U[K], T[K]> extends true\n ? never\n : K\n : K]-?: ExtendedPropertyValidator<U & T, K>\n} & {\n // OPTIONAL:\n // - Keys where U[K] === T[K] (and therefore K \u2208 keyof T)\n [K in keyof U as K extends keyof T\n ? Equal<U[K], T[K]> extends true\n ? K\n : never\n : never]?: ExtendedPropertyValidator<U & T, K>\n}\n\nexport type ExtendedPropertyValidator<\n U extends object,\n P extends keyof U,\n> = PropertyValidator<Required<U>[P], { optional: IsPropertyOptional<U, P> }>\n", "/*\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport type { PartialDeep } from '@amazon/vinyl-util'\nimport type { Validator } from './Validator'\n\nexport interface ValidatorWithPartial<\n Output extends Input,\n Input,\n> extends Validator<Output, Input> {\n partial(): ValidatorWithPartial<Partial<Output> & Input, Input>\n partialDeep(): ValidatorWithPartial<PartialDeep<Output> & Input, Input>\n}\n\n/**\n * Returns true if the given validator is an object validator.\n * @param validator\n */\nexport function isValidatorWithPartial<Output extends Input, Input>(\n validator: Validator<Output, Input>\n): validator is ValidatorWithPartial<Output, Input> {\n return 'partial' in validator && 'partialDeep' in validator\n}\n\n/**\n * If the given validator is an object validator, it will be cloned to a deep partial validator,\n * otherwise returns the validator as is.\n *\n * @param validator\n */\nexport function maybeToDeepPartial(validator: Validator<any>): Validator<any> {\n return isValidatorWithPartial(validator)\n ? validator.partialDeep()\n : validator\n}\n\n/**\n * If the given validator is an object validator, it will be cloned to a partial validator,\n * otherwise returns the validator as is.\n *\n * @param validator\n */\nexport function maybeToPartial(validator: Validator<any>): Validator<any> {\n return isValidatorWithPartial(validator) ? validator.partial() : validator\n}\n", "/*\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport type { ReadonlyRecord } from '@amazon/vinyl-util'\nimport { ownKeys, substitute } from '@amazon/vinyl-util'\nimport { ValueSchema } from './ValueSchema'\nimport { StringSchema } from './StringSchema'\nimport { typeOfValidators } from './typeOfValidators'\nimport type { ValidationErrorMessage, Validator } from './Validator'\nimport { createDeepValidator } from './Validator'\n\n/**\n * @private\n */\nconst locale = {\n record: '{ [key: {key}]: {value} }',\n} as const\n\nexport const recordValidators = {\n /**\n * Returns a validator that asserts that the object's own enumerable properties has keys and\n * values that match their respective validators.\n *\n * Prototype members are not included.\n * Numeric keys are validated as strings. For example the object `{ [0]: 1 }` will be passed\n * to the key validator as '0'.\n *\n * @param keyValidator Validates each key.\n * @param valueValidator Validates each value.\n */\n record<K extends string | symbol, V>(\n keyValidator: Validator<K>,\n valueValidator: Validator<V>\n ): Validator<Record<K, V>, object> {\n return createDeepValidator(\n substitute(locale.record, {\n key: keyValidator.description,\n value: valueValidator.description,\n }),\n (input, options, path) => {\n const errors: ValidationErrorMessage[] = []\n for (const key of ownKeys(input)) {\n const keyStr = String(key)\n errors.push(\n ...keyValidator.validate(\n key,\n options,\n path.concat(`[${keyStr}]`)\n )\n )\n if (!options.all && errors.length) return errors\n const value = input[key]\n errors.push(\n ...valueValidator.validate(\n value,\n options,\n path.concat(keyStr)\n )\n )\n if (!options.all && errors.length) return errors\n }\n return errors\n }\n )\n },\n} as const\n\n/**\n * Chainable object validators for the Record type.\n */\nexport class RecordSchema<\n T extends ReadonlyRecord<keyof any, any>,\n> extends ValueSchema<T> {\n private static _base: RecordSchema<Record<keyof any, unknown>> | null = null\n\n /**\n * The base Object validator validating that the input is an object.\n */\n static get base(): RecordSchema<Record<keyof any, unknown>> {\n if (this._base == null)\n this._base = new RecordSchema(typeOfValidators.object)\n return this._base\n }\n\n private static get defaultKeyValidator(): StringSchema {\n return StringSchema.base\n }\n\n /**\n * Returns a validator that asserts that the object's own enumerable properties has keys and\n * values that match their respective validators.\n *\n * Prototype members are not included.\n * Numeric keys are validated as strings. For example the object `{ [0]: 1 }` will be passed\n * to the key validator as '0'.\n *\n * @param keyValidator Validates each key.\n * @param valueValidator Validates each value.\n */\n record<K extends string | symbol, V>(\n keyValidator: Validator<K>,\n valueValidator: Validator<V>\n ): RecordSchema<ReadonlyRecord<K, V>> {\n return this.chain(recordValidators.record(keyValidator, valueValidator))\n }\n\n /**\n * Returns a validator that asserts that the object's own enumerable properties has\n * string keys and values that match the given validator.\n *\n * Prototype members are not included.\n *\n * @param valueValidator Validates each value.\n */\n recordValues<V>(\n valueValidator: Validator<V>\n ): RecordSchema<Record<string, V>> {\n return this.record(RecordSchema.defaultKeyValidator, valueValidator)\n }\n\n /**\n * Casts to a ReadonlyRecord\n */\n readonly(): RecordSchema<\n T extends Record<infer K, infer V> ? ReadonlyRecord<K, V> : never\n > {\n return this as any\n }\n\n /**\n * Casts the type parameter.\n */\n cast<T extends ReadonlyRecord<keyof any, unknown>>(): RecordSchema<T> {\n return this as any\n }\n}\n", "/*\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { substitute } from '@amazon/vinyl-util'\nimport { ValueSchema } from './ValueSchema'\nimport { typeOfValidators } from './typeOfValidators'\nimport type { Validator } from './Validator'\nimport { createValidator } from './Validator'\n\n/**\n * @private\n */\nconst locale = {\n notEmpty: 'not empty',\n minLength: 'at least {value} characters',\n maxLength: 'at most {value} characters',\n noWhitespace: 'no whitespace characters',\n matches: 'matches {value}',\n} as const\n\nexport const stringValidators = {\n /**\n * Creates a validator that asserts that the input is not empty.\n */\n notEmpty(): Validator<string, string> {\n return createValidator(locale.notEmpty, (input) => input !== '')\n },\n\n /**\n * Creates a validator that asserts that the input string has at least the given minimum\n * length.\n *\n * @param min The string must be at least this length.\n */\n minLength(min: number): Validator<string, string> {\n return createValidator(\n substitute(locale.minLength, { value: min }),\n (input) => input.length >= min\n )\n },\n\n /**\n * Creates a validator that asserts that the input string has at most the given maximum\n * length.\n *\n * @param max The string must be at most this length.\n */\n maxLength(max: number): Validator<string, string> {\n return createValidator(\n substitute(locale.maxLength, { value: max }),\n (input) => input.length <= max\n )\n },\n\n /**\n * Creates a validator that asserts that the input string has no whitespace characters.\n * Whitespace characters include space, new line, carriage return, and tab.\n */\n noWhitespace(): Validator<string, string> {\n return createValidator(\n locale.noWhitespace,\n (input) => input.search(/\\s/g) === -1\n )\n },\n\n /**\n * Creates a validator that asserts that the input string matches the given regex.\n * @param regex\n */\n matches(regex: RegExp): Validator<string, string> {\n return createValidator(\n substitute(locale.matches, { value: regex.toString() }),\n (input) => {\n return regex.test(input)\n }\n )\n },\n} as const\n\nexport class StringSchema extends ValueSchema<string> {\n private static _base: StringSchema | null = null\n\n /**\n * The base SetSchema instance validating that the input is a Set.\n */\n static get base(): StringSchema {\n if (this._base == null)\n this._base = new StringSchema(typeOfValidators.string)\n return this._base\n }\n\n /**\n * Creates a validator that asserts that the input is not empty.\n */\n notEmpty(): StringSchema {\n return this.chain(stringValidators.notEmpty())\n }\n\n /**\n * Creates a validator that asserts that the input string has at least the given minimum\n * length.\n *\n * @param min The string must be at least this length.\n */\n minLength(min: number): StringSchema {\n return this.chain(stringValidators.minLength(min))\n }\n\n /**\n * Creates a validator that asserts that the input string has at most the given maximum\n * length.\n *\n * @param max The string must be at most this length.\n */\n maxLength(max: number): StringSchema {\n return this.chain(stringValidators.maxLength(max))\n }\n\n /**\n * Creates a validator that asserts that the input string has no whitespace characters.\n * Whitespace characters include space, new line, carriage return, and tab.\n */\n noWhitespace(): StringSchema {\n return this.chain(stringValidators.noWhitespace())\n }\n\n /**\n * Creates a validator that asserts that the input string matches the given regex.\n * @param regex\n */\n matches(regex: RegExp): StringSchema {\n return this.chain(stringValidators.matches(regex))\n }\n}\n"],
|
|
4
|
+
"sourcesContent": ["/** Auto-generated from build scripts */\nexport * from './validation/validators'\nexport * from './validation/typeOfValidators'\nexport * from './validation/orValidators'\nexport * from './validation/andValidators'\nexport * from './validation/ValueSchema'\nexport * from './validation/ValidatorWithPartial'\nexport * from './validation/Validator'\nexport * from './validation/StringSchema'\nexport * from './validation/SetSchema'\nexport * from './validation/SchemaBase'\nexport * from './validation/RecordSchema'\nexport * from './validation/PropertyValidator'\nexport * from './validation/ObjectSchema'\nexport * from './validation/NumberSchema'\nexport * from './validation/FunctionSchema'\nexport * from './validation/ArraySchema'\n", "/*\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport {\n type AnyRecord,\n type Fun,\n type Primitive,\n type ReadonlyRecord,\n stringifyForPrint,\n substitute,\n} from '@amazon/vinyl-util'\nimport { ArraySchema } from './ArraySchema'\nimport { FunctionSchema } from './FunctionSchema'\nimport { SetSchema } from './SetSchema'\nimport { ValueSchema, valueValidators } from './ValueSchema'\nimport { NumberSchema } from './NumberSchema'\nimport { type ExtendedPropertyValidators, ObjectSchema } from './ObjectSchema'\nimport { RecordSchema } from './RecordSchema'\nimport { StringSchema } from './StringSchema'\nimport { typeOfValidators } from './typeOfValidators'\nimport type { Validator } from './Validator'\nimport { createValidator } from './Validator'\n\n/**\n * @private\n */\nconst locale = {\n isOneOf: 'one of: {value}',\n instanceOf: 'instance of {value}',\n oneOfSeparator: ' | ',\n} as const\n\n/**\n * Creates a no-op validator. The value can be any type.\n */\nexport function any(): ValueSchema<any> {\n return new ValueSchema(valueValidators.any())\n}\n\n/**\n * Creates a validator that asserts that the input is an array.\n */\nexport function array(): ArraySchema<unknown[]>\n\n/**\n * Creates a validator that asserts that the input is an array and every element passes the\n * given validator.\n *\n * @param elementValidator\n */\nexport function array<U>(elementValidator: Validator<U>): ArraySchema<U[]>\n\nexport function array(\n elementValidator?: Validator<any>\n): ArraySchema<unknown[]> {\n if (!elementValidator) return ArraySchema.base\n else return ArraySchema.base.withElements(elementValidator)\n}\n\n/**\n * Creates a validator that asserts that the input is a boolean.\n */\nexport function boolean(): ValueSchema<boolean> {\n return new ValueSchema(typeOfValidators.boolean)\n}\n\n/**\n * Creates a validator that asserts that the input is a function.\n */\nexport function func(): FunctionSchema<Fun> {\n return FunctionSchema.base\n}\n\n/**\n * Validates that the input is an instanceof the given prototype.\n * @param clazz\n */\nexport function instanceOf<const T>(\n clazz: new (...args: any[]) => T\n): ValueSchema<T> {\n return new ValueSchema(\n createValidator(\n substitute(locale.instanceOf, { value: clazz.name }),\n (input) => input instanceof clazz\n )\n )\n}\n\n/**\n * Creates a validator that asserts that the input is nullish or one of the given possible values.\n *\n * @param possibleValues\n */\nexport function isOneOf<const U extends readonly Primitive[]>(\n ...possibleValues: U\n): ValueSchema<U[number]> {\n return new ValueSchema(\n createValidator(\n substitute(locale.isOneOf, {\n value: possibleValues.join(locale.oneOfSeparator),\n }),\n (input) => possibleValues.includes(input as U[number])\n )\n )\n}\n\n/**\n * Creates a validator that asserts that the input is one of the values of the given enum.\n *\n * @param enumObject The enum to validate against.\n */\nexport function enumOf<const T extends Record<string, Primitive>>(\n enumObject: T\n): ValueSchema<T[keyof T]> {\n return isOneOf(...Object.values(enumObject)) as unknown as ValueSchema<\n T[keyof T]\n >\n}\n\n/**\n * Creates a validator that asserts that the input is null.\n */\nexport function exactlyNull(): Validator<null> {\n return valueValidators.null()\n}\n\n/**\n * Creates a validator that asserts that the input is nullish.\n */\nexport function nullish(): Validator<null | undefined> {\n return valueValidators.nullish()\n}\n\n/**\n * Creates a validator that asserts that the input is a number.\n */\nexport function number(): NumberSchema {\n return NumberSchema.base\n}\n\n/**\n * Creates a validator that validates the input has properties that pass their respective\n * validators.\n */\nexport function object<const U extends object>(\n propertyValidators: NoInfer<ExtendedPropertyValidators<AnyRecord, U>>\n): ObjectSchema<U> {\n return ObjectSchema.base.extend<U>(propertyValidators)\n}\n\n/**\n * Returns a validator that asserts that the object's own enumerable properties has keys and\n * values that match their respective validators.\n *\n * Prototype members are not included.\n * Numeric keys are validated as strings. For example the object `{ [0]: 1 }` will be passed\n * to the key validator as '0'.\n *\n * To assume string keys, use {@link recordValues}\n *\n * @param keyValidator Validates each key.\n * @param valueValidator Validates each value.\n */\nexport function record<const K extends string | symbol, const V>(\n keyValidator: Validator<K>,\n valueValidator: Validator<V>\n): RecordSchema<ReadonlyRecord<K, V>> {\n return RecordSchema.base.record(keyValidator, valueValidator)\n}\n\n/**\n * Returns a validator that asserts that the input object's own enumerable properties has\n * string keys and values that match the given validator.\n *\n * Prototype members are not included.\n *\n * @param valueValidator Validates each value.\n */\nexport function recordValues<const V>(\n valueValidator: Validator<V>\n): RecordSchema<Record<string, V>> {\n return RecordSchema.base.recordValues(valueValidator)\n}\n\n/**\n * Returns a validator that asserts the input is a set with elements that match the given\n * element validator.\n * @param elementValidator\n */\nexport function set<const U>(\n elementValidator: Validator<U>\n): SetSchema<Set<U>> {\n return SetSchema.base.withElements(elementValidator)\n}\n\n/**\n * Creates a validator that asserts that the input is type 'string'.\n */\nexport function string(): StringSchema {\n return StringSchema.base\n}\n\n/**\n * Creates a validator that asserts that the input array is a tuple whose elements match\n * the given validators.\n *\n * @param validators\n */\nexport function tuple<U extends readonly any[]>(\n ...validators: {\n [Index in keyof U]: Validator<U[Index]>\n }\n): ArraySchema<{\n [Index in keyof U]: U[Index]\n}> {\n return ArraySchema.base.tuple(...validators)\n}\n\n/**\n * Creates a validator that asserts that the input is type 'symbol'.\n */\nexport function symbol(): ValueSchema<symbol> {\n return new ValueSchema(typeOfValidators.symbol)\n}\n\n/**\n * Creates a validator that asserts that the input is strictly undefined.\n */\nexport function exactlyUndefined(): ValueSchema<undefined> {\n return new ValueSchema(valueValidators.undefined())\n}\n\n/**\n * Returns a custom\n * @param expectationMessage\n * @param isValid\n * @param inputStringify\n */\nexport function custom<T>(\n expectationMessage: string,\n isValid: (input: unknown) => boolean,\n inputStringify: (input: unknown) => string = (input) =>\n stringifyForPrint(input, 500)\n): ValueSchema<T> {\n return new ValueSchema(\n createValidator(expectationMessage, isValid, inputStringify)\n )\n}\n", "/*\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport type { ElementType } from '@amazon/vinyl-util'\nimport { substitute } from '@amazon/vinyl-util'\nimport { ValueSchema } from './ValueSchema'\nimport type { ValidationErrorMessage, Validator } from './Validator'\nimport { createDeepValidator, createValidator } from './Validator'\n\n/**\n * @private\n */\nconst locale = {\n array: 'array',\n minLength: 'at least {value} elements',\n maxLength: 'at most {value} elements',\n exactlyLength: 'exactly {value} elements',\n actualLength: 'length {value}',\n withElements: '({value})[]',\n tuple: '[{value}]',\n} as const\n\nexport const arrayValidators = {\n /**\n * Creates a validator that asserts that the input is an array.\n *\n * Note: arrays can only be readonly by type system, there is no native readonly\n * js array. This validator assumes mutability, use the ArraySchema readonly() method\n * to cast to a readonly array.\n */\n isArray(): Validator<unknown[]> {\n return createValidator(locale.array, (input: unknown) =>\n Array.isArray(input)\n )\n },\n\n /**\n * Creates a validator that asserts that every element passes the given validator.\n *\n * @param elementValidator\n */\n withElements<U>(\n elementValidator: Validator<U>\n ): Validator<U[], readonly unknown[]> {\n return createDeepValidator(\n substitute(locale.withElements, {\n value: elementValidator.description,\n }),\n (input, options, path) => {\n const errors: ValidationErrorMessage[] = []\n for (let i = 0; i < input.length; i++) {\n const element = input[i]\n errors.push(\n ...elementValidator.validate(\n element,\n options,\n path.concat(i.toString())\n )\n )\n if (!options.all && errors.length) return errors\n }\n return errors\n }\n )\n },\n\n /**\n * Creates a validator that asserts that the input array is a tuple whose elements match\n * the given validators.\n *\n * @param validators\n */\n tuple<U extends readonly any[]>(\n ...validators: {\n [Index in keyof U]: Validator<U[Index]>\n }\n ): Validator<\n {\n [Index in keyof U]: U[Index]\n },\n readonly unknown[]\n > {\n const lengthValidator = createValidator(\n substitute(locale.exactlyLength, {\n value: validators.length,\n }),\n (length: number) => length === validators.length\n )\n return createDeepValidator(\n substitute(locale.tuple, { value: validators.join(', ') }),\n (input, options, path) => {\n const errors: ValidationErrorMessage[] = []\n errors.push(\n ...lengthValidator.validate(input.length, options, path)\n )\n if (!options.all && errors.length) return errors\n const n = Math.min(validators.length, input.length)\n for (let i = 0; i < n; i++) {\n const element = input[i]\n const validator = validators[i]\n errors.push(\n ...validator.validate(\n element,\n options,\n path.concat(i.toString())\n )\n )\n if (!options.all && errors.length) return errors\n }\n return errors\n }\n )\n },\n\n /**\n * Creates a validator that validates the input array has the given minimum length.\n * @param min The minimum number of elements (inclusive)\n */\n minLength(min: number): Validator<readonly unknown[], readonly unknown[]> {\n return createValidator(\n substitute(locale.minLength, { value: min }),\n (input) => input.length >= min,\n (input) => substitute(locale.actualLength, { value: input.length })\n )\n },\n\n /**\n *\n * Creates a validator that validates the input array has the given maximum length.\n * @param max The maximum number of elements (inclusive)\n */\n maxLength(max: number): Validator<readonly unknown[], readonly unknown[]> {\n return createValidator(\n substitute(locale.maxLength, { value: max }),\n (input) => input.length <= max,\n (input) => substitute(locale.actualLength, { value: input.length })\n )\n },\n} as const\n\nexport class ArraySchema<T extends readonly unknown[]> extends ValueSchema<T> {\n private static _base: ArraySchema<unknown[]> | null = null\n\n /**\n * The base ArraySchema instance validating that the input is an Array.\n */\n static get base(): ArraySchema<unknown[]> {\n if (this._base == null)\n this._base = new ArraySchema(arrayValidators.isArray())\n return this._base\n }\n\n /**\n * Creates a validator that asserts that every element passes the given validator.\n *\n * @param elementValidator\n */\n withElements<U>(\n elementValidator: Validator<U>\n ): ArraySchema<(ElementType<T> & U)[]> {\n return this.chain(arrayValidators.withElements(elementValidator))\n }\n\n /**\n * Creates a validator that asserts that the input array is a tuple whose elements match\n * the given validators.\n *\n * @param validators\n */\n tuple<U extends readonly any[]>(\n ...validators: {\n [Index in keyof U]: Validator<U[Index]>\n }\n ): ArraySchema<{\n [Index in keyof U]: U[Index]\n }> {\n return this.chain(arrayValidators.tuple(...validators))\n }\n\n /**\n * Creates a validator that validates the input array has the given minimum length.\n * @param min The minimum number of elements (inclusive)\n */\n minLength(min: number): ArraySchema<T> {\n return this.chain(arrayValidators.minLength(min))\n }\n\n /**\n *\n * Creates a validator that validates the input array has the given maximum length.\n * @param max The maximum number of elements (inclusive)\n */\n maxLength(max: number): ArraySchema<T> {\n return this.chain(arrayValidators.maxLength(max))\n }\n\n /**\n * Casts to a readonly array.\n * This is a shallow cast, elements of the array will not be changed.\n */\n readonly(): ArraySchema<Readonly<T>> {\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n return this as any\n }\n\n /**\n * Casts the type parameter.\n */\n cast<T extends readonly unknown[]>(): ArraySchema<T> {\n return this as any\n }\n}\n", "/*\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { substitute } from '@amazon/vinyl-util'\nimport type { Validator } from './Validator'\nimport { createDeepValidator } from './Validator'\n\n/*\n * @brief\n * andValidators will intersect an arbitrary number of validators.\n *\n * While in most cases validating that an input passes two validators, the asserted output is the\n * intersection of those two validator outputs, this is not always the case.\n * For example, take two validators with outputs `A[]` and `B[]`, their combined validated output\n * type would be `(A & B)[]`, not `A[] & B[]`. Use casting when necessary.\n *\n * Also note that there is no contravariance safety with the chained validator inputs. That is,\n * there's no compile-time checking that validatorB accepts an input that is the super of\n * validatorA's output.\n */\n\n/**\n * @private\n */\nconst locale = {\n /**\n * {value} The child validators' descriptions, joined with `separator`.\n *\n * groupings of and validators is unimportant,\n * and(and(a, b), c) is the same as and(a, and(b, c)), so `a & b & c` is an accurate\n * representation for either.\n */\n template: '{value}',\n\n /**\n * The separator with which to join child validator descriptions.\n */\n separator: ' & ',\n} as const\n\n/**\n * Validates that all the given validators pass.\n */\nexport function andValidators<A extends Input, B, Input>(\n validatorA: Validator<A, Input>,\n validatorB: Validator<B, any>\n): Validator<A & B, Input>\n\n/**\n * Validates that all the given validators pass.\n */\nexport function andValidators<A extends Input, B, C, Input>(\n validatorA: Validator<A, Input>,\n validatorB: Validator<B, any>,\n validatorC: Validator<C, any>\n): Validator<A & B & C, Input>\n\n/**\n * Validates that all the given validators pass.\n */\nexport function andValidators<A extends Input, B, C, D, Input>(\n validatorA: Validator<A, Input>,\n validatorB: Validator<B, any>,\n validatorC: Validator<C, any>,\n validatorD: Validator<D, any>\n): Validator<A & B & C & D, any>\n\n/**\n * Validates that all the given validators pass.\n */\nexport function andValidators<A extends Input, B, C, D, E, Input>(\n validatorA: Validator<A, Input>,\n validatorB: Validator<B, any>,\n validatorC: Validator<C, any>,\n validatorD: Validator<D, any>,\n validatorE: Validator<E, any>\n): Validator<A & B & C & D & E, any>\n\nexport function andValidators(\n ...validators: Validator<any, any>[]\n): Validator<any, any>\n\nexport function andValidators(\n ...validators: Validator<any, any>[]\n): Validator<any, any> {\n return createDeepValidator(\n substitute(locale.template, {\n value: validators.map((v) => v.description).join(locale.separator),\n }),\n (input, options, path) => {\n for (const validator of validators) {\n const errors = validator.validate(input, options, path)\n if (errors.length) return errors\n }\n return []\n }\n )\n}\n", "/*\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { type Invariant, ValidationError } from '@amazon/vinyl-util'\nimport { stringifyForPrint, substitute } from '@amazon/vinyl-util'\n\n/**\n * Represents a validation failure.\n */\nexport interface ValidationErrorMessage {\n readonly message: string\n readonly path: readonly string[]\n}\n\nexport interface ValidationOptions {\n /**\n * If true, collect all validation errors.\n * Default: false\n */\n readonly all?: boolean\n}\n\n/**\n * A Validator can assert that an input matches this validator's schema.\n */\nexport interface Validator<Output extends Input, in Input = unknown> {\n /**\n * Enforces T is in an invariant position.\n * This prevents a validator with more strict rules is assigned to a less strict type, which\n * can cause unexpected validation errors.\n */\n __type?: Invariant<Output>\n\n /**\n * A short description of the validator.\n */\n readonly description: string\n\n /**\n * Returns true if the input is valid according to this validator.\n *\n * @param input\n */\n readonly isValid: (input: Input) => input is Output\n\n /**\n * Validates the provided input, returning a list of error messages, or an empty array if the\n * input passes this validator.\n *\n * @param input The input to validate.\n * @param options Validation options.\n * @param path The current field path to this validator.\n * @return Returns an array of validation failures. If `options.all` is not true, only the\n * first error will be returned.\n */\n readonly validate: (\n input: Input,\n options?: ValidationOptions,\n path?: readonly string[]\n ) => readonly ValidationErrorMessage[]\n\n /**\n * Validates the given input, asserting that the input is type `T`.\n * If the input is not valid, a {@link ValidationError} will be thrown.\n *\n * @param input The input to validate.\n * @param origin The error origin. `ErrorOrigin.API` by default.\n * @param path The current field path to this validator.\n * @return Returns the input, cast as the validated type T\n */\n readonly assert: (\n input: Input,\n origin?: string,\n path?: readonly string[]\n ) => asserts input is Output\n}\n\n/**\n * @private\n */\nconst validatorLocale = {\n /**\n * The expectation template string with the following replacement tokens:\n *\n * `{expected}` - The expected description.\n * `{actual}` - The actual value.\n * `{path}` - The path, dot separated.\n */\n template: 'Expected: {expected}, but was: {actual}. At: {path}',\n}\n\n/**\n * Creates a message string for a ValidationErrorMessage based on the input and its expectation.\n *\n * @param expectationMessage\n * @param input\n * @param path\n * @param inputStringify\n */\nexport function createValidationExpectationMessage<Input>(\n expectationMessage: string,\n input: Input,\n path: readonly string[],\n inputStringify: (input: Input) => string = (input) =>\n stringifyForPrint(input, 500)\n): string {\n return substitute(validatorLocale.template, {\n expected: expectationMessage,\n actual: inputStringify(input),\n path: path.join('.'),\n })\n}\n\n/**\n * Creates a new basic validator.\n *\n * For a deep validator which has sub-fields, use {@link createDeepValidator}.\n *\n * @param expectationMessage The message to use to describe what is expected. This will be used in\n * the error message template.\n * @param isValid Returns true if the given input is valid.\n * @param inputStringify Stringifies the input for use as the actual `{actual}` token in the validation\n * expectation template. Default is `stringifyForPrint` with a 500 character max length.\n */\nexport function createValidator<Output extends Input, Input = unknown>(\n expectationMessage: string,\n isValid: (input: Input) => boolean,\n inputStringify: (input: Input) => string = (input) =>\n stringifyForPrint(input, 500)\n): Validator<Output, Input> {\n return {\n description: expectationMessage,\n\n isValid(input: Input): input is Output {\n return isValid(input)\n },\n\n validate(\n input: Input,\n _?: ValidationOptions,\n path: readonly string[] = []\n ): readonly ValidationErrorMessage[] {\n if (!isValid(input)) {\n return [\n {\n message: createValidationExpectationMessage(\n expectationMessage,\n input,\n path,\n inputStringify\n ),\n path,\n },\n ]\n }\n return []\n },\n\n assert: (\n input: Input,\n origin?: string,\n path: readonly string[] = []\n ): asserts input is Output => {\n if (!isValid(input)) {\n throw new ValidationError(\n createValidationExpectationMessage(\n expectationMessage,\n input,\n path,\n inputStringify\n ),\n origin,\n path\n )\n }\n },\n }\n}\n\n/**\n * Creates a new deep validator.\n *\n * For a shallow validator which validates one value, use {@link createValidator}.\n *\n * @param description Describes the validator.\n * @param validate Returns an array of validation failures.\n */\nexport function createDeepValidator<Output extends Input, Input = unknown>(\n description: string,\n validate: (\n input: Input,\n options: ValidationOptions,\n path: readonly string[]\n ) => readonly ValidationErrorMessage[]\n): Validator<Output, Input> {\n return {\n description,\n\n isValid(input: Input): input is Output {\n return validate(input, { all: false }, []).length === 0\n },\n\n validate(\n input: Input,\n options?: ValidationOptions,\n path: readonly string[] = []\n ): readonly ValidationErrorMessage[] {\n return validate(input, options ?? { all: false }, path)\n },\n\n assert: (\n input: Input,\n origin?: string,\n path: readonly string[] = []\n ): asserts input is Output => {\n const errors = validate(input, { all: false }, path)\n if (errors.length) {\n const error = errors[0]\n throw new ValidationError(error.message, origin, error.path)\n }\n },\n }\n}\n", "/*\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { substitute } from '@amazon/vinyl-util'\nimport type { ValidationErrorMessage, Validator } from './Validator'\nimport {\n createDeepValidator,\n createValidationExpectationMessage,\n} from './Validator'\n\n/*\n * @brief\n * orValidators will union an arbitrary number of validators.\n * input type is always type any; it's not strictly necessary for all validators to accept the same\n * input type. For example, if validatorA asserts that a value is not null, validatorB can safely\n * assume its input is not null.\n * output type will be the union of the validator outputs up to 5 validators, 6 or more will be\n * type any.\n */\n\n/**\n * @private\n */\nconst locale = {\n /**\n * {value} - The child validators' descriptions, joined with `separator`.\n */\n template: '({value})',\n\n /**\n * The separator with which to join child validator descriptions.\n */\n separator: ' | ',\n} as const\n\n/**\n * Validates that one of the given validators pass.\n */\nexport function orValidators<A, B>(\n validatorA: Validator<A, any>,\n validatorB: Validator<B, any>\n): Validator<A | B, any>\n\n/**\n * Validates that one of the given validators pass.\n */\nexport function orValidators<A, B, C>(\n validatorA: Validator<A, any>,\n validatorB: Validator<B, any>,\n validatorC: Validator<C, any>\n): Validator<A | B | C, any>\n\n/**\n * Validates that one of the given validators pass.\n */\nexport function orValidators<A, B, C, D>(\n validatorA: Validator<A, any>,\n validatorB: Validator<B, any>,\n validatorC: Validator<C, any>,\n validatorD: Validator<D, any>\n): Validator<A | B | C | D, any>\n\n/**\n * Validates that one of the given validators pass.\n */\nexport function orValidators<A, B, C, D, E>(\n validatorA: Validator<A, any>,\n validatorB: Validator<B, any>,\n validatorC: Validator<C, any>,\n validatorD: Validator<D, any>,\n validatorE: Validator<E, any>\n): Validator<A | B | C | D | E, any>\n\nexport function orValidators(\n ...validators: Validator<any, any>[]\n): Validator<any, any>\n\n/**\n * Validates that one of the given validators pass.\n *\n * If all validators fail, the validator that produced an error at the deepest path will have its\n * error message bubbled. If all validators failed at the current depth, a concatenation of\n * validator descriptions will be used.\n *\n * For example:\n * `orValidators(number(), string()).validate(false)` will produce the message:\n * 'Expected (number | string), but was false, At: '\n *\n * And:\n * `orValidators(number(), object({ childProp: number() })).validate({ childProp: 'not-a-number' })`\n * will produce:\n * 'Expected number, but was \"not-a-number\", At: childProp'\n *\n * @param validators The validators to test.\n */\nexport function orValidators(\n ...validators: Validator<any, any>[]\n): Validator<any, any> {\n const description = substitute(locale.template, {\n value: validators.map((v) => v.description).join(locale.separator),\n })\n\n return createDeepValidator(description, (input, options, path) => {\n let longestErrors: readonly ValidationErrorMessage[] = []\n let longestPath = 0\n for (const validator of validators) {\n const errors = validator.validate(input, options, path)\n if (!errors.length) return errors\n // Take the deepest error to bubble.\n const pathLength = errors.reduce(\n (max, m) => Math.max(m.path.length, max),\n 0\n )\n if (pathLength >= longestPath) {\n longestErrors = errors\n longestPath = pathLength\n }\n }\n return longestPath > path.length\n ? longestErrors\n : [\n {\n message: createValidationExpectationMessage(\n description,\n input,\n path\n ),\n path,\n },\n ]\n })\n}\n", "/*\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { IllegalArgumentError, invariant, type Maybe } from '@amazon/vinyl-util'\nimport { andValidators } from './andValidators'\nimport type {\n ValidationErrorMessage,\n ValidationOptions,\n Validator,\n} from './Validator'\nimport type {\n PropertyValidator,\n PropertyValidatorOptions,\n PropertyValidatorWithOptions,\n} from './PropertyValidator'\n\nconst requiredValidationOptions = {\n optional: false,\n} as const satisfies PropertyValidatorOptions\n\n/**\n * A base class for validation state.\n * Provides methods for chaining.\n *\n * Subclasses should not override constructors.\n */\nexport abstract class SchemaBase<T> implements PropertyValidator<\n T,\n { readonly optional: false }\n> {\n __type = /* @__PURE__ */ invariant<T>()\n\n private readonly validator: Validator<T>\n private _options = requiredValidationOptions\n\n get options() {\n return this._options\n }\n\n /**\n * Constructs the first link in a schema chain.\n *\n * @param currentValidator\n */\n constructor(currentValidator: Validator<any, any>)\n\n /**\n * Constructs linking to the given previous schema.\n *\n * @param currentValidator\n * @param previousSchema\n * @param operation\n */\n constructor(\n currentValidator: Validator<any, any>,\n previousSchema: SchemaBase<any>,\n operation: (\n validatorA: Validator<any>,\n validatorB: Validator<any, any>\n ) => Validator<T>\n )\n\n constructor(\n private readonly currentValidator: Validator<any, any>,\n private readonly previousSchema?: Maybe<SchemaBase<any>>,\n private readonly operation?: Maybe<\n (\n validatorA: Validator<any>,\n validatorB: Validator<any, any>\n ) => Validator<T>\n >\n ) {\n this.validator =\n operation == null\n ? currentValidator\n : operation(previousSchema!, currentValidator)\n }\n\n get description(): string {\n return this.validator.description\n }\n\n readonly assert: (\n input: unknown,\n origin?: string,\n path?: readonly string[]\n ) => asserts input is T = (input, origin?, path?): asserts input is T => {\n this.validator.assert(input, origin, path)\n }\n\n readonly isValid: (input: unknown) => input is T = (\n input: unknown\n ): input is T => this.validator.isValid(input)\n\n readonly validate = (\n input: unknown,\n options?: ValidationOptions,\n path?: readonly string[]\n ): readonly ValidationErrorMessage[] =>\n this.validator.validate(input, options, path)\n\n /**\n * Clones this schema, transforming all validators with the given mutator.\n *\n * @param transform A transformer which takes an existing validator in the chain and returns\n * a new one. Validators should be considered to be immutable; transform should not change the\n * input but instead return a new validator.\n */\n protected clone(\n transform: (validator: Validator<any>) => Validator<any> = (v) => v\n ): any {\n const cloned = this.operation\n ? this.self(\n transform(this.currentValidator),\n this.previousSchema!.clone(transform),\n this.operation\n )\n : this.self(transform(this.currentValidator))\n cloned._options = this._options\n return cloned\n }\n\n protected self(current: Validator<any, any>): any\n\n protected self(\n currentValidator: Validator<any, any>,\n previousSchema: SchemaBase<any> | undefined,\n operation:\n | ((\n validatorA: Validator<any>,\n validatorB: Validator<any, any>\n ) => Validator<T>)\n | undefined\n ): any\n\n protected self(\n current: Validator<any, any>,\n previous?: SchemaBase<any>,\n operation?: (\n validatorA: Validator<any>,\n validatorB: Validator<any, any>\n ) => Validator<T> | undefined\n ): any {\n if (this.constructor.length > 3) {\n throw new IllegalArgumentError(\n 'constructor should have at most three required arguments'\n )\n }\n return new (this.constructor as any)(current, previous, operation)\n }\n\n /**\n * Constructs a new schema with a validator chaining the current validator with the\n * provided next in an AND operation.\n *\n * @param nextValidator The validator to run after the current.\n * @return Returns a new Schema instance the same class with a new validator chaining the\n * current validator with the given next in an AND operation.\n */\n protected chain(nextValidator: Validator<any, any>): any {\n return this.self(nextValidator, this, andValidators)\n }\n\n optional(): PropertyValidatorWithOptions<\n this,\n T,\n { readonly optional: true }\n > {\n const cloned = this.clone()\n cloned._options = {\n ...cloned.options,\n optional: true,\n }\n return cloned\n }\n\n required(): PropertyValidatorWithOptions<\n this,\n T,\n { readonly optional: false }\n > {\n const cloned = this.clone()\n cloned._options = {\n ...cloned.options,\n optional: false,\n }\n return cloned\n }\n}\n", "/*\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { andValidators } from './andValidators'\nimport { orValidators } from './orValidators'\nimport { SchemaBase } from './SchemaBase'\nimport type { Validator } from './Validator'\nimport { createValidator } from './Validator'\n\nconst locale = {\n null: 'null',\n nullish: 'nullish',\n undefined: 'undefined',\n} as const\n\nexport const valueValidators = {\n any(): Validator<any> {\n // no need for localization, validator cannot fail.\n return createValidator('', () => true)\n },\n\n /**\n * Creates a validator that asserts that the input is nullish.\n */\n nullish(): Validator<null | undefined> {\n return createValidator(locale.nullish, (input) => input == null)\n },\n\n /**\n * Creates a validator that asserts that the input is strictly null.\n */\n null(): Validator<null> {\n return createValidator(locale.null, (input) => input === null)\n },\n\n /**\n * Creates a validator that asserts that the input is strictly undefined.\n */\n undefined(): Validator<undefined> {\n return createValidator(locale.undefined, (input) => input === undefined)\n },\n} as const\n\nexport class ValueSchema<T> extends SchemaBase<T> {\n /**\n * Prepends this validator allowing for null or undefined.\n */\n maybe(): ValueSchema<T | undefined | null> {\n return this.or(valueValidators.nullish())\n }\n\n /**\n * Prepends this validator allowing for null.\n */\n orNull(): ValueSchema<T | null> {\n return this.or(valueValidators.null())\n }\n\n /**\n * Prepends this validator allowing for undefined.\n */\n orUndefined(): ValueSchema<T | undefined> {\n return this.or(valueValidators.undefined())\n }\n\n /**\n * Returns a validator that asserts if this validator and the next passes.\n *\n * @see andValidators\n *\n * @param nextValidator The validator to run after the current.\n * @return Returns a new ValueSchema intersecting this validator and the next.\n */\n and<U>(nextValidator: Validator<U>): ValueSchema<T & U> {\n return new ValueSchema(nextValidator, this, andValidators)\n }\n\n /**\n * Returns a validator that asserts if this validator or the next passes.\n *\n * Implementation note:\n * subclasses should not change the schema instance returned unless all chainable validators\n * accept input type 'unknown'.\n *\n * @param nextValidator The validator to run after the current.\n * @return Returns a new ValueSchema providing the union of this validator and the next.\n */\n or<U>(nextValidator: Validator<U, any>): ValueSchema<T | U> {\n return new ValueSchema(nextValidator, this, orValidators)\n }\n}\n", "/*\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport type { Fun } from '@amazon/vinyl-util'\nimport { substitute } from '@amazon/vinyl-util'\nimport { ValueSchema } from './ValueSchema'\nimport type { Validator } from './Validator'\nimport { createValidator } from './Validator'\nimport { typeOfValidators } from './typeOfValidators'\n\n/**\n * @private\n */\nconst locale = {\n length: 'at most {value} arguments',\n actualLength: '{value} arguments',\n} as const\n\nexport const functionValidators = {\n length(max: number): Validator<Fun, Fun> {\n return createValidator(\n substitute(locale.length, { value: max }),\n (input) => input.length <= max,\n (input) => substitute(locale.actualLength, { value: input.length })\n )\n },\n} as const\n\nexport class FunctionSchema<T extends Fun> extends ValueSchema<T> {\n private static _base: FunctionSchema<Fun> | null = null\n\n /**\n * The base Function validator validating that the input is a function.\n */\n static get base(): FunctionSchema<Fun> {\n if (this._base == null)\n this._base = new FunctionSchema(typeOfValidators.func)\n return this._base\n }\n\n length(max: number): FunctionSchema<T> {\n return this.chain(functionValidators.length(max))\n }\n\n /**\n * Casts the function signature.\n * Function signatures, except for their required number of parameters, cannot be\n * meaningfully validated.\n */\n cast<T extends Fun>(): FunctionSchema<T> {\n return this as any\n }\n}\n", "/*\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport type { FromTypeof, Typeof } from '@amazon/vinyl-util'\nimport { substitute } from '@amazon/vinyl-util'\nimport type { Validator } from './Validator'\nimport { createValidator } from './Validator'\n\n/**\n * @private\n */\nconst locale = {\n template: 'type {value}',\n} as const\n\n/**\n * Creates a validator that validates that the input is not nullish and its `typeof` matches the\n * expected value.\n *\n * Note: while `typeof null === 'object'`, `typeOfValidator('object')` will assert that its\n * input is not nullish.\n *\n * @param expected\n */\nfunction typeOfValidator<T extends Typeof>(\n expected: T\n): Validator<NonNullable<FromTypeof<T>>> {\n return createValidator(\n substitute(locale.template, { value: expected }),\n (input: unknown): input is NonNullable<FromTypeof<T>> => {\n return input != null && typeof input === expected\n }\n )\n}\n\nconst typeOfValidatorCache: any = {}\n\nfunction cachedTypeOfValidator<T extends Typeof>(\n type: T\n): Validator<NonNullable<FromTypeof<T>>> {\n if (!(type in typeOfValidatorCache)) {\n typeOfValidatorCache[type] = typeOfValidator(type)\n }\n return typeOfValidatorCache[type]\n}\n\n/**\n * Validators asserting typeof input matches the expected value.\n *\n * Note: bigint is omitted; not all supported platforms can use BigInt.\n */\nexport const typeOfValidators = {\n get boolean() {\n return cachedTypeOfValidator('boolean')\n },\n get func() {\n return cachedTypeOfValidator('function')\n },\n get number() {\n return cachedTypeOfValidator('number')\n },\n get object() {\n return cachedTypeOfValidator('object')\n },\n get string() {\n return cachedTypeOfValidator('string')\n },\n get symbol() {\n return cachedTypeOfValidator('symbol')\n },\n} as const\n", "/*\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport type { SetElementType } from '@amazon/vinyl-util'\nimport { substitute } from '@amazon/vinyl-util'\nimport type { ValidationErrorMessage, Validator } from './Validator'\nimport { createDeepValidator, createValidator } from './Validator'\nimport { ValueSchema } from './ValueSchema'\n\n/**\n * @private\n */\nconst locale = {\n set: 'Set',\n withElements: 'Set<{value}>',\n} as const\n\nexport const setValidators = {\n /**\n * Creates a validator that asserts that the input is a set.\n */\n isSet(): Validator<Set<unknown>> {\n return createValidator(\n locale.set,\n (input: unknown) => input instanceof Set\n )\n },\n\n /**\n * Creates a validator that asserts that every element passes the given validator.\n *\n * @param elementValidator\n */\n withElements<U>(\n elementValidator: Validator<U>\n ): Validator<Set<U>, ReadonlySet<unknown>> {\n return createDeepValidator(\n substitute(locale.withElements, {\n value: elementValidator.description,\n }),\n (input, options, path) => {\n const errors: ValidationErrorMessage[] = []\n let i = 0\n for (const element of input) {\n errors.push(\n ...elementValidator.validate(\n element,\n options,\n path.concat(i.toString())\n )\n )\n if (!options.all && errors.length) return errors\n i++\n }\n return errors\n }\n )\n },\n} as const\n\nexport class SetSchema<T extends ReadonlySet<unknown>> extends ValueSchema<T> {\n private static _base: SetSchema<Set<unknown>> | null = null\n\n /**\n * The base SetSchema instance validating that the input is a Set.\n */\n static get base(): SetSchema<Set<unknown>> {\n if (this._base == null)\n this._base = new SetSchema(setValidators.isSet())\n return this._base\n }\n\n /**\n * Creates a validator that asserts that every element passes the given validator.\n *\n * @param elementValidator\n */\n withElements<U>(\n elementValidator: Validator<U>\n ): SetSchema<Set<SetElementType<T> & U>> {\n return this.chain(setValidators.withElements(elementValidator))\n }\n\n /**\n * Casts to a readonly set.\n * This is a shallow cast, elements of the array will not be changed.\n */\n readonly(): SetSchema<ReadonlySet<SetElementType<T>>> {\n return this as any\n }\n\n /**\n * Casts the parameter type.\n */\n cast<T extends ReadonlySet<unknown>>(): SetSchema<T> {\n return this as any\n }\n}\n", "/*\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { substitute } from '@amazon/vinyl-util'\nimport { ValueSchema } from './ValueSchema'\nimport { typeOfValidators } from './typeOfValidators'\nimport type { Validator } from './Validator'\nimport { createValidator } from './Validator'\n\nconst locale = {\n gte: 'at least {value}',\n gt: 'greater than {value}',\n lte: 'at most {value}',\n lt: 'less than {value}',\n within: 'within {min} and {max}',\n safeInteger: 'safe integer',\n finite: 'finite',\n} as const\n\nexport const numberValidators = {\n /**\n * Creates a validator that asserts that the input number is at least the provided minimum\n * value.\n *\n * @param min The minimum (inclusive) the value may be.\n */\n gte(min: number): Validator<number, number> {\n return createValidator(\n substitute(locale.gte, { value: min }),\n (input) => input >= min\n )\n },\n\n /**\n * Creates a validator that asserts that the input number is greater than the provided minimum\n * value.\n *\n * @param min The minimum (exclusive) the value may be.\n */\n gt(min: number): Validator<number, number> {\n return createValidator(\n substitute(locale.gt, { value: min }),\n (input) => input > min\n )\n },\n\n /**\n * Creates a validator that asserts that the input number is at most the provided maximum\n * value.\n *\n * @param max The maximum (inclusive) the value may be.\n */\n lte(max: number): Validator<number, number> {\n return createValidator(\n substitute(locale.lte, { value: max }),\n (input) => input <= max\n )\n },\n\n /**\n * Creates a validator that asserts that the input number is less than the provided maximum\n * value.\n *\n * @param max The maximum (exclusive) the value may be.\n */\n lt(max: number): Validator<number, number> {\n return createValidator(\n substitute(locale.lt, { value: max }),\n (input) => input < max\n )\n },\n\n /**\n * Creates a validator that asserts that the input number is at least the provided minimum\n * and at most the provided maximum values.\n *\n * @param min The minimum (inclusive) value the input may be.\n * @param max The maximum (inclusive) value the input may be.\n */\n within(min: number, max: number): Validator<number, number> {\n return createValidator(\n substitute(locale.within, { min, max }),\n (input) => input >= min && input <= max\n )\n },\n\n /**\n * Creates a validator that asserts that the input number is finite.\n */\n finite(): Validator<number, number> {\n return createValidator(locale.finite, (input) => Number.isFinite(input))\n },\n\n /**\n * Creates a validator that asserts that the input number is a safe integer.\n */\n safeInteger(): Validator<number, number> {\n return createValidator(locale.safeInteger, (input) =>\n Number.isSafeInteger(input)\n )\n },\n} as const\n\nexport class NumberSchema extends ValueSchema<number> {\n private static _base: NumberSchema | null = null\n\n /**\n * The base Object validator validating that the input is an object.\n */\n static get base(): NumberSchema {\n if (this._base == null)\n this._base = new NumberSchema(typeOfValidators.number)\n return this._base\n }\n\n /**\n * Creates a validator that asserts that the input number is at least the provided minimum\n * value.\n *\n * @param min The minimum (inclusive) the value may be.\n */\n gte(min: number): this {\n return this.chain(numberValidators.gte(min))\n }\n\n /**\n * Creates a validator that asserts that the input number is greater than the provided minimum\n * value.\n *\n * @param min The minimum (exclusive) the value may be.\n */\n gt(min: number): this {\n return this.chain(numberValidators.gt(min))\n }\n\n /**\n * Creates a validator that asserts that the input number is at most the provided maximum\n * value.\n *\n * @param max The maximum (inclusive) the value may be.\n */\n lte(max: number): this {\n return this.chain(numberValidators.lte(max))\n }\n\n /**\n * Creates a validator that asserts that the input number is less than the provided maximum\n * value.\n *\n * @param max The maximum (exclusive) the value may be.\n */\n lt(max: number): this {\n return this.chain(numberValidators.lt(max))\n }\n\n /**\n * Creates a validator that asserts that the input number is at least the provided minimum\n * and at most the provided maximum values.\n *\n * @param min The minimum (inclusive) value the input may be.\n * @param max The maximum (inclusive) value the input may be.\n */\n within(min: number, max: number): this {\n return this.chain(numberValidators.within(min, max))\n }\n\n /**\n * Creates a validator that asserts that the input number is finite.\n */\n finite(): this {\n return this.chain(numberValidators.finite())\n }\n\n /**\n * Creates a validator that asserts that the input number is a safe integer.\n */\n safeInteger(): this {\n return this.chain(numberValidators.safeInteger())\n }\n}\n", "/*\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport type {\n AnyRecord,\n IsPropertyOptional,\n PartialDeep,\n} from '@amazon/vinyl-util'\nimport { merge, ownKeys, substitute } from '@amazon/vinyl-util'\nimport type { ValidatorWithPartial } from './ValidatorWithPartial'\nimport { maybeToDeepPartial, maybeToPartial } from './ValidatorWithPartial'\nimport { ValueSchema } from './ValueSchema'\nimport { typeOfValidators } from './typeOfValidators'\nimport type { ValidationErrorMessage } from './Validator'\nimport { createDeepValidator } from './Validator'\nimport type { PropertyValidator } from './PropertyValidator'\nimport type { Equal } from '@amazon/vinyl-util'\n\n/**\n * @private\n */\nconst locale = {\n extend: '{\\n{body}\\n}',\n prop: '{key}: {value}',\n propSeparator: ',\\n',\n indent: ' ',\n required: `property '{key}' is required`,\n} as const\n\nexport const objectValidators = {\n /**\n * Creates a validator that validates the input has properties that pass their respective\n * validators.\n *\n * @param propertyValidators\n */\n properties<U extends object>(propertyValidators: {\n readonly [P in keyof U]-?: PropertyValidator<\n Required<U>[P],\n { optional: IsPropertyOptional<U, P> }\n >\n }): ValidatorWithPartial<U, object> {\n const propertiesDescriptions: string[] = []\n const keys = ownKeys(propertyValidators)\n for (const key of keys) {\n const validator = propertyValidators[key]\n propertiesDescriptions.push(\n substitute(locale.prop, {\n key: String(key) + (validator.options.optional ? '?' : ''),\n value: validator.description,\n })\n )\n }\n const description = substitute(locale.extend, {\n body: propertiesDescriptions\n .join(locale.propSeparator)\n .split('\\n')\n .map((line) => locale.indent + line)\n .join('\\n'),\n })\n const validator = createDeepValidator(\n description,\n (input: any, options, path) => {\n const errors: ValidationErrorMessage[] = []\n for (const key of keys) {\n const validator = propertyValidators[key]\n if (key in input) {\n const value = input[key]\n errors.push(\n ...validator.validate(\n value,\n options,\n path.concat(String(key))\n )\n )\n } else {\n // Missing property\n if (!validator.options.optional) {\n errors.push({\n message: substitute(locale.required, { key }),\n path: path.concat(String(key)),\n })\n }\n }\n if (!options.all && errors.length) return errors\n }\n return errors\n }\n )\n return merge(validator, {\n partial(): ValidatorWithPartial<Partial<U>, object> {\n const optionalPropertyValidators = {} as any\n for (const key of keys) {\n optionalPropertyValidators[key] =\n propertyValidators[key].optional()\n }\n return objectValidators.properties<Partial<U>>(\n optionalPropertyValidators\n )\n },\n\n partialDeep(): ValidatorWithPartial<PartialDeep<U>, object> {\n const optionalPropertyValidators = {} as any\n for (const key of keys) {\n optionalPropertyValidators[key] = maybeToDeepPartial(\n propertyValidators[key].optional()\n )\n }\n return objectValidators.properties<PartialDeep<U>>(\n optionalPropertyValidators\n )\n },\n })\n },\n} as const\n\n/**\n * Chainable object validators.\n */\nexport class ObjectSchema<T extends object>\n extends ValueSchema<T>\n implements ValidatorWithPartial<T, unknown>\n{\n private static _base: ObjectSchema<AnyRecord> | null = null\n\n /**\n * The base Object validator validating that the input is an object.\n */\n static get base(): ObjectSchema<AnyRecord> {\n if (this._base == null)\n this._base = new ObjectSchema(typeOfValidators.object)\n return this._base\n }\n\n /**\n * Creates a validator that validates the input has properties that pass their respective\n * validators.\n *\n * @param propertyValidators\n */\n extend<U extends object>(\n propertyValidators: NoInfer<ExtendedPropertyValidators<T, U>>\n ): ObjectSchema<U> {\n return this.chain(objectValidators.properties(propertyValidators))\n }\n\n /**\n * Allows all properties to be undefined.\n */\n partial(): ObjectSchema<Partial<T>> {\n return this.clone(maybeToPartial)\n }\n\n /**\n * Allows all recursive properties to be undefined.\n */\n partialDeep(): ObjectSchema<PartialDeep<T>> {\n return this.clone(maybeToDeepPartial)\n }\n\n /**\n * Casts the type parameter.\n */\n cast<T extends object>(): ObjectSchema<T> {\n return this as any\n }\n}\n\nexport type ExtendedPropertyValidators<T extends object, U extends object> = {\n // REQUIRED:\n // - Keys in U but not in T\n // - Keys in both where U[K] !== T[K]\n [K in keyof U as K extends keyof T\n ? Equal<U[K], T[K]> extends true\n ? never\n : K\n : K]-?: ExtendedPropertyValidator<U & T, K>\n} & {\n // OPTIONAL:\n // - Keys where U[K] === T[K] (and therefore K \u2208 keyof T)\n [K in keyof U as K extends keyof T\n ? Equal<U[K], T[K]> extends true\n ? K\n : never\n : never]?: ExtendedPropertyValidator<U & T, K>\n}\n\nexport type ExtendedPropertyValidator<\n U extends object,\n P extends keyof U,\n> = PropertyValidator<Required<U>[P], { optional: IsPropertyOptional<U, P> }>\n", "/*\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport type { PartialDeep } from '@amazon/vinyl-util'\nimport type { Validator } from './Validator'\n\nexport interface ValidatorWithPartial<\n Output extends Input,\n Input,\n> extends Validator<Output, Input> {\n partial(): ValidatorWithPartial<Partial<Output> & Input, Input>\n partialDeep(): ValidatorWithPartial<PartialDeep<Output> & Input, Input>\n}\n\n/**\n * Returns true if the given validator is an object validator.\n * @param validator\n */\nexport function isValidatorWithPartial<Output extends Input, Input>(\n validator: Validator<Output, Input>\n): validator is ValidatorWithPartial<Output, Input> {\n return 'partial' in validator && 'partialDeep' in validator\n}\n\n/**\n * If the given validator is an object validator, it will be cloned to a deep partial validator,\n * otherwise returns the validator as is.\n *\n * @param validator\n */\nexport function maybeToDeepPartial(validator: Validator<any>): Validator<any> {\n return isValidatorWithPartial(validator)\n ? validator.partialDeep()\n : validator\n}\n\n/**\n * If the given validator is an object validator, it will be cloned to a partial validator,\n * otherwise returns the validator as is.\n *\n * @param validator\n */\nexport function maybeToPartial(validator: Validator<any>): Validator<any> {\n return isValidatorWithPartial(validator) ? validator.partial() : validator\n}\n", "/*\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport type { ReadonlyRecord } from '@amazon/vinyl-util'\nimport { ownKeys, substitute } from '@amazon/vinyl-util'\nimport { ValueSchema } from './ValueSchema'\nimport { StringSchema } from './StringSchema'\nimport { typeOfValidators } from './typeOfValidators'\nimport type { ValidationErrorMessage, Validator } from './Validator'\nimport { createDeepValidator } from './Validator'\n\n/**\n * @private\n */\nconst locale = {\n record: '{ [key: {key}]: {value} }',\n} as const\n\nexport const recordValidators = {\n /**\n * Returns a validator that asserts that the object's own enumerable properties has keys and\n * values that match their respective validators.\n *\n * Prototype members are not included.\n * Numeric keys are validated as strings. For example the object `{ [0]: 1 }` will be passed\n * to the key validator as '0'.\n *\n * @param keyValidator Validates each key.\n * @param valueValidator Validates each value.\n */\n record<K extends string | symbol, V>(\n keyValidator: Validator<K>,\n valueValidator: Validator<V>\n ): Validator<Record<K, V>, object> {\n return createDeepValidator(\n substitute(locale.record, {\n key: keyValidator.description,\n value: valueValidator.description,\n }),\n (input, options, path) => {\n const errors: ValidationErrorMessage[] = []\n for (const key of ownKeys(input)) {\n const keyStr = String(key)\n errors.push(\n ...keyValidator.validate(\n key,\n options,\n path.concat(`[${keyStr}]`)\n )\n )\n if (!options.all && errors.length) return errors\n const value = input[key]\n errors.push(\n ...valueValidator.validate(\n value,\n options,\n path.concat(keyStr)\n )\n )\n if (!options.all && errors.length) return errors\n }\n return errors\n }\n )\n },\n} as const\n\n/**\n * Chainable object validators for the Record type.\n */\nexport class RecordSchema<\n T extends ReadonlyRecord<keyof any, any>,\n> extends ValueSchema<T> {\n private static _base: RecordSchema<Record<keyof any, unknown>> | null = null\n\n /**\n * The base Object validator validating that the input is an object.\n */\n static get base(): RecordSchema<Record<keyof any, unknown>> {\n if (this._base == null)\n this._base = new RecordSchema(typeOfValidators.object)\n return this._base\n }\n\n private static get defaultKeyValidator(): StringSchema {\n return StringSchema.base\n }\n\n /**\n * Returns a validator that asserts that the object's own enumerable properties has keys and\n * values that match their respective validators.\n *\n * Prototype members are not included.\n * Numeric keys are validated as strings. For example the object `{ [0]: 1 }` will be passed\n * to the key validator as '0'.\n *\n * @param keyValidator Validates each key.\n * @param valueValidator Validates each value.\n */\n record<K extends string | symbol, V>(\n keyValidator: Validator<K>,\n valueValidator: Validator<V>\n ): RecordSchema<ReadonlyRecord<K, V>> {\n return this.chain(recordValidators.record(keyValidator, valueValidator))\n }\n\n /**\n * Returns a validator that asserts that the object's own enumerable properties has\n * string keys and values that match the given validator.\n *\n * Prototype members are not included.\n *\n * @param valueValidator Validates each value.\n */\n recordValues<V>(\n valueValidator: Validator<V>\n ): RecordSchema<Record<string, V>> {\n return this.record(RecordSchema.defaultKeyValidator, valueValidator)\n }\n\n /**\n * Casts to a ReadonlyRecord\n */\n readonly(): RecordSchema<\n T extends Record<infer K, infer V> ? ReadonlyRecord<K, V> : never\n > {\n return this as any\n }\n\n /**\n * Casts the type parameter.\n */\n cast<T extends ReadonlyRecord<keyof any, unknown>>(): RecordSchema<T> {\n return this as any\n }\n}\n", "/*\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { substitute } from '@amazon/vinyl-util'\nimport { ValueSchema } from './ValueSchema'\nimport { typeOfValidators } from './typeOfValidators'\nimport type { Validator } from './Validator'\nimport { createValidator } from './Validator'\n\n/**\n * @private\n */\nconst locale = {\n notEmpty: 'not empty',\n minLength: 'at least {value} characters',\n maxLength: 'at most {value} characters',\n noWhitespace: 'no whitespace characters',\n matches: 'matches {value}',\n} as const\n\nexport const stringValidators = {\n /**\n * Creates a validator that asserts that the input is not empty.\n */\n notEmpty(): Validator<string, string> {\n return createValidator(locale.notEmpty, (input) => input !== '')\n },\n\n /**\n * Creates a validator that asserts that the input string has at least the given minimum\n * length.\n *\n * @param min The string must be at least this length.\n */\n minLength(min: number): Validator<string, string> {\n return createValidator(\n substitute(locale.minLength, { value: min }),\n (input) => input.length >= min\n )\n },\n\n /**\n * Creates a validator that asserts that the input string has at most the given maximum\n * length.\n *\n * @param max The string must be at most this length.\n */\n maxLength(max: number): Validator<string, string> {\n return createValidator(\n substitute(locale.maxLength, { value: max }),\n (input) => input.length <= max\n )\n },\n\n /**\n * Creates a validator that asserts that the input string has no whitespace characters.\n * Whitespace characters include space, new line, carriage return, and tab.\n */\n noWhitespace(): Validator<string, string> {\n return createValidator(\n locale.noWhitespace,\n (input) => input.search(/\\s/g) === -1\n )\n },\n\n /**\n * Creates a validator that asserts that the input string matches the given regex.\n * @param regex\n */\n matches(regex: RegExp): Validator<string, string> {\n return createValidator(\n substitute(locale.matches, { value: regex.toString() }),\n (input) => {\n return regex.test(input)\n }\n )\n },\n} as const\n\nexport class StringSchema extends ValueSchema<string> {\n private static _base: StringSchema | null = null\n\n /**\n * The base SetSchema instance validating that the input is a Set.\n */\n static get base(): StringSchema {\n if (this._base == null)\n this._base = new StringSchema(typeOfValidators.string)\n return this._base\n }\n\n /**\n * Creates a validator that asserts that the input is not empty.\n */\n notEmpty(): StringSchema {\n return this.chain(stringValidators.notEmpty())\n }\n\n /**\n * Creates a validator that asserts that the input string has at least the given minimum\n * length.\n *\n * @param min The string must be at least this length.\n */\n minLength(min: number): StringSchema {\n return this.chain(stringValidators.minLength(min))\n }\n\n /**\n * Creates a validator that asserts that the input string has at most the given maximum\n * length.\n *\n * @param max The string must be at most this length.\n */\n maxLength(max: number): StringSchema {\n return this.chain(stringValidators.maxLength(max))\n }\n\n /**\n * Creates a validator that asserts that the input string has no whitespace characters.\n * Whitespace characters include space, new line, carriage return, and tab.\n */\n noWhitespace(): StringSchema {\n return this.chain(stringValidators.noWhitespace())\n }\n\n /**\n * Creates a validator that asserts that the input string matches the given regex.\n * @param regex\n */\n matches(regex: RegExp): StringSchema {\n return this.chain(stringValidators.matches(regex))\n }\n}\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACKA,IAAAA,sBAOO;;;ACNP,IAAAC,qBAA2B;;;ACD3B,IAAAC,qBAA2B;;;ACA3B,wBAAgD;AAChD,IAAAC,qBAA8C;AA4E9C,IAAM,kBAAkB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQpB,UAAU;AACd;AAUO,SAAS,mCACZ,oBACA,OACA,MACA,iBAA2C,CAACC,eACxC,sCAAkBA,QAAO,GAAG,GAC1B;AACN,aAAO,+BAAW,gBAAgB,UAAU;AAAA,IACxC,UAAU;AAAA,IACV,QAAQ,eAAe,KAAK;AAAA,IAC5B,MAAM,KAAK,KAAK,GAAG;AAAA,EACvB,CAAC;AACL;AAaO,SAAS,gBACZ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AO,IAAI,YAAY,iBAAiB,MAAM;AAClD;AAKO,SAAS,mBAA2C;AACvD,SAAO,IAAI,YAAY,gBAAgB,UAAU,CAAC;AACtD;AAQO,SAAS,OACZ,oBACA,SACA,iBAA6C,CAAC,cAC1C,uCAAkB,OAAO,GAAG,GAClB;AACd,SAAO,IAAI;AAAA,IACP,gBAAgB,oBAAoB,SAAS,cAAc;AAAA,EAC/D;AACJ;",
|
|
6
6
|
"names": ["import_vinyl_util", "import_vinyl_util", "import_vinyl_util", "import_vinyl_util", "input", "import_vinyl_util", "locale", "import_vinyl_util", "locale", "locale", "import_vinyl_util", "import_vinyl_util", "locale", "locale", "import_vinyl_util", "locale", "import_vinyl_util", "locale", "import_vinyl_util", "locale", "validator", "import_vinyl_util", "import_vinyl_util", "locale", "locale", "locale"]
|
|
7
7
|
}
|
package/dist/index.js
CHANGED
|
@@ -189,9 +189,9 @@ var requiredValidationOptions = {
|
|
|
189
189
|
};
|
|
190
190
|
var SchemaBase = class {
|
|
191
191
|
constructor(currentValidator, previousSchema, operation) {
|
|
192
|
-
this
|
|
193
|
-
this
|
|
194
|
-
this
|
|
192
|
+
__publicField(this, "currentValidator", currentValidator);
|
|
193
|
+
__publicField(this, "previousSchema", previousSchema);
|
|
194
|
+
__publicField(this, "operation", operation);
|
|
195
195
|
__publicField(this, "__type", /* @__PURE__ */ invariant());
|
|
196
196
|
__publicField(this, "validator");
|
|
197
197
|
__publicField(this, "_options", requiredValidationOptions);
|