Class: DataMapper::Validations::ConfirmationValidator
- Inherits:
-
GenericValidator
- Object
- GenericValidator
- DataMapper::Validations::ConfirmationValidator
- Defined in:
- lib/dm-validations/validators/confirmation_validator.rb
Overview
Instance Attribute Summary
Attributes inherited from GenericValidator
#field_name, #humanized_field_name, #if_clause, #options, #unless_clause
Instance Method Summary collapse
- #call(target) ⇒ Object
-
#initialize(field_name, options = {}) ⇒ ConfirmationValidator
constructor
A new instance of ConfirmationValidator.
Methods inherited from GenericValidator
#==, #add_error, #evaluate_conditional_clause, #execute?, #inspect, #optional?, #set_optional_by_default
Constructor Details
#initialize(field_name, options = {}) ⇒ ConfirmationValidator
Returns a new instance of ConfirmationValidator.
8 9 10 11 12 13 14 15 16 |
# File 'lib/dm-validations/validators/confirmation_validator.rb', line 8 def initialize(field_name, = {}) super set_optional_by_default @confirm_field_name = ( [:confirm] || "#{field_name}_confirmation" ).to_sym end |
Instance Method Details
#call(target) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/dm-validations/validators/confirmation_validator.rb', line 18 def call(target) return true if valid?(target) = ( @options[:message] || ValidationErrors.( :confirmation, field_name ) ) add_error(target, , field_name) false end |