///
export type ValidationData = {
schema: any;
formValues: any;
initialFormValues?: any;
showUntouchedErrors?: boolean;
};
export type UseFormValidationReturn = {
/**
* object of fields that have an error
*/
errors: any;
/**
* function to set the error
*/
setErrors?: (error: any) => void;
/**
* function to do the validation, for example on field change
*/
reValidate: () => void;
/**
* function to be called on submit
*/
handleFormSubmit: (event: React.FormEvent, callback: (val: any) => void) => void;
/**
* function to reset the validation, meaning isValid = false, isDirty=false
*/
resetValidation?: () => void;
/**
* boolean to check if the form is valid or not
*/
isValid: boolean;
/**
* boolean to check if the form is dirty or not
*/
isDirty: boolean;
/**
* array of all dirty fields
*/
dirtyFields?: string[];
/**
* array of all touched fields
*/
touchedFields?: string[];
/**
* function to add the field to touched fields list
*/
onFieldTouch: (val: string) => void;
};
export type UseFormValidationHook = (values: ValidationData) => UseFormValidationReturn;