instance method validates_numericality_of

Ruby on Rails 8.0.4

Since v2.2.3

Available in: v2.2.3 v2.3.18 v6.1.7.10 v7.0.10 v7.1.6 v7.2.3 v8.0.4 v8.1.2

Signature

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_names rest
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

Type at least 2 characters to search.

↑↓ navigate · open · esc close