Class: Violated::PresenceValidator

Inherits:
Object
  • Object
show all
Defined in:
lib/violated/validators/presence_validator.rb

Instance Method Summary collapse

Constructor Details

#initialize(_) ⇒ PresenceValidator

Returns a new instance of PresenceValidator.



6
7
# File 'lib/violated/validators/presence_validator.rb', line 6

def initialize(_)
end

Instance Method Details

#reasonObject



9
10
11
# File 'lib/violated/validators/presence_validator.rb', line 9

def reason
  :required
end

#valid?(value) ⇒ Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/violated/validators/presence_validator.rb', line 13

def valid?(value)
  !value.nil? && !value.empty?
end