Module: ActiveModel::Validations::HelperMethods

Defined in:
lib/range_validator.rb

Instance Method Summary collapse

Instance Method Details

#validates_range_of(*attr_names) ⇒ Object

Validates that the specified attributes are valid ranges and, optionally, that they do or do not overlap with ranges in other models. Examples:

validates :field, :range => true
validates :field, :range => { :overlapping => Proc.new{ |record| record.other_records } }
validates :field, :range => { :not_overlapping => :other_records }

When passing a symbol to :overlapping or :not_overlapping, the object must respond_to that message with a (possibly empty) list of objects that have the same fields.



74
75
76
# File 'lib/range_validator.rb', line 74

def validates_range_of(*attr_names)
  validates_with RangeValidator, _merge_attributes(attr_names)
end