Sha256: e6605ca9003f5873a71ab20da3d5e804a733f287e9e7a11085a194d45e053018

Contents?: true

Size: 504 Bytes

Versions: 14

Compression:

Stored size: 504 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(instance)
      super || "doesn't match confirmation"
    end
  end
end

Version data entries

14 entries across 14 versions & 2 rubygems

Version Path
mack-notifier-0.8.2 lib/gems/validatable-1.6.7/lib/validations/validates_confirmation_of.rb
mack-notifier-0.8.3 lib/gems/validatable-1.6.7/lib/validations/validates_confirmation_of.rb
mack-notifier-0.8.3.1 lib/gems/validatable-1.6.7/lib/validations/validates_confirmation_of.rb
validatable-1.6.0 lib/validations/validates_confirmation_of.rb
validatable-1.6.7 lib/validations/validates_confirmation_of.rb
validatable-1.6.2 lib/validations/validates_confirmation_of.rb
validatable-1.6.3 lib/validations/validates_confirmation_of.rb
validatable-1.6.4 lib/validations/validates_confirmation_of.rb
validatable-1.4.0 lib/validations/validates_confirmation_of.rb
validatable-1.5.2 lib/validations/validates_confirmation_of.rb
validatable-1.6.1 lib/validations/validates_confirmation_of.rb
validatable-1.6.6 lib/validations/validates_confirmation_of.rb
validatable-1.3.4 lib/validations/validates_confirmation_of.rb
validatable-1.5.0 lib/validations/validates_confirmation_of.rb