Class: LIVR::Rules::Meta::NestedObject

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

Instance Method Summary collapse

Constructor Details

#initialize(livr) ⇒ NestedObject


6
7
8
# File 'lib/livr/rules/meta.rb', line 6

def initialize(livr)
  @validator = Validator.new(livr).prepare
end

Instance Method Details

#call(nested_object, user_data, field_results) ⇒ Object


10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/livr/rules/meta.rb', line 10

def call(nested_object, user_data, field_results)
  return if is_no_value(nested_object)
  return 'FORMAT_ERROR' unless nested_object.is_a?(Hash)

  result = @validator.validate(nested_object)

  if result
    field_results << result
    return
  else
    return @validator.get_errors
  end
end