import { CustomError } from 'ts-custom-error'; import { FutureInstance } from 'fluture'; /** * The base class from which all Validator-error related classes inherit. */ export declare class ValidationError extends CustomError { readonly errors: T; constructor(errors: T); } /** * The specialized error class used to emit validation failures on Task inputs. */ export declare class InputValidationError extends ValidationError { } /** * The specialized error class used to emit validation failures on Task outputs. */ export declare class OutputValidationError extends ValidationError { } /** * The specialized error class used to emit validation failures on Context values. */ export declare class ContextValidationError extends ValidationError { readonly contextKey: K; constructor(contextKey: K, errors: T); } /** * A Validator function accepts an arbitrary value of ``, and returns a Future that either rejects with an Error * that extends the `CustomError` class, or resolves with the originally supplied `value`. * * *IMPORTANT*: When implementing a custom Validator function, ensure that it declares a single type parameter that * defines the design-time type of the value that should pass validation to insure correct type inference at * design-time. */ export declare type Validator = (value: T) => FutureInstance, T>; /** * Allows Context values to be validated as individual key/value pairs, and valid context key names to be inferred and * correlated to their respective validator function. */ export declare type ContextValidators = { [K in keyof T]: Validator; }; /** * A Conditional type that allows type information to be inferred from a Validator function at design-time. */ export declare type TypeOf = T extends Validator ? U : never; /** * Specialized application of a Validator function and value, that coerces validation failure errors to * `InputValidationError`. */ export declare const validateInput: (validator: Validator, value: T) => FutureInstance, T>; /** * Specialized application of a Validator function and value, that coerces validation failure errors to * `OutputValidationError`. */ export declare const validateOutput: (validator: Validator, value: T) => FutureInstance, T>; /** * Specialized application of multiple Validator functions and values contained within an object. * * Each value within the `context` object is validated against it's corresponding validation function within the * `validators` object in parallel. * * Returns a Future that will reject with the first key/value pair that failed validation, or resolve to an object * containing the context key/value pairs. */ export declare const validateContext: (validators: ContextValidators | undefined, context?: { values: T; }) => FutureInstance, T>; //# sourceMappingURL=validator.d.ts.map