Validating the User Model

Add basic validation rules for the users' parameters.

Create validation rules

In this lesson, we will update our model to define validation rules. These rules are described in the template in app/models/user.rb.

Ruby on Rails provides a complete validation mechanism in their official documentation.

For the User model, we only want to validate three things:

  1. The email must be unique.
  2. The email must have a valid format.
  3. The password must be filled in.

Get hands-on with 1200+ tech skills courses.