Open midnight-wonderer opened 3 years ago
Oops! my bad
I can avoid the error myself by detecting keys.empty?
in my macro.
resolved_value, base_path = if keys.empty?
[values.data, []]
else
[value, path.keys]
end
# use resolved_value and base_path for validations
If I call value
as I described initially, the error will be triggered.
I'll leave this thread open and let the maintainer decide whether the inconsistencies are something to be handled by dry-rb, or by consumers. I would understand if there is no good solution for the library, though. Feel free to close the thread if that is the case.
Describe the bug
I extracted a macro into a reusable module, like this:
and use it like this:
which works fine.
But I cannot use it on the root hash, like this:
Expected behavior
The macro should validate the root hash the same way as when I use it on an inner hash.
Actual behavior
dry-validation throws an
ArgumentError
My environment
Suggestion
Probably adding
around here.