Class: ActiveRecord::Validations::NumericalityValidator
Do not use. This class is for internal use only.
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
|
|
Instance Chain:
|
|
Inherits: |
ActiveModel::Validations::NumericalityValidator
|
Defined in: | activerecord/lib/active_record/validations/numericality.rb |
Constant Summary
::ActiveModel::Validations::Comparability
- Included
::ActiveModel::Validations::NumericalityValidator
- Inherited
HEXADECIMAL_REGEX, INTEGER_REGEX, NUMBER_CHECKS, RANGE_CHECKS, RESERVED_OPTIONS
Class Method Summary
::ActiveModel::EachValidator
- Inherited
.new | Returns a new validator instance. |
::ActiveModel::Validator
- Inherited
Instance Attribute Summary
Instance Method Summary
- #validate_each(record, attribute, value, precision: nil, scale: nil)
- #column_precision_for(record, attribute) private
- #column_scale_for(record, attribute) private
::ActiveModel::Validations::NumericalityValidator
- Inherited
::ActiveModel::Validations::ResolveValue
- Included
::ActiveModel::Validations::Comparability
- Included
::ActiveModel::EachValidator
- Inherited
#check_validity! | Hook method that gets called by the initializer allowing verification that the arguments supplied are valid. |
#validate | Performs validation on the supplied record. |
#validate_each | Override this method in subclasses with the validation logic, adding errors to the records |
#prepare_value_for_validation |
::ActiveModel::Validator
- Inherited
Constructor Details
This class inherits a constructor from ActiveModel::EachValidator
Instance Method Details
#column_precision_for(record, attribute) (private)
[ GitHub ]# File 'activerecord/lib/active_record/validations/numericality.rb', line 13
def column_precision_for(record, attribute) record.class.type_for_attribute(attribute.to_s)&.precision end
#column_scale_for(record, attribute) (private)
[ GitHub ]# File 'activerecord/lib/active_record/validations/numericality.rb', line 17
def column_scale_for(record, attribute) record.class.type_for_attribute(attribute.to_s)&.scale end
#validate_each(record, attribute, value, precision: nil, scale: nil)
[ GitHub ]# File 'activerecord/lib/active_record/validations/numericality.rb', line 6
def validate_each(record, attribute, value, precision: nil, scale: nil) precision = [column_precision_for(record, attribute) || Float::DIG, Float::DIG].min scale = column_scale_for(record, attribute) super(record, attribute, value, precision: precision, scale: scale) end