Class: LIVR::Rules::Special::EqualToField

Inherits:
LIVR::Rule
  • Object
show all
Defined in:
lib/livr/rules/special.rb

Instance Method Summary collapse

Constructor Details

#initialize(field) ⇒ EqualToField


20
21
22
# File 'lib/livr/rules/special.rb', line 20

def initialize(field)
  @field = field
end

Instance Method Details

#call(value, user_data, field_results) ⇒ Object


24
25
26
27
28
29
# File 'lib/livr/rules/special.rb', line 24

def call(value, user_data, field_results)
  return if is_no_value(value)
  return 'FORMAT_ERROR' if !is_primitive(value)

  return "FIELDS_NOT_EQUAL" if value != user_data[@field]
end