New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Empty array causing false positive #1230
Comments
Understandable. The behaviour today is like
This would be the most pragmatic approach. Changing the behaviour at all without such will be a breaking change. I don't know how that'd look, but I'd be open for some brainstorming (before anyone jumps into coding). |
Hi @gustavohenke ! I'm willing to help but I don't have any experience in open-source so I'm not sure how that brainstorming would go? 😄 |
Oh, feel free to post some of the API ideas and maybe how you think they should work, and we can go from there. Anything that's not user facing can be changed freely! |
Describe the bug
Hi!
When validations fields I noticed that array had a different behavior than other values.
If an empty array is given no validation is run and the field is considered valid even if we're not expecting an array value.
I think this line in standard-validation.ts producing this behavior.
To Reproduce
Here's a RunKit reproducing the error.
Expected behavior
In the RunKit I'm expecting only
count1
andcount6
to be valid because the doc states if value is an array then each element of an array is validated.It seems a bit weird that all types fails except arrays which means most validators needs an extra
not().isArray()
to prevent unexpected values in following middlewares.Current behavior
In the RunKit ,
count1
,count5
andcount6
are valid.Environment:
PS:
I tagged this as a bug but maybe it should be a feature request?
An option or a config to add that enable or disable the use of array values?
The text was updated successfully, but these errors were encountered: