@amazon/vinyl-validation 3.2.2 → 3.2.3-next.20261001143710
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +5 -3
- package/dist/index.cjs.map +2 -2
- package/dist/index.js +5 -3
- package/dist/index.js.map +2 -2
- package/dist/types/current/tsconfig.tsbuildinfo +1 -1
- package/dist/types/current/validation/ArraySchema.d.ts.map +1 -1
- package/dist/types/current/validation/ArraySchema.js +5 -1
- package/dist/types/current/validation/NumberSchema.d.ts +1 -1
- package/dist/types/current/validation/NumberSchema.js +1 -1
- package/dist/types/current/validation/StringSchema.d.ts +1 -1
- package/dist/types/current/validation/StringSchema.js +1 -1
- package/dist/types/ts3.7/validation/NumberSchema.d.ts +1 -1
- package/dist/types/ts3.7/validation/StringSchema.d.ts +1 -1
- package/dist/types/ts4.1/validation/NumberSchema.d.ts +1 -1
- package/dist/types/ts4.1/validation/StringSchema.d.ts +1 -1
- package/dist/types/ts4.7/validation/NumberSchema.d.ts +1 -1
- package/dist/types/ts4.7/validation/StringSchema.d.ts +1 -1
- package/dist/unit/types/current/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -560,7 +560,9 @@ var arrayValidators = {
|
|
|
560
560
|
(length) => length === validators.length
|
|
561
561
|
);
|
|
562
562
|
return createDeepValidator(
|
|
563
|
-
(0, import_vinyl_util7.substitute)(locale4.tuple, {
|
|
563
|
+
(0, import_vinyl_util7.substitute)(locale4.tuple, {
|
|
564
|
+
value: validators.map((validator) => validator.description).join(", ")
|
|
565
|
+
}),
|
|
564
566
|
(input, options, path) => {
|
|
565
567
|
const errors = [];
|
|
566
568
|
errors.push(
|
|
@@ -870,7 +872,7 @@ var numberValidators = {
|
|
|
870
872
|
};
|
|
871
873
|
var _NumberSchema = class _NumberSchema extends ValueSchema {
|
|
872
874
|
/**
|
|
873
|
-
* The base
|
|
875
|
+
* The base NumberSchema instance validating that the input is a number.
|
|
874
876
|
*/
|
|
875
877
|
static get base() {
|
|
876
878
|
if (this._base == null)
|
|
@@ -1163,7 +1165,7 @@ var stringValidators = {
|
|
|
1163
1165
|
};
|
|
1164
1166
|
var _StringSchema = class _StringSchema extends ValueSchema {
|
|
1165
1167
|
/**
|
|
1166
|
-
* The base
|
|
1168
|
+
* The base StringSchema instance validating that the input is a string.
|
|
1167
1169
|
*/
|
|
1168
1170
|
static get base() {
|
|
1169
1171
|
if (this._base == null)
|
package/dist/index.cjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/index.ts", "../src/validation/andValidators.ts", "../src/validation/Validator.ts", "../src/validation/JsonSchema.ts", "../src/validation/ArraySchema.ts", "../src/validation/orValidators.ts", "../src/validation/SchemaBase.ts", "../src/validation/ValueSchema.ts", "../src/validation/FunctionSchema.ts", "../src/validation/typeOfValidators.ts", "../src/validation/NumberSchema.ts", "../src/validation/ObjectSchema.ts", "../src/validation/ValidatorWithPartial.ts", "../src/validation/RecordSchema.ts", "../src/validation/StringSchema.ts", "../src/validation/SetSchema.ts", "../src/validation/validators.ts"],
|
|
4
|
-
"sourcesContent": ["/** Auto-generated from build scripts */\nexport * from './validation/andValidators'\nexport * from './validation/ArraySchema'\nexport * from './validation/FunctionSchema'\nexport * from './validation/JsonSchema'\nexport * from './validation/NumberSchema'\nexport * from './validation/ObjectSchema'\nexport * from './validation/orValidators'\nexport * from './validation/PropertyValidator'\nexport * from './validation/RecordSchema'\nexport * from './validation/SchemaBase'\nexport * from './validation/SetSchema'\nexport * from './validation/StringSchema'\nexport * from './validation/typeOfValidators'\nexport * from './validation/Validator'\nexport * from './validation/validators'\nexport * from './validation/ValidatorWithPartial'\nexport * from './validation/ValueSchema'\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'\nimport { mergeJsonSchema } from './JsonSchema'\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 mergeJsonSchema(...validators.map((v) => v.jsonSchema))\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'\nimport type { JsonSchema } from './JsonSchema'\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 * The JSON Schema fragment this validator contributes, if any.\n *\n * Fragments compose the same way the {@link description} does: chaining validators with `and`\n * merges their fragments, and `or` unions them into an `anyOf`. Serialize a full schema with\n * {@link toJsonSchema}. A validator with no meaningful shape (for example a bare type check)\n * may omit this.\n */\n readonly jsonSchema?: JsonSchema | undefined\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 * @param jsonSchema The JSON Schema fragment this validator contributes, if any.\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 jsonSchema?: JsonSchema\n): Validator<Output, Input> {\n return {\n description: expectationMessage,\n jsonSchema,\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 * @param jsonSchema The JSON Schema fragment this validator contributes, if any.\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 jsonSchema?: JsonSchema\n): Validator<Output, Input> {\n return {\n description,\n jsonSchema,\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 { ownKeys } from '@amazon/vinyl-util'\nimport type { Validator } from './Validator'\n\n/**\n * The `type` keyword value of a JSON Schema node.\n */\nexport type JsonSchemaType =\n 'string' | 'number' | 'integer' | 'boolean' | 'object' | 'array' | 'null'\n\n/**\n * A JSON Schema definition (a draft-07 compatible subset) describing the shape a value must take.\n *\n * This is the serializable representation produced by {@link toJsonSchema}, suitable for handing to\n * an LLM as the shape it must produce. It intentionally mirrors zod-to-json-schema output for the\n * node types this library supports.\n */\nexport interface JsonSchema {\n readonly type?: JsonSchemaType | readonly JsonSchemaType[]\n\n /**\n * A human-readable description, attached to a schema node via its `describe` method.\n */\n readonly description?: string\n\n // Object\n readonly properties?: Readonly<Record<string, JsonSchema>>\n readonly required?: readonly string[]\n readonly additionalProperties?: boolean | JsonSchema\n\n // Array\n readonly items?: JsonSchema | readonly JsonSchema[]\n readonly additionalItems?: boolean\n readonly minItems?: number\n readonly maxItems?: number\n readonly uniqueItems?: boolean\n\n // String\n readonly minLength?: number\n readonly maxLength?: number\n readonly pattern?: string\n\n // Number\n readonly minimum?: number\n readonly maximum?: number\n readonly exclusiveMinimum?: number\n readonly exclusiveMaximum?: number\n\n // Enumeration\n readonly enum?: readonly unknown[]\n\n // Composition\n readonly anyOf?: readonly JsonSchema[]\n}\n\n/**\n * A source that can produce its own JSON Schema definition. Schema nodes implement this so that\n * per-node metadata (such as a `describe` description) is honored during serialization.\n */\nexport interface JsonSchemaProvider {\n toJsonSchema(): JsonSchema\n}\n\ntype MutableJsonSchema = {\n -readonly [K in keyof JsonSchema]: JsonSchema[K]\n}\n\n/**\n * Merges JSON Schema fragments into a single definition, later fragments taking precedence.\n *\n * This mirrors an intersection (`and`) of constraints: `properties` are combined and `required`\n * keys are unioned, while all other keywords are overridden by the last fragment that defines them.\n *\n * @param fragments The fragments to merge. `undefined` fragments are ignored.\n */\nexport function mergeJsonSchema(\n ...fragments: readonly (JsonSchema | undefined)[]\n): JsonSchema {\n const merged: MutableJsonSchema = {}\n for (const fragment of fragments) {\n if (fragment == null) continue\n for (const key of ownKeys(fragment)) {\n if (fragment[key] === undefined) continue\n if (key === 'properties') {\n merged.properties = {\n ...merged.properties,\n ...fragment.properties,\n }\n } else if (key === 'required') {\n merged.required = [\n ...new Set([\n ...(merged.required ?? []),\n ...(fragment.required as readonly string[]),\n ]),\n ]\n } else {\n // A homogeneous copy of one key; the key/value are drawn from the same fragment.\n merged[key] = fragment[key] as never\n }\n }\n }\n return merged\n}\n\n/**\n * Serializes a validator to a JSON Schema definition.\n *\n * Schema nodes ({@link JsonSchemaProvider}s) serialize themselves so that per-node metadata is\n * honored; other validators contribute their attached JSON Schema fragment, defaulting to the empty\n * schema (which matches any value) when none is attached.\n *\n * @param source The validator or schema node to serialize.\n */\nexport function toJsonSchema(source: Validator<any, any>): JsonSchema {\n const provider = source as Partial<JsonSchemaProvider>\n if (typeof provider.toJsonSchema === 'function') {\n return provider.toJsonSchema()\n }\n return { ...source.jsonSchema }\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'\nimport { toJsonSchema } from './JsonSchema'\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(\n locale.array,\n (input: unknown) => Array.isArray(input),\n undefined,\n { type: 'array' }\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 { type: 'array', items: toJsonSchema(elementValidator) }\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 type: 'array',\n items: validators.map((v) => toJsonSchema(v)),\n minItems: validators.length,\n maxItems: validators.length,\n additionalItems: false,\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 { minItems: min }\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 { maxItems: max }\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 { ValidationErrorMessage, Validator } from './Validator'\nimport {\n createDeepValidator,\n createValidationExpectationMessage,\n} from './Validator'\nimport type { JsonSchema } from './JsonSchema'\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 * Composes the child validators' JSON Schema fragments into a union.\n *\n * Branches with no fragment are skipped: JSON Schema has no representation for `undefined`, and a\n * value's optionality is instead conveyed by an object's `required` list. A single remaining branch\n * collapses to that branch rather than a redundant `anyOf`.\n */\nfunction unionJsonSchema(\n validators: readonly Validator<any, any>[]\n): JsonSchema | undefined {\n const branches = validators\n .map((v) => v.jsonSchema)\n .filter((fragment): fragment is JsonSchema => fragment != null)\n if (branches.length === 0) return undefined\n if (branches.length === 1) return branches[0]\n return { anyOf: branches }\n}\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(\n description,\n (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 unionJsonSchema(validators)\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'\nimport type { JsonSchema, JsonSchemaProvider } from './JsonSchema'\nimport { mergeJsonSchema } from './JsonSchema'\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>\n implements\n PropertyValidator<T, { readonly optional: false }>,\n JsonSchemaProvider\n{\n __type = /* @__PURE__ */ invariant<T>()\n\n private readonly validator: Validator<T>\n private _options = requiredValidationOptions\n private _jsonSchemaDescription?: string\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 /**\n * The composed JSON Schema fragment for this schema, including any {@link describe} description.\n * Composes through chaining the same way {@link description} does; serialize a complete\n * definition with {@link toJsonSchema}.\n */\n get jsonSchema(): JsonSchema | undefined {\n const base = this.validator.jsonSchema\n if (this._jsonSchemaDescription == null) return base\n return mergeJsonSchema(base, {\n description: this._jsonSchemaDescription,\n })\n }\n\n /**\n * Attaches a human-readable description to this schema, akin to zod's `describe`.\n * The description is metadata only; it does not affect validation, and surfaces in the output\n * of {@link toJsonSchema}.\n *\n * @param description The description to attach.\n * @return A clone of this schema carrying the description.\n */\n describe(description: string): this {\n const cloned = this.clone()\n cloned._jsonSchemaDescription = description\n return cloned\n }\n\n /**\n * Serializes this schema to a JSON Schema definition, suitable for describing the shape to an\n * LLM or other consumer. Works similarly to zod-to-json-schema.\n */\n toJsonSchema(): JsonSchema {\n return this.jsonSchema ?? {}\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 cloned._jsonSchemaDescription = this._jsonSchemaDescription\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 * JSON Schema has no representation for `undefined`, so only `null` is expressed.\n */\n nullish(): Validator<null | undefined> {\n return createValidator(\n locale.nullish,\n (input) => input == null,\n undefined,\n {\n type: 'null',\n }\n )\n },\n\n /**\n * Creates a validator that asserts that the input is strictly null.\n */\n null(): Validator<null> {\n return createValidator(\n locale.null,\n (input) => input === null,\n undefined,\n {\n type: 'null',\n }\n )\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'\nimport type { JsonSchema, JsonSchemaType } from './JsonSchema'\n\n/**\n * @private\n */\nconst locale = {\n template: 'type {value}',\n} as const\n\n/**\n * The JSON Schema `type` for each JavaScript `typeof` value that has a JSON representation.\n * Types with no JSON equivalent (`function`, `symbol`) are absent and contribute no fragment.\n */\nconst jsonSchemaTypeByTypeof: Partial<Record<Typeof, JsonSchemaType>> = {\n string: 'string',\n number: 'number',\n boolean: 'boolean',\n object: 'object',\n}\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 const jsonType = jsonSchemaTypeByTypeof[expected]\n const jsonSchema: JsonSchema | undefined =\n jsonType == null ? undefined : { type: jsonType }\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 undefined,\n jsonSchema\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 { 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 undefined,\n { minimum: 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 undefined,\n { exclusiveMinimum: 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 undefined,\n { maximum: 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 undefined,\n { exclusiveMaximum: 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 undefined,\n { minimum: min, maximum: 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(\n locale.safeInteger,\n (input) => Number.isSafeInteger(input),\n undefined,\n { type: 'integer' }\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'\nimport type { JsonSchema } from './JsonSchema'\nimport { toJsonSchema } from './JsonSchema'\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 const jsonProperties: Record<string, JsonSchema> = {}\n const requiredKeys: string[] = []\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 jsonProperties[String(key)] = toJsonSchema(validator)\n if (!validator.options.optional) requiredKeys.push(String(key))\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 jsonSchema: JsonSchema = {\n type: 'object',\n properties: jsonProperties,\n ...(requiredKeys.length ? { required: requiredKeys } : {}),\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 jsonSchema\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 [\n K in keyof U as K extends keyof T\n ? Equal<U[K], T[K]> extends true\n ? never\n : K\n : K\n ]-?: ExtendedPropertyValidator<U & T, K>\n} & {\n // OPTIONAL:\n // - Keys where U[K] === T[K] (and therefore K \u2208 keyof T)\n [\n K in keyof U as K extends keyof T\n ? Equal<U[K], T[K]> extends true\n ? K\n : never\n : never\n ]?: 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'\nimport { toJsonSchema } from './JsonSchema'\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 type: 'object',\n additionalProperties: toJsonSchema(valueValidator),\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(\n locale.notEmpty,\n (input) => input !== '',\n undefined,\n { minLength: 1 }\n )\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 undefined,\n { minLength: 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 undefined,\n { maxLength: 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 undefined,\n { pattern: regex.source }\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", "/*\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'\nimport { toJsonSchema } from './JsonSchema'\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 undefined,\n { type: 'array', uniqueItems: true }\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 type: 'array',\n uniqueItems: true,\n items: toJsonSchema(elementValidator),\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 {\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 undefined,\n { enum: [...possibleValues] }\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"],
|
|
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;AAAA;AAAA;;;ACKA,IAAAA,qBAA2B;;;ACA3B,wBAAgD;AAChD,IAAAC,qBAA8C;AA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,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;",
|
|
4
|
+
"sourcesContent": ["/** Auto-generated from build scripts */\nexport * from './validation/andValidators'\nexport * from './validation/ArraySchema'\nexport * from './validation/FunctionSchema'\nexport * from './validation/JsonSchema'\nexport * from './validation/NumberSchema'\nexport * from './validation/ObjectSchema'\nexport * from './validation/orValidators'\nexport * from './validation/PropertyValidator'\nexport * from './validation/RecordSchema'\nexport * from './validation/SchemaBase'\nexport * from './validation/SetSchema'\nexport * from './validation/StringSchema'\nexport * from './validation/typeOfValidators'\nexport * from './validation/Validator'\nexport * from './validation/validators'\nexport * from './validation/ValidatorWithPartial'\nexport * from './validation/ValueSchema'\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'\nimport { mergeJsonSchema } from './JsonSchema'\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 mergeJsonSchema(...validators.map((v) => v.jsonSchema))\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'\nimport type { JsonSchema } from './JsonSchema'\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 * The JSON Schema fragment this validator contributes, if any.\n *\n * Fragments compose the same way the {@link description} does: chaining validators with `and`\n * merges their fragments, and `or` unions them into an `anyOf`. Serialize a full schema with\n * {@link toJsonSchema}. A validator with no meaningful shape (for example a bare type check)\n * may omit this.\n */\n readonly jsonSchema?: JsonSchema | undefined\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 * @param jsonSchema The JSON Schema fragment this validator contributes, if any.\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 jsonSchema?: JsonSchema\n): Validator<Output, Input> {\n return {\n description: expectationMessage,\n jsonSchema,\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 * @param jsonSchema The JSON Schema fragment this validator contributes, if any.\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 jsonSchema?: JsonSchema\n): Validator<Output, Input> {\n return {\n description,\n jsonSchema,\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 { ownKeys } from '@amazon/vinyl-util'\nimport type { Validator } from './Validator'\n\n/**\n * The `type` keyword value of a JSON Schema node.\n */\nexport type JsonSchemaType =\n 'string' | 'number' | 'integer' | 'boolean' | 'object' | 'array' | 'null'\n\n/**\n * A JSON Schema definition (a draft-07 compatible subset) describing the shape a value must take.\n *\n * This is the serializable representation produced by {@link toJsonSchema}, suitable for handing to\n * an LLM as the shape it must produce. It intentionally mirrors zod-to-json-schema output for the\n * node types this library supports.\n */\nexport interface JsonSchema {\n readonly type?: JsonSchemaType | readonly JsonSchemaType[]\n\n /**\n * A human-readable description, attached to a schema node via its `describe` method.\n */\n readonly description?: string\n\n // Object\n readonly properties?: Readonly<Record<string, JsonSchema>>\n readonly required?: readonly string[]\n readonly additionalProperties?: boolean | JsonSchema\n\n // Array\n readonly items?: JsonSchema | readonly JsonSchema[]\n readonly additionalItems?: boolean\n readonly minItems?: number\n readonly maxItems?: number\n readonly uniqueItems?: boolean\n\n // String\n readonly minLength?: number\n readonly maxLength?: number\n readonly pattern?: string\n\n // Number\n readonly minimum?: number\n readonly maximum?: number\n readonly exclusiveMinimum?: number\n readonly exclusiveMaximum?: number\n\n // Enumeration\n readonly enum?: readonly unknown[]\n\n // Composition\n readonly anyOf?: readonly JsonSchema[]\n}\n\n/**\n * A source that can produce its own JSON Schema definition. Schema nodes implement this so that\n * per-node metadata (such as a `describe` description) is honored during serialization.\n */\nexport interface JsonSchemaProvider {\n toJsonSchema(): JsonSchema\n}\n\ntype MutableJsonSchema = {\n -readonly [K in keyof JsonSchema]: JsonSchema[K]\n}\n\n/**\n * Merges JSON Schema fragments into a single definition, later fragments taking precedence.\n *\n * This mirrors an intersection (`and`) of constraints: `properties` are combined and `required`\n * keys are unioned, while all other keywords are overridden by the last fragment that defines them.\n *\n * @param fragments The fragments to merge. `undefined` fragments are ignored.\n */\nexport function mergeJsonSchema(\n ...fragments: readonly (JsonSchema | undefined)[]\n): JsonSchema {\n const merged: MutableJsonSchema = {}\n for (const fragment of fragments) {\n if (fragment == null) continue\n for (const key of ownKeys(fragment)) {\n if (fragment[key] === undefined) continue\n if (key === 'properties') {\n merged.properties = {\n ...merged.properties,\n ...fragment.properties,\n }\n } else if (key === 'required') {\n merged.required = [\n ...new Set([\n ...(merged.required ?? []),\n ...(fragment.required as readonly string[]),\n ]),\n ]\n } else {\n // A homogeneous copy of one key; the key/value are drawn from the same fragment.\n merged[key] = fragment[key] as never\n }\n }\n }\n return merged\n}\n\n/**\n * Serializes a validator to a JSON Schema definition.\n *\n * Schema nodes ({@link JsonSchemaProvider}s) serialize themselves so that per-node metadata is\n * honored; other validators contribute their attached JSON Schema fragment, defaulting to the empty\n * schema (which matches any value) when none is attached.\n *\n * @param source The validator or schema node to serialize.\n */\nexport function toJsonSchema(source: Validator<any, any>): JsonSchema {\n const provider = source as Partial<JsonSchemaProvider>\n if (typeof provider.toJsonSchema === 'function') {\n return provider.toJsonSchema()\n }\n return { ...source.jsonSchema }\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'\nimport { toJsonSchema } from './JsonSchema'\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(\n locale.array,\n (input: unknown) => Array.isArray(input),\n undefined,\n { type: 'array' }\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 { type: 'array', items: toJsonSchema(elementValidator) }\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, {\n value: validators\n .map((validator) => validator.description)\n .join(', '),\n }),\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 type: 'array',\n items: validators.map((v) => toJsonSchema(v)),\n minItems: validators.length,\n maxItems: validators.length,\n additionalItems: false,\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 { minItems: min }\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 { maxItems: max }\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 { ValidationErrorMessage, Validator } from './Validator'\nimport {\n createDeepValidator,\n createValidationExpectationMessage,\n} from './Validator'\nimport type { JsonSchema } from './JsonSchema'\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 * Composes the child validators' JSON Schema fragments into a union.\n *\n * Branches with no fragment are skipped: JSON Schema has no representation for `undefined`, and a\n * value's optionality is instead conveyed by an object's `required` list. A single remaining branch\n * collapses to that branch rather than a redundant `anyOf`.\n */\nfunction unionJsonSchema(\n validators: readonly Validator<any, any>[]\n): JsonSchema | undefined {\n const branches = validators\n .map((v) => v.jsonSchema)\n .filter((fragment): fragment is JsonSchema => fragment != null)\n if (branches.length === 0) return undefined\n if (branches.length === 1) return branches[0]\n return { anyOf: branches }\n}\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(\n description,\n (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 unionJsonSchema(validators)\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'\nimport type { JsonSchema, JsonSchemaProvider } from './JsonSchema'\nimport { mergeJsonSchema } from './JsonSchema'\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>\n implements\n PropertyValidator<T, { readonly optional: false }>,\n JsonSchemaProvider\n{\n __type = /* @__PURE__ */ invariant<T>()\n\n private readonly validator: Validator<T>\n private _options = requiredValidationOptions\n private _jsonSchemaDescription?: string\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 /**\n * The composed JSON Schema fragment for this schema, including any {@link describe} description.\n * Composes through chaining the same way {@link description} does; serialize a complete\n * definition with {@link toJsonSchema}.\n */\n get jsonSchema(): JsonSchema | undefined {\n const base = this.validator.jsonSchema\n if (this._jsonSchemaDescription == null) return base\n return mergeJsonSchema(base, {\n description: this._jsonSchemaDescription,\n })\n }\n\n /**\n * Attaches a human-readable description to this schema, akin to zod's `describe`.\n * The description is metadata only; it does not affect validation, and surfaces in the output\n * of {@link toJsonSchema}.\n *\n * @param description The description to attach.\n * @return A clone of this schema carrying the description.\n */\n describe(description: string): this {\n const cloned = this.clone()\n cloned._jsonSchemaDescription = description\n return cloned\n }\n\n /**\n * Serializes this schema to a JSON Schema definition, suitable for describing the shape to an\n * LLM or other consumer. Works similarly to zod-to-json-schema.\n */\n toJsonSchema(): JsonSchema {\n return this.jsonSchema ?? {}\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 cloned._jsonSchemaDescription = this._jsonSchemaDescription\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 * JSON Schema has no representation for `undefined`, so only `null` is expressed.\n */\n nullish(): Validator<null | undefined> {\n return createValidator(\n locale.nullish,\n (input) => input == null,\n undefined,\n {\n type: 'null',\n }\n )\n },\n\n /**\n * Creates a validator that asserts that the input is strictly null.\n */\n null(): Validator<null> {\n return createValidator(\n locale.null,\n (input) => input === null,\n undefined,\n {\n type: 'null',\n }\n )\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'\nimport type { JsonSchema, JsonSchemaType } from './JsonSchema'\n\n/**\n * @private\n */\nconst locale = {\n template: 'type {value}',\n} as const\n\n/**\n * The JSON Schema `type` for each JavaScript `typeof` value that has a JSON representation.\n * Types with no JSON equivalent (`function`, `symbol`) are absent and contribute no fragment.\n */\nconst jsonSchemaTypeByTypeof: Partial<Record<Typeof, JsonSchemaType>> = {\n string: 'string',\n number: 'number',\n boolean: 'boolean',\n object: 'object',\n}\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 const jsonType = jsonSchemaTypeByTypeof[expected]\n const jsonSchema: JsonSchema | undefined =\n jsonType == null ? undefined : { type: jsonType }\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 undefined,\n jsonSchema\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 { 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 undefined,\n { minimum: 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 undefined,\n { exclusiveMinimum: 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 undefined,\n { maximum: 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 undefined,\n { exclusiveMaximum: 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 undefined,\n { minimum: min, maximum: 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(\n locale.safeInteger,\n (input) => Number.isSafeInteger(input),\n undefined,\n { type: 'integer' }\n )\n },\n} as const\n\nexport class NumberSchema extends ValueSchema<number> {\n private static _base: NumberSchema | null = null\n\n /**\n * The base NumberSchema instance validating that the input is a number.\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'\nimport type { JsonSchema } from './JsonSchema'\nimport { toJsonSchema } from './JsonSchema'\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 const jsonProperties: Record<string, JsonSchema> = {}\n const requiredKeys: string[] = []\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 jsonProperties[String(key)] = toJsonSchema(validator)\n if (!validator.options.optional) requiredKeys.push(String(key))\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 jsonSchema: JsonSchema = {\n type: 'object',\n properties: jsonProperties,\n ...(requiredKeys.length ? { required: requiredKeys } : {}),\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 jsonSchema\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 [\n K in keyof U as K extends keyof T\n ? Equal<U[K], T[K]> extends true\n ? never\n : K\n : K\n ]-?: ExtendedPropertyValidator<U & T, K>\n} & {\n // OPTIONAL:\n // - Keys where U[K] === T[K] (and therefore K \u2208 keyof T)\n [\n K in keyof U as K extends keyof T\n ? Equal<U[K], T[K]> extends true\n ? K\n : never\n : never\n ]?: 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'\nimport { toJsonSchema } from './JsonSchema'\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 type: 'object',\n additionalProperties: toJsonSchema(valueValidator),\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(\n locale.notEmpty,\n (input) => input !== '',\n undefined,\n { minLength: 1 }\n )\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 undefined,\n { minLength: 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 undefined,\n { maxLength: 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 undefined,\n { pattern: regex.source }\n )\n },\n} as const\n\nexport class StringSchema extends ValueSchema<string> {\n private static _base: StringSchema | null = null\n\n /**\n * The base StringSchema instance validating that the input is a string.\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", "/*\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'\nimport { toJsonSchema } from './JsonSchema'\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 undefined,\n { type: 'array', uniqueItems: true }\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 type: 'array',\n uniqueItems: true,\n items: toJsonSchema(elementValidator),\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 {\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 undefined,\n { enum: [...possibleValues] }\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"],
|
|
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;AAAA;AAAA;;;ACKA,IAAAA,qBAA2B;;;ACA3B,wBAAgD;AAChD,IAAAC,qBAA8C;AAuF9C,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;AAcO,SAAS,gBACZ,oBACA,SACA,iBAA2C,CAAC,cACxC,sCAAkB,OAAO,GAAG,GAChC,YACwB;AACxB,SAAO;AAAA,IACH,aAAa;AAAA,IACb;AAAA,IAEA,QAAQ,OAA+B;AACnC,aAAO,QAAQ,KAAK;AAAA,IACxB;AAAA,IAEA,SACI,OACA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AE;AAAA,IAChC;AAAA,EACJ;AACJ;AAOO,SAAS,OACZ,YACuB;AACvB,SAAO,QAAQ,GAAG,OAAO,OAAO,UAAU,CAAC;AAG/C;AAKO,SAAS,cAA+B;AAC3C,SAAO,gBAAgB,KAAK;AAChC;AAKO,SAAS,UAAuC;AACnD,SAAO,gBAAgB,QAAQ;AACnC;AAKO,SAAS,SAAuB;AACnC,SAAO,aAAa;AACxB;AAMO,SAAS,OACZ,oBACe;AACf,SAAO,aAAa,KAAK,OAAU,kBAAkB;AACzD;AAeO,SAAS,OACZ,cACA,gBACkC;AAClC,SAAO,aAAa,KAAK,OAAO,cAAc,cAAc;AAChE;AAUO,SAAS,aACZ,gBAC+B;AAC/B,SAAO,aAAa,KAAK,aAAa,cAAc;AACxD;AAOO,SAAS,IACZ,kBACiB;AACjB,SAAO,UAAU,KAAK,aAAa,gBAAgB;AACvD;AAKO,SAAS,SAAuB;AACnC,SAAO,aAAa;AACxB;AAQO,SAAS,SACT,YAKJ;AACC,SAAO,YAAY,KAAK,MAAM,GAAG,UAAU;AAC/C;AAKO,SAAS,SAA8B;AAC1C,SAAO,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", "input", "import_vinyl_util", "import_vinyl_util", "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", "validator", "import_vinyl_util", "import_vinyl_util", "locale", "locale", "import_vinyl_util", "locale", "import_vinyl_util", "locale"]
|
|
7
7
|
}
|
package/dist/index.js
CHANGED
|
@@ -491,7 +491,9 @@ var arrayValidators = {
|
|
|
491
491
|
(length) => length === validators.length
|
|
492
492
|
);
|
|
493
493
|
return createDeepValidator(
|
|
494
|
-
substitute4(locale4.tuple, {
|
|
494
|
+
substitute4(locale4.tuple, {
|
|
495
|
+
value: validators.map((validator) => validator.description).join(", ")
|
|
496
|
+
}),
|
|
495
497
|
(input, options, path) => {
|
|
496
498
|
const errors = [];
|
|
497
499
|
errors.push(
|
|
@@ -801,7 +803,7 @@ var numberValidators = {
|
|
|
801
803
|
};
|
|
802
804
|
var _NumberSchema = class _NumberSchema extends ValueSchema {
|
|
803
805
|
/**
|
|
804
|
-
* The base
|
|
806
|
+
* The base NumberSchema instance validating that the input is a number.
|
|
805
807
|
*/
|
|
806
808
|
static get base() {
|
|
807
809
|
if (this._base == null)
|
|
@@ -1094,7 +1096,7 @@ var stringValidators = {
|
|
|
1094
1096
|
};
|
|
1095
1097
|
var _StringSchema = class _StringSchema extends ValueSchema {
|
|
1096
1098
|
/**
|
|
1097
|
-
* The base
|
|
1099
|
+
* The base StringSchema instance validating that the input is a string.
|
|
1098
1100
|
*/
|
|
1099
1101
|
static get base() {
|
|
1100
1102
|
if (this._base == null)
|