mirror of
https://github.com/astuto/astuto.git
synced 2025-12-15 11:17:49 +01:00
20 lines
439 B
TypeScript
20 lines
439 B
TypeScript
|
|
import { FieldError } from "react-hook-form";
|
||
|
|
import I18n from 'i18n-js';
|
||
|
|
|
||
|
|
export const getLabel = (
|
||
|
|
entity: string,
|
||
|
|
attribute: string,
|
||
|
|
) => (
|
||
|
|
I18n.t(`activerecord.attributes.${entity}.${attribute}`)
|
||
|
|
);
|
||
|
|
|
||
|
|
export const getValidationMessage = (
|
||
|
|
validationType: FieldError['type'],
|
||
|
|
entity: string,
|
||
|
|
attribute: string,
|
||
|
|
) => (
|
||
|
|
I18n.t(
|
||
|
|
`common.validations.${validationType}`,
|
||
|
|
{ attribute: getLabel(entity, attribute) }
|
||
|
|
)
|
||
|
|
);
|