lib/dry/schema/key_validator.rb in dry-schema-1.5.0 vs lib/dry/schema/key_validator.rb in dry-schema-1.5.1
- old
+ new
@@ -51,10 +51,11 @@
hash.flat_map { |key, _|
case (value = hash[key])
when Hash
[key].product(key_paths(hash[key])).map { |keys| keys.join(DOT) }
when Array
- value.flat_map.with_index { |el, idx|
+ hashes_or_arrays = value.select { |e| e.is_a?(Array) || e.is_a?(Hash) }
+ hashes_or_arrays.flat_map.with_index { |el, idx|
key_paths(el).map { |path| ["#{key}[#{idx}]", *path].join(DOT) }
}
else
key.to_s
end