Working with validations and errors

Ecto provides a number of built-in changeset validations that we can hook into to ensure the data integrity of an application. Out of the box, Ecto provides the following validations to use (note that there are more than those listed; this is just a small sample):

  • validate_change validates the changeset against a provided function
  • validate_confirmation validates a field and the field's confirmation match (for example, password and password_confirmation)
  • validate_format validates that a field matches the specified format
  • validate_length validates that the field is the expected length
  • validate_number validates that the field has the specified numeric properties
  • validate_required validates that the field  ...

Get Phoenix Web Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.