-
Notifications
You must be signed in to change notification settings - Fork 512
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
Array validation does not check if the provided value is an array #1563
Comments
Hello there friedow 👋 Thank you for opening your very first issue in this project. We will try to get back to you as soon as we can.👀 |
We are coercing to an array, so removing that would certainly be a breaking change. |
I agree. Was there a reason why values were siently coerced to an array though? |
Depends on the context. For bodies, I agree that it's weird, query params less so. |
Agreed, for query params this makes more sense |
To me it is really weird that validation changes inputs (body and query params alike). I think this should be a breaking change and validation should not implicitly coerce values. |
Just another sample that we currently facing: when the TS type allows |
@WoH and I just had a talk offline and we agreed to make the coercion of request bodies configurable by adding a config flag |
Sorting
I'm submitting a ...
I confirm that I
Expected Behavior
If a request body contains a parameter typed as an array, it should be validated that the provided value is actually an array.
Current Behavior
If a request body contains a parameter typed as an array:
You can actually provide a Request having the parameter set to the arrays generic type without the validation catching it:
Possible Solution
I'll provide a fix for this in the code :).
Steps to Reproduce
See above
Context (Environment)
Version of the library: v6.0.1
Version of NodeJS: v18.18.2
Detailed Description
I'll use the Array.isArray() function to validate that the input to
validateArray()
is in fact an array. If not, a validation error will be produced by the function.Breaking change?
Nope 🎉
The text was updated successfully, but these errors were encountered: