Class: Validatable::ValidatesConfirmationOf

Inherits:
ValidationBase show all
Defined in:
lib/validations/validates_confirmation_of.rb

Overview

:nodoc:

Instance Attribute Summary

Attributes inherited from ValidationBase

#attribute

Instance Method Summary collapse

Methods inherited from ValidationBase

after_validate, after_validations, all_after_validations, all_defaults, default, defaults, #initialize, option, #raise_error_if_key_is_dup, required_option, #run_after_validate, #should_validate?, #validate_this_time?

Methods included from Requireable

included, #requires

Methods included from Understandable

included, #must_understand

Constructor Details

This class inherits a constructor from Validatable::ValidationBase

Instance Method Details

#message(instance) ⇒ Object



11
12
13
# File 'lib/validations/validates_confirmation_of.rb', line 11

def message(instance)
  super || "doesn't match confirmation"
end

#valid?(instance) ⇒ Boolean

Returns:

  • (Boolean)


6
7
8
9
# File 'lib/validations/validates_confirmation_of.rb', line 6

def valid?(instance)
  return instance.send(self.attribute) == instance.send("#{self.attribute}_confirmation".to_sym) if case_sensitive
  instance.send(self.attribute).to_s.casecmp(instance.send("#{self.attribute}_confirmation".to_sym).to_s) == 0
end