1 import type { FieldProps, FormikErrors } from 'formik';
3 export const maybeErrorMessage = <V = any, T = FormikErrors<V>[keyof FormikErrors<V>]>(error: T): string | false => {
4 if (typeof error === 'string') return error;
8 export const useFieldControl = (props: FieldProps): { error: false | string } => {
9 const { field, form } = props;
10 const { name } = field;
11 const { touched, errors } = form;
12 const error = touched[name] && errors[name];
13 return { error: maybeErrorMessage(error) };