import { RefObject } from 'react'; import { Errors, FieldPath, ModifiedState, UseFormStateHook, Values } from './useFormState'; import { UseFormStatusHook } from './useFormStatus'; import { UseFormValuesHook } from './useFormValues'; import { UseFormErrorsHook } from './useFormErrors'; export type ValidateFieldFunction = (path: FieldPath, value: unknown, values: V) => Promise; export type UseFormValidationOptions = { /** * The form errors hook. */ formErrors: UseFormErrorsHook; /** * The form state hook. */ formState: UseFormStateHook; /** * The form status hook. */ formStatus: UseFormStatusHook; /** * The form values hook. */ formValues: UseFormValuesHook; /** * Validates given values. * @param values * @param modified */ validate?(values: V, modified: ModifiedState): Promise | undefined>; /** * Validates a single field. * @param path * @param value * @param values */ validateField?: ValidateFieldFunction; /** * The validation delay. */ validateDelay?: number; }; export type UseFormValidationHook = { /** * Sets validation globally or for given fields. */ setNeedValidation(validation: boolean | FieldPath[]): void; /** * Sets the validation error. */ setValidateError(error: Error | undefined): void; /** * Sets the validated state of the form. */ setValidated(validated: boolean): void; /** * Sets the validation state. */ setValidating(validating: boolean): void; /** * Validate all fields. */ validate(): Promise | undefined>; /** * Validate a single field. */ validateField(path: FieldPath): Promise; /** * Validate given fields. */ validateFields(paths: FieldPath[]): Promise | undefined>; /** * The ref of the validation function. */ validateRef: RefObject['validate']>; }; declare function useFormValidation(options: UseFormValidationOptions): UseFormValidationHook; export default useFormValidation; //# sourceMappingURL=useFormValidation.d.ts.map