Is there a way to change the default validation messages for the entire app in Ecto?

I have an app with several models that use validate_required when creating the changesets. I also happen to use Gettext to translate all the fields. The problem is that if I change a name in, let’s say “can’t be blank” to “mandatory field”, I have to do so in every model that uses the translation.

Is there a way to configure ecto to always show the same gettext message in one place in the app ? I’ve searched the docs and did’nt find anything about this.

I though that I could create a submodule that do just that, but I would like to knokw if there’s another way before diving too deep

Thank you!


If you want “can’t be blank” to always be “mandatory field”, you can do so with gettext by mapping all can't be blank msgid to translations of “mandatory field”.

## From Ecto.Changeset.cast/4
msgid "can't be blank"
msgstr "mandatory field"