chrisdel101

chrisdel101

Ecto Changeset validate_confirmation function is undefined

This related to my other question, but I’m asking a new one for clarity.

Using the built-in validation_confirmation I’m getting:
undefined function validate_confirmation/4.

It’s an Ecto(?) function, so I’m stumped on this one. None of the other functions there fail, only validation_confirmation. Am I missing an import somewhere? Undefined error makes no sense here.


defp validate_email(changeset) do
    IO.inspect(changeset)
    changeset
    |> validate_required([:email])
    |> validate_format(:email, ~r/^[^\s]+@[^\s]+$/, message: "must have the @ sign and no spaces")
    |> validate_length(:email, max: 160)
    |> unsafe_validate_unique(:email, TurnStile.Repo)
    |> unique_constraint(:email)
    |> validate_confirmation(changeset, :password, message: "does not match password")
  end

Most Liked

dimitarvp

dimitarvp

It does take the changeset as a first parameter, it’s just that the pipe removes the need to type it out.

Example:

def sum(a, b) do
  a + b
end

# the two lines below do the same thing:
sum(1, 2)
1 |> sum(2)
codeanpeace

codeanpeace

defp validate_email(changeset) do
    IO.inspect(changeset)
    changeset
    |> ...
    |> validate_confirmation(changeset, :password, message: "does not match password")
  end

What you had originally would be equivalent to:
validate_confirmation(changeset, changeset, :password, message: "...")
which would explain why the error was undefined function validate_confirmation/4.

Where Next?

Popular in Discussions Top

AstonJ
I’ve just started the Phoenix part of the utterly brilliant online course by @pragdave. On generating the Phoenix app he uses the --no-ec...
New
tmbb
This is a post to discuss the new Phoenix LiveView functionality. From Chris’s talk, it appears that they generate all HTML on the serve...
342 18595 126
New
nburkley
AWS re:Invent is on at the moment with some interesting announcements. One new feature in particular is the Lambda Runtime API for AWS La...
New
slashdotdash
Phoenix Live View is now publicly available on GitHub. Here’s Chris McCord’s tweet announcing making it public.
New
Nvim
Anybody knows a comprehensive comparison of Django and Phoenix, thanks for the help. Where are they similar? Where do they differ the m...
New
tomekowal
Hey guys! I want to create a toy project that shows a chart of temperature over time and updates every 5 seconds. I feel LiveView is per...
New
thojanssens1
It would be nice to be able to define a redirect from one route to another from the router.ex file. E.g.: redirect "/", UserController, ...
New

Other popular topics Top

vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
msaraiva
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
564 44167 214
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID<0.412.0> terminating ** (Postgrex.Error) FATAL...
New

We're in Beta

About us Mission Statement