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