Form validation message missing field name
Hey folks, I've just purchased the ash book and I'm just at the beginning.
For some reason my form validation isn't showing any field names in the error message. I've done exactly as the book says, as far as I can tell, and I'm not sure if this is just how it's supposed to be.
Any advice is very appreciated :)
10 Replies
Solution
that's how it is supposed to be, as shown in the book 🙂
sorry, my image doesn't seem to have uploaded, here it is again.
I didn't see a screenshot showing the validation error so It wasn't clear to me that this was correct, to me it definitely looks incorrect. "is required" reads as a bit odd to me.
Is it customizable somewhere?

there isn't a setting to turn on to add field names to the validation messages that I'm aware of, no
No worries, looks like i could set the "post_process_errors" function if I wanted custom error messages, right?
I'd lean towards customizing the messages as part of the validations on your resource, I'm not sure if the "is required" can be customized there though as it comes from the
allow_nil? false
Okay, good to know. I guess this raises the further question: What about support for translations?
If I wanted to support multiple languages obviously things like form errors would have to all be able to be swapped out depending on the language.
Is there any support for that sort of thing?
Post process errors is the best option there
And just to confirm, there isn't like a set of atoms that are associated with errors that i can pattern match on or anything?
I just have to define a set of transformations like:
(rough sudocode)
if message ="is required" && language= :spanish then "es necesario"
You'd use gettext or something but yes
We haven't built a file for ash with all our messages unfortunately
no worries, thanks for clearing all that up.