Sha256: 5b50b293bda0b4c6c2212172a9c8df334252b1fbd9192d07d82b94316dd7cf21

Contents?: true

Size: 494 Bytes

Versions: 2

Compression:

Stored size: 494 Bytes

Contents

module Validatable
  class ValidatesConfirmationOf < ValidationBase #:nodoc:
    option :case_sensitive
    default :case_sensitive => true
    
    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
    
    def message
      super || "doesn't match confirmation"
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
validatable-1.3.0 lib/validations/validates_confirmation_of.rb
validatable-1.3.2 lib/validations/validates_confirmation_of.rb