April 2019
Beginner to intermediate
244 pages
6h 34m
English
We’ve completed the first step of making a change to the database, and we have a Changeset struct with the changes we want to apply. But before we send it off to the database, we want to make sure that the data we’ve got is correct. Ecto provides two tools to help us check the integrity of our data: validations and constraints. They perform similar functions, but differ in the way that they’re implemented. We’ll explore each of them in the rest of this section.
Validations are utility functions provided by the Ecto.Changeset module to help check the integrity of your data. If you look at the module documentation, the validation functions are easy to spot because they all start with validate_:
Read now
Unlock full access