instance method
validates_numericality_of
Ruby on Rails 8.0.4
Since v2.2.3Signature
validates_numericality_of(*attr_names)
Validates whether the value of the specified attribute is numeric by trying to convert it to a float with Kernel.Float (if only_integer is false) or applying it to the regular expression /\A[+\-]?\d+\z/ (if only_integer is set to true). Kernel.Float precision defaults to the column’s precision value or 15.
See ActiveModel::Validations::HelperMethods.validates_numericality_of for more information.
Parameters
-
attr_namesrest
Source
# File activerecord/lib/active_record/validations/numericality.rb, line 31
def validates_numericality_of(*attr_names)
validates_with NumericalityValidator, _merge_attributes(attr_names)
end
Defined in activerecord/lib/active_record/validations/numericality.rb line 31
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveRecord::Validations::ClassMethods