method
validates_length_of
v6.0.0 -
Show latest stable
- Class:
ActiveRecord::Validations::ClassMethods
validates_length_of(*attr_names)public
Validates that the specified attributes match the length restrictions supplied. If the attribute is an association, records that are marked for destruction are not counted.
See ActiveModel::Validations::HelperMethods.validates_length_of for more information.
1Note
Can be used with has_many associations
You can also use this to validate that a has_many association has a specified number of records on the other end:
has_many :members
validates_length_of :members, :minimum => 1