react-hook-form-6
Version:
Latest version 6 of react-hook-form
22 lines (21 loc) • 1.08 kB
TypeScript
import { Message } from './form';
export declare type ValidationValue = boolean | number | string | RegExp;
export declare type ValidationRule<TValidationValue extends ValidationValue = ValidationValue> = TValidationValue | ValidationValueMessage<TValidationValue>;
export declare type ValidationValueMessage<TValidationValue extends ValidationValue = ValidationValue> = {
value: TValidationValue;
message: Message;
};
export declare type ValidateResult = Message | Message[] | boolean | undefined;
export declare type Validate = (data: any) => ValidateResult | Promise<ValidateResult>;
export declare type RegisterOptions = Partial<{
required: Message | ValidationRule<boolean>;
min: ValidationRule<number | string>;
max: ValidationRule<number | string>;
maxLength: ValidationRule<number | string>;
minLength: ValidationRule<number | string>;
pattern: ValidationRule<RegExp>;
validate: Validate | Record<string, Validate>;
valueAsNumber: boolean;
valueAsDate: boolean;
setValueAs: (value: any) => any;
}>;