I’ve been trying to use the {msg, opts} tuple variant of the :message option in validate_format, taking a validation that looked like this:
|> validate_format(:field, ~r/some_regex/, message: "oh no!")
to this
|> validate_format(:field, ~r/some_regex/, message: {"oh no!", [error_type: :some_error_type]})
but when I do, I start to get errors that look like this in my validation code:
** (EXIT from #PID<0.2412.0>) an exception was raised:
** (FunctionClauseError) no function clause matching in anonymous fn/1 in Ecto.Changeset.validate_change/3
The following arguments were given to anonymous fn/1 in Ecto.Changeset.validate_change/3:
# 1
{:field, {{"oh no!", [error_type: :some_error_type]}, [validation: :format]}}
stacktrace:
(ecto 3.11.2) lib/ecto/changeset.ex:2430: anonymous fn/1 in Ecto.Changeset.validate_change/3
(elixir 1.16.2) lib/enum.ex:1700: Enum."-map/2-lists^map/1-1-"/2
(ecto 3.11.2) lib/ecto/changeset.ex:2430: Ecto.Changeset.validate_change/3
Am I misunderstanding how the tuple variant for the :message
option is supposed to look? I can’t figure out why this error is happening.