Custom validation error not appearing in form
I'm using the
.input
and .inputs_for
components from Phoenix, and I see the normal is required
errors in the html when I leave fields blank, but while my custom error shows up in the changeset from IO.inspect
I don't see it in the html.
The validation:
The resource:
Is there something I'm missing in implementing a validation or could it be something in the form?4 Replies
I would suspect it's because this error is not tied to a specific field, so you'd have to add something to render generic form errors.
Or if this is intended to be tied to a specific attribute, you need to associate it w/ the attributes that should show the error.
For an example: https://github.com/ash-project/ash/blob/v2.6.31/lib/ash/resource/validation/confirm.ex#L43
GitHub
ash/confirm.ex at v2.6.31 ยท ash-project/ash
A declarative and extensible framework for building Elixir applications. - ash/confirm.ex at v2.6.31 ยท ash-project/ash
Got it, reading through the Ash source for validations and InvalidAttribute now to try and get a sense of how it's meant to work
OK! So I had noticed pretty quick that in the changeset for domains, whose error is not appearing, the field is showing up as a string whereas for my other resources whose default errors are working the field is specified as an atom. I changed the name field to be an atom and it still didn't work... then I finally changed it to gibberish and noticed it was still showing up in iex as the same field as a string.
mix clean
and mix compile
and now everything is fine. That was the issue. I do not know why it was stuck on the old values but now everything is great ๐
weird that it got stuck, but glad its working now ๐