I'm writing a custom Ecto.Type
for colors (serialized and parsed as CSS colors).
The behaviour specifies that the cast/1
callback should return :error
unless successful. It does not allow for returning an error reason, and will generate the generic "is invalid" error description when used with a Changeset.
What is the best way to allow better error messages on in changesets on invalid (uncasteable) input? I would like to create a validate_color
function to be used on changesets, but if the cast failed the field will already have the generic error.