Sha256: 04c415e57a2a802c49dee6c2632b68937ef6ce5f65f4a133c84ff584ae2d99c2

Contents?: true

Size: 349 Bytes

Versions: 5

Compression:

Stored size: 349 Bytes

Contents

module Validatable 
  class ValidatesPresenceOf < ValidationBase #:nodoc:
    def valid?(instance)
      return false if instance.send(self.attribute).nil?
      instance.send(self.attribute).respond_to?(:strip) ? instance.send(self.attribute).strip.length != 0 : true
    end
    
    def message
      super || "can't be empty"
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
validatable-1.3.2 lib/validations/validates_presence_of.rb
validatable-1.2.2 lib/validations/validates_presence_of.rb
validatable-1.2.1 lib/validations/validates_presence_of.rb
validatable-1.1.2 lib/validations/validates_presence_of.rb
validatable-1.3.0 lib/validations/validates_presence_of.rb