Class: ActiveModel::Validations::ConfirmationValidator
- Inherits:
-
EachValidator
- Object
- ActiveModel::Validator
- EachValidator
- ActiveModel::Validations::ConfirmationValidator
- Defined in:
- activemodel/lib/active_model/validations/confirmation.rb
Overview
:nodoc:
Instance Attribute Summary
Attributes inherited from EachValidator
Attributes inherited from ActiveModel::Validator
Instance Method Summary collapse
-
#initialize(options) ⇒ ConfirmationValidator
constructor
A new instance of ConfirmationValidator.
- #validate_each(record, attribute, value) ⇒ Object
Methods inherited from EachValidator
Methods inherited from ActiveModel::Validator
Constructor Details
#initialize(options) ⇒ ConfirmationValidator
Returns a new instance of ConfirmationValidator.
6 7 8 9 |
# File 'activemodel/lib/active_model/validations/confirmation.rb', line 6 def initialize() super({ case_sensitive: true }.merge!()) setup!([:class]) end |
Instance Method Details
#validate_each(record, attribute, value) ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'activemodel/lib/active_model/validations/confirmation.rb', line 11 def validate_each(record, attribute, value) unless (confirmed = record.send("#{attribute}_confirmation")).nil? unless confirmation_value_equal?(record, attribute, value, confirmed) human_attribute_name = record.class.human_attribute_name(attribute) record.errors.add(:"#{attribute}_confirmation", :confirmation, **.except(:case_sensitive).merge!(attribute: human_attribute_name)) end end end |