import { RuntypedError } from './core/index.js'; import { ReceiveType } from './reflection/reflection.js'; import { Type } from './reflection/type.js'; import { Serializer } from './serializer/serializer.js'; /** * Used in validator functions. */ export declare class ValidatorError { readonly code: string; readonly message: string; readonly path?: string | undefined; constructor(code: string, message: string, path?: string | undefined); } /** * The structure of a validation error. * * Path defines the shallow or deep path (using dots). * Message is an arbitrary message in english. * * In validators please use and return `new ValidatorError('code', 'message')` instead. */ export declare class ValidationErrorItem { /** * The path to the property. Might be a deep path separated by dot. */ readonly path: string; /** * A lower cased error code that can be used to identify this error and translate. */ readonly code: string; /** * Free text of the error. */ readonly message: string; /** * Optional value that caused the error. */ readonly value?: any; constructor( /** * The path to the property. Might be a deep path separated by dot. */ path: string, /** * A lower cased error code that can be used to identify this error and translate. */ code: string, /** * Free text of the error. */ message: string, /** * Optional value that caused the error. */ value?: any); toString(prefix?: string): string; } export declare class ValidationError extends RuntypedError { readonly errors: ValidationErrorItem[]; constructor(errors: ValidationErrorItem[], type?: Type); static from(errors: { path: string; message: string; code?: string; value?: any; }[]): ValidationError; } /** * Returns empty array when valid, or ValidationErrorItem[] with detailed error messages if not valid. * * Returns validation error items when failed. If successful returns an empty array. */ export declare function validate(data: any, type?: ReceiveType): ValidationErrorItem[]; export declare function validateFunction(serializerToUse?: Serializer, type?: ReceiveType): (data: T) => ValidationErrorItem[]; /** * Returns true when valid, and false if not. */ export declare function validates(data: any, type?: ReceiveType): boolean;