Class: WhyValidationsSuckIn96::ValidatesConfirmation

Inherits:
WhyValidationsSuckIn96::Validation show all
Includes:
WhyValidationsSuckIn96::AttributeBasedValidation, WhyValidationsSuckIn96::SkippableValidation
Defined in:
lib/whyvalidationssuckin96/macros/validates_confirmation.rb

Overview

Checks the validity of an attribute against a confirmation field. Note that this validation does not set up the confirmation field on the object, leaving this up to the implementer.

Examples:

Default usage

  class 
    attr_accessor :password, :password_confirmation
    setup_validations do
      validates_confirmation_of :password
    end
  end

Constant Summary

DefaultOptions =
{:message => "does not match the confirmation"}

Constants inherited from WhyValidationsSuckIn96::Validation

DefaultOptions

Instance Method Summary

Methods included from WhyValidationsSuckIn96::AttributeBasedValidation

#attribute, #attribute_value, #initialize

Methods inherited from WhyValidationsSuckIn96::Validation

#failed?, #has_run?, #initialize, #message, new_subclass, #passed?, #validates?

Constructor Details

This class inherits a constructor from WhyValidationsSuckIn96::AttributeBasedValidation

Instance Method Details

- (Object) validate



22
23
24
25
26
27
28
29
30
# File 'lib/whyvalidationssuckin96/macros/validates_confirmation.rb', line 22

def validate
  super
  skip unless confirmation_value = validatable.send(confirmation_field)
  if confirmation_value == attribute_value
    pass
  else
    fail
  end
end