April 2018
Beginner to intermediate
406 pages
9h 33m
English
In some scenarios, we may have custom error messages and validations that don't really match up to the provided Ecto validations out of the box. We have two ways to handle this with Ecto:
Let's explore both options. First, if we want to use validate_change, it's very simple. We'll start with the simplest implementation and then refactor it to get a good sense of how it all fits together:
def changeset(%User{}=user, attrs) do user # ... |> validate_change(:email, fn :email, value -> if value ...