import { StringIndexedObject } from '@befe/brick-utils'; type Value = any; type Source = StringIndexedObject; type ErrorMessage = string; type Message = ErrorMessage | ((value: any, source: Source) => ErrorMessage); export interface ValidatorResult { valid: boolean; value: Value; errors: ErrorMessage[]; } interface ValidatorOptions { messageMap?: StringIndexedObject; } interface ConstraintMap { [key: string]: Constraint; } type ConstraintItem = Rule[] | ConstraintMap; type Constraint = StringIndexedObject; type Validator = (value: any, source: Source, rule: Rule, options?: ValidatorOptions) => Promise | boolean | void; interface Rule { message?: Message; validator?: Validator; type?: 'string' | 'boolean' | 'regexp' | 'number' | 'integer' | 'array' | 'enum' | 'date'; required?: boolean; pattern?: RegExp; length?: number; min?: number; max?: number; } interface ValidationResult { valid: boolean; detail: StringIndexedObject; } export declare function validate(source: Source, constraint: Constraint, options?: ValidatorOptions): Promise; export declare namespace validate { var single: (value: any, constraintItem: ConstraintItem, options?: ValidatorOptions | undefined) => Promise; } export {};