Sha256: 5375c03cc90af242997ba10d7562375e2d14e459d77c3fafb79aa37c4d7d5fc5

Contents?: true

Size: 326 Bytes

Versions: 6

Compression:

Stored size: 326 Bytes

Contents

# frozen_string_literal: true

module SimpleValidate
  class ValidatesPresenceOf < ValidatesBase
    def initialize(attribute, options)
      super(attribute, options[:message] ||
        "can't be empty", options[:if] || proc { true })
    end

    def valid?(instance)
      !instance.send(attribute).nil?
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
simple_validate-2.2.2 lib/simple_validate/validates_presence_of.rb
simple_validate-2.1.2 lib/simple_validate/validates_presence_of.rb
simple_validate-2.0.2 lib/simple_validate/validates_presence_of.rb
simple_validate-2.0.1 lib/simple_validate/validates_presence_of.rb
simple_validate-2.0.0 lib/simple_validate/validates_presence_of.rb
simple_validate-1.2.3 lib/simple_validate/validates_presence_of.rb