import AsyncValidator from 'async-validator'; import { IRule, IRuleTrigger } from './index'; import { IRuleStatus } from './field'; export interface IValidateResult { valid: boolean; message: string; status: IRuleStatus } export interface IValidator { initialize: (params: IValidatorParams) => void; setValidtorFunc: (callback: IValidatorFunc) => void; validate: (trigger: IRuleTrigger) => Promise; } export type IValidatorMap = { [trigger in IRuleTrigger]?: { [status in IRuleStatus]?: AsyncValidator } }; export interface IValidatorParams { rules: IRule[]; } export type IValidatorFunc = (trigger: IRuleTrigger, value: any) => Promise | IValidateResult | void;