Reputation: 12447
Using Elixir & Phoenix framework here.
I have a signup page where I'm validating the password & password confirmation fields using the validate_confirmation
function.
def changeset(model, params \\ %{}) do
model
|> cast(params, @required_fields, @optional_fields)
|> validate_confirmation(:password)
|> validate_length(:firstName, min: 2)
end
If I enter mismatching passwords, I get an error no function clause matching in Gettext.dngettext/6
in the browser - https://i.sstatic.net/eDrxE.jpg
I have the latest dependencies before posting this.
The complete stacktrace is available here - http://pastebin.com/XLKav4cu
What am I doing wrong?
Upvotes: 0
Views: 883
Reputation: 6501
You're using the old style syntax for Ecto. You now need to cast, then pass to the validate_required
function
def changeset(model, params \\ %{}) do
model
|> cast(params, [list of all fields])
|> validate_required([list of required fields])
|> validate_confirmation(:password)
|> validate_length(:firstName, min: 2)
end
See https://hexdocs.pm/ecto/Ecto.html#module-changesets for further details
Upvotes: 1