method
check_validity!
v7.1.3.4 -
Show latest stable
- Class:
ActiveModel::Validations::LengthValidator
check_validity!()public
No documentation available.
# File activemodel/lib/active_model/validations/length.rb, line 29
def check_validity!
keys = CHECKS.keys & options.keys
if keys.empty?
raise ArgumentError, "Range unspecified. Specify the :in, :within, :maximum, :minimum, or :is option."
end
keys.each do |key|
value = options[key]
unless (value.is_a?(Integer) && value >= 0) ||
value == Float::INFINITY || value == -Float::INFINITY ||
value.is_a?(Symbol) || value.is_a?(Proc)
raise ArgumentError, ":#{key} must be a non-negative Integer, Infinity, Symbol, or Proc"
end
end
end