import { ReactNode } from 'react'; import { FormStore } from './createFormStore'; export interface ValidateMessages { default?: string; required?: string; enum?: string; whitespace?: string; date?: { format?: string; parse?: string; invalid?: string; }; types?: { string?: string; function?: string; array?: string; object?: string; number?: string; date?: string; boolean?: string; integer?: string; float?: string; regexp?: string; email?: string; url?: string; hex?: string; }; string?: { len?: string; min?: string; max?: string; range?: string; }; number?: { len?: string; min?: string; max?: string; range?: string; }; array?: { len?: string; min?: string; max?: string; range?: string; }; pattern?: { mismatch?: string; }; } export type ValidatorType = 'string' | 'number' | 'boolean' | 'function' | 'regexp' | 'integer' | 'float' | 'array' | 'object' | 'enum' | 'date' | 'url' | 'hex' | 'email'; export interface RuleConfig { validator?: (value: any, rule: Rule) => Promise | boolean | string; pattern?: RegExp; message?: string | (() => string); trigger?: string | string[]; transform?: (value: any) => any; type?: ValidatorType; enum?: string; len?: number; max?: number; min?: number; required?: boolean; whitespace?: boolean; } export type Rule = RuleConfig | ((form: FormStore) => RuleConfig); export interface Regulation { [name: string]: Rule | Rule[]; } export interface ValidateOptions { validateFirst?: boolean; value?: any; name?: string | number | (string | number)[]; label?: ReactNode; form?: FormStore; triggerName?: string | string[]; } export declare function getRuleConfig(rule: Rule, form: FormStore): RuleConfig; export declare class Validator { regulation: Regulation; validateMessages: ValidateMessages; constructor(regulation: Regulation); setValidateMessages(validateMessages: ValidateMessages): void; validateInternal(type: string, value: any, rule: Rule): Promise; validateRule(value: any, rule: RuleConfig): Promise; validate(rules: Rule[], options?: ValidateOptions): Promise; replaceSymbol(string: string, rule: RuleConfig, options?: ValidateOptions): string; } export default Validator;