export type ValidationErrors = { path: (string | number)[]; message: string; }[]; /** * A `ValidationError` wraps one or more errors encountered during validation. */ export declare class ValidationError extends Error { /** An `Array` of validation errors encountered while validating */ readonly errors: ValidationErrors; /** Our stack, always present as we enforce it in the constructor */ readonly stack: string; /** * Create a new `ValidationError` instance from a `ValidationErrorBuilder` * or with a `cause` (a string, or another error) and optional path. * * The `constructor` (optional last parameter) will restrict creation of * this instance's stack up to the specified function. */ constructor(builder: ValidationErrorBuilder); constructor(cause: any, constructor?: Function); constructor(cause: any, path: (string | number)[], constructor?: Function); } /** * Helper class to build a `ValidationError` associated p */ export declare class ValidationErrorBuilder { /** The current list of validation errors */ readonly errors: ValidationErrors; /** * Record a validation error associated with the specified key. * * @param error - The error (normally a `string` or a `ValidationError`) * to record and associate with the given key * @param key - The key in an object, or index in an array where the * vaildation error was encountered */ record(error: any, ...key: (string | number)[]): this; /** * Assert there are no validation errors and return the specified value, or * throw a `ValidationError` combining all errors * * @param value - The value to return if no errors have been recorded */ assert(value: T): T; } /** * Simple assertion function throwing `ValidationError`(s) with an empty path */ export declare function assertValidation(what: boolean | undefined, message: string): asserts what; /** * Simple assertion function throwing `TypeError`(s) to be used when * constructing a `Validator` from a `Schema` or validation constraints. */ export declare function assertSchema(what: boolean | undefined, message: string): asserts what;