Sha256: 722f50a26a9f4c9941dd0af0374ab9ee41d5872d9738475cb2728628aeb10a92

Contents?: true

Size: 272 Bytes

Versions: 14

Compression:

Stored size: 272 Bytes

Contents

require 'haveapi/client/validator'

module HaveAPI::Client
  class Validators::Presence < Validator
    name :present

    def valid?
      return false if value.nil?
      return !value.strip.empty? if !opts[:empty] && value.is_a?(::String)

      true
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
haveapi-client-0.25.0 lib/haveapi/client/validators/presence.rb
haveapi-client-0.24.0 lib/haveapi/client/validators/presence.rb
haveapi-client-0.23.7 lib/haveapi/client/validators/presence.rb
haveapi-client-0.23.6 lib/haveapi/client/validators/presence.rb
haveapi-client-0.23.5 lib/haveapi/client/validators/presence.rb
haveapi-client-0.23.4 lib/haveapi/client/validators/presence.rb
haveapi-client-0.23.3 lib/haveapi/client/validators/presence.rb
haveapi-client-0.23.2 lib/haveapi/client/validators/presence.rb
haveapi-client-0.23.1 lib/haveapi/client/validators/presence.rb
haveapi-client-0.23.0 lib/haveapi/client/validators/presence.rb
haveapi-client-0.22.1 lib/haveapi/client/validators/presence.rb
haveapi-client-0.22.0 lib/haveapi/client/validators/presence.rb
haveapi-client-0.21.1 lib/haveapi/client/validators/presence.rb
haveapi-client-0.21.0 lib/haveapi/client/validators/presence.rb