You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This fails because visit_array tries to define a member rule every time, even when they don't exist.
I did some small tests and this seemed to solve the issue:
def visit_array(node)
if node
registry['array'].member(call(node))
else
registry['array']
end
end
But I'm not sure if this would impact other usages of the AST with an array.
This is basically needed for schema validations that are done like that: required(:skills).filled(:array?), in which we just want to ensure that the key has an array, but the values inside of it doesn't matter.
We should handle this use case, but I gotta ask - why the array elements "don't matter"? What I'm trying to do with these libs is to make people concious about type safety in a rather strict way. If you're using these libs to handle input from "the outside world" then you should be conservative about type expectations. I also understand that these libs might be used in contexts where less strict approach is fine, so I'm wondering what's your use case now :)
I was thinking about that too, I think that we will always care about the contents of an array in some way. My real use case was that each itself wasn't checking before hand if something was an array and blew up when calling map, that's why I wanted to set the :array? rule there, but it then throw that error.
Maybe we should raise a more meaningful exception when someone is trying to use :array? without member rules? Or just let it be?
Falling AST:
This fails because
visit_array
tries to define a member rule every time, even when they don't exist.I did some small tests and this seemed to solve the issue:
But I'm not sure if this would impact other usages of the AST with an array.
This is basically needed for schema validations that are done like that:
required(:skills).filled(:array?)
, in which we just want to ensure that the key has an array, but the values inside of it doesn't matter.Related: dry-rb/dry-validation#170
The text was updated successfully, but these errors were encountered: