import type { FormState } from '../../core/hooks/useForm/types';
import type { CountryCode } from '../../core/models/country-code';
import type { Translatable } from '../../language/types';
export type ValidatorMode = 'blur' | 'input';
export interface FieldData<FormSchema> {
    key: keyof FormSchema;
    value: FormSchema[keyof FormSchema] | null;
    mode?: ValidatorMode;
    formName?: any;
}
export interface FieldContext<FormSchema> {
    state: FormState<FormSchema>;
}
export type Formatter<ValueType> = (value: ValueType | null, context?: FieldContext<any>) => ValueType | null;
export interface Format<ValueType> {
    formatter?: Formatter<ValueType>;
    format?: string;
    maxlength?: number;
}
export type FormatRules<FormSchema> = Partial<{
    [field in keyof FormSchema]: Format<FormSchema[field]>;
}>;
export type CountryFormatRules<FormSchema> = Partial<Record<CountryCode, FormatRules<FormSchema>>>;
export interface ValidationRuleResult {
    isValid: boolean;
    errorMessage?: Translatable;
    hasError: boolean;
}
export type ValidationRuleResults<Schema> = Partial<Record<keyof Schema, ValidationRuleResult | null | undefined>>;
export interface ValidatorRule<ValueType, FormSchema> {
    validate: (value: ValueType | null, context?: FieldContext<FormSchema>) => boolean;
    errorMessage?: Translatable | ((value: ValueType | null, context?: FieldContext<FormSchema>) => Translatable | undefined);
    modes: readonly ValidatorMode[];
}
export interface AsyncValidatorRule<ValueType, FormSchema> {
    asyncValidate: (value: ValueType | null, context?: FieldContext<FormSchema>) => Promise<boolean>;
    errorMessage?: Translatable | ((value: ValueType | null, context?: FieldContext<FormSchema>) => Translatable);
    modes: readonly ValidatorMode[];
}
export type ValidatorRules<FormSchema> = Partial<{
    [field in keyof FormSchema]: ValidatorRule<FormSchema[field], FormSchema> | ValidatorRule<FormSchema[field], FormSchema>[];
}>;
export type AsyncValidatorRules<FormSchema> = Partial<{
    [field in keyof FormSchema]: AsyncValidatorRule<FormSchema[field], FormSchema>;
}>;
