neurodynamic
Unexpected error using message: {msg, opts} option in validation code
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.
Marked As Solved
fuelen
Last Post!
neurodynamic
Popular in Questions
Hello, how can I check the Phoenix version ?
Thanks !
New
I am trying to figure out how Mix knows whether the environment is test, dev, or prod – where is this set?
Thanks.
New
Hey all,
I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
There are pre-rolled solutions for other frameworks that do work. However, Phoenix does not seem to have these. Have people had good expe...
New
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New
Hey,
Just curious what are the main benefits of Elixir compared to Clojure?
When is Elixir more useful than Clojure and vice versa?
Th...
New
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors:
[WARN] - (starship::utils): Executing command ...
New
Other popular topics
Update:
How to use the Blogs & Podcasts section
You can post links to your blog posts or podcasts either in one of the Official Blog...
New
I am trying to figure out how Mix knows whether the environment is test, dev, or prod – where is this set?
Thanks.
New
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
I asked this very same question on twitter and got some interesting feedback, but I thought it would be a good question to ask here as we...
New
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #hex









