Last active: 2 years ago
import useTranslation, { TranslationTarget } from './useTranslation';
type Props = {
required?: TranslationTarget;
pattern?: TranslationTarget;
};
const defaultProps: Required<Props> = {
required: 'Value required',
pattern: 'Not a valid email address',
};
const useFormErrorMap = (props?: Props) => {
const { t } = useTranslation();
const { required, pattern } = {
...defaultProps,
...props,
};
return {
required: t(required),
pattern: t(pattern),
};
};
export default useFormErrorMap;