Class: ActiveModel::Validations::ComparisonValidator
- Inherits:
-
EachValidator
- Object
- ActiveModel::Validator
- EachValidator
- ActiveModel::Validations::ComparisonValidator
- Includes:
- Comparability
- Defined in:
- lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activemodel-7.0.4/lib/active_model/validations/comparison.rb
Overview
:nodoc:
Constant Summary
Constants included from Comparability
ActiveModel::Validations::Comparability::COMPARE_CHECKS
Instance Attribute Summary
Attributes inherited from EachValidator
Attributes inherited from ActiveModel::Validator
Instance Method Summary collapse
Methods included from Comparability
Methods inherited from EachValidator
Methods inherited from ActiveModel::Validator
#initialize, kind, #kind, #validate
Constructor Details
This class inherits a constructor from ActiveModel::EachValidator
Instance Method Details
#check_validity! ⇒ Object
10 11 12 13 14 15 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activemodel-7.0.4/lib/active_model/validations/comparison.rb', line 10 def check_validity! unless (.keys & COMPARE_CHECKS.keys).any? raise ArgumentError, "Expected one of :greater_than, :greater_than_or_equal_to, "\ ":equal_to, :less_than, :less_than_or_equal_to, or :other_than option to be supplied." end end |
#validate_each(record, attr_name, value) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activemodel-7.0.4/lib/active_model/validations/comparison.rb', line 17 def validate_each(record, attr_name, value) .slice(*COMPARE_CHECKS.keys).each do |option, raw_option_value| option_value = option_value(record, raw_option_value) if value.nil? || value.blank? return record.errors.add(attr_name, :blank, **(value, option_value)) end unless value.public_send(COMPARE_CHECKS[option], option_value) record.errors.add(attr_name, option, **(value, option_value)) end rescue ArgumentError => e record.errors.add(attr_name, e.) end end |