Class: Errapi::Validations::Presence

Inherits:
Base
  • Object
show all
Defined in:
lib/errapi/validations/presence.rb

Defined Under Namespace

Classes: Factory

Instance Method Summary collapse

Methods inherited from Base

#actual_option_value, #callable_option_type_error, #callable_option_value?, #callable_option_value_error, #exactly_one_option?, #initialize

Constructor Details

This class inherits a constructor from Errapi::Validations::Base

Instance Method Details

#validate(value, context, options = {}) ⇒ Object



7
8
9
10
11
# File 'lib/errapi/validations/presence.rb', line 7

def validate value, context, options = {}
  if reason = check(value, options.fetch(:value_set, true))
    context.add_error reason: reason
  end
end