DEV Community

spencer-w-mathews
spencer-w-mathews

Posted on

Active Record Validations

Validations are used in order to ensure that the data persisted to the database is valid.

Why Validate?

Validations can help ensure input data is compatible with existing data. They can help assure a valid email address or username is used. They can make sure a data set designed to be integers only stays that way.

Common Validations

  • acceptance
  • validates_associated
  • confirmation
  • comparison
  • exclusion
  • format
  • inclusion
  • length
  • numericality
  • presence
  • absence
  • uniqueness
  • validates_with
  • validates_each

Sources: https://guides.rubyonrails.org/active_record_validations.html#validations-overview

Top comments (0)