Class: HaveAPI::Client::Validators::Presence

Inherits:
HaveAPI::Client::Validator show all
Defined in:
lib/haveapi/client/validators/presence.rb

Instance Attribute Summary

Attributes inherited from HaveAPI::Client::Validator

#params, #value

Instance Method Summary collapse

Methods inherited from HaveAPI::Client::Validator

#errors, #initialize, name, register, validate

Constructor Details

This class inherits a constructor from HaveAPI::Client::Validator

Instance Method Details

#valid?Boolean

Returns:

  • (Boolean)


7
8
9
10
11
12
# File 'lib/haveapi/client/validators/presence.rb', line 7

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

  true
end