Active Record validations are used to ensure that only valid data is saved to the database by validating the objects before they are saved. Active Record has a validation system allowing developers to specify rules for the attributes of a model. Common validations include presence, length, uniqueness, and custom validations.
They do not:
- validate previously saved data
- prevent all occurrences of invalid data being saved to a database.
Some common validations:
validates :some_important_attribute, presence: true validates :several, :important, :attributes, presence: true
validates :screenname, uniqueness: true