Class: ReeValidator::ValidatePresence

Inherits:
Object
  • Object
show all
Includes:
Ree::FnDSL
Defined in:
lib/ree_lib/packages/ree_validator/package/ree_validator/functions/validate_presence.rb

Constant Summary collapse

PresenceErr =
Class.new(StandardError)

Instance Method Summary collapse

Instance Method Details

#call(value, error = nil) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/ree_lib/packages/ree_validator/package/ree_validator/functions/validate_presence.rb', line 17

def call(value, error = nil)
  if (is_blank(value))

    error ||= PresenceErr.new(
      t(
        'validator.presence.can_not_be_blank',
        default_by_locale: :en
      )
    )

    raise error
  end

  true
end