module ActiveModel::Validations::HelperMethods

Public Instance Methods

validates_range_of(*attr_names) click to toggle source

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.

# File lib/range_validator.rb, line 74
def validates_range_of(*attr_names)
  validates_with RangeValidator, _merge_attributes(attr_names)
end