Class: Dry::Schema::KeyValidator Private

Inherits:
Object
  • Object
show all
Extended by:
Initializer
Defined in:
lib/dry/schema/key_validator.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Constant Summary collapse

INDEX_REGEX =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

/\[\d+\]/
DIGIT_REGEX =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

/\A\d+\z/
BRACKETS =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

"[]"

Instance Method Summary collapse

Instance Method Details

#call(result) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/dry/schema/key_validator.rb', line 20

def call(result)
  input = result.to_h

  input_paths = key_paths(input)
  key_paths = key_map.to_dot_notation

  input_paths.each do |path|
    error_path = validate_path(key_paths, path)

    next unless error_path

    result.add_error([:unexpected_key, [error_path, input]])
  end

  result
end