Skip to content
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

QueryParam. Scrict option does not work in case with map(array) #1654

Closed
nickdani opened this issue Jan 20, 2017 · 4 comments
Closed

QueryParam. Scrict option does not work in case with map(array) #1654

nickdani opened this issue Jan 20, 2017 · 4 comments

Comments

@nickdani
Copy link

Hi.
I have this annotation:
@QueryParam(map=true, name="ids",requirements="\d+", strict=true, nullable=false)
for this url /test?ids[]=1&ids[]=2&ids[]=3

so, I assume that there should be an error when I'm trying to use such url:
/test without ids in query string.
But, unfortunately I can pass validation by this url :(
am I doing something wrong?
For me it looks like option strict does not work for arrays

"friendsofsymfony/rest-bundle": "^2.1"

@klnjmm
Copy link

klnjmm commented Jul 20, 2017

Hi,

I have exactly the same problem and I expected the described behavior.
Is there something done since 6 March 2017 ?

Thanks

@elkangaroo
Copy link

elkangaroo commented Mar 9, 2018

I think this is not about "strict=true" but about "nullable=false" not behaving as expected (same as issue #1765 and probably also related: #1785). The NotNull constraint is only applied to the array elements, not the param itself, which is unexpected.

I don't know what and when exactly this changed, because we upgraded from 1.8 to 2.3 and somewhere in between this seems to have changed :(

@elkangaroo
Copy link

Here is the relevant code from v1.8: https://github.com/FriendsOfSymfony/FOSRestBundle/blob/1.8/Request/ParamFetcher.php#L166

There a BadRequestHttpException "%s parameter value of '%s' is not an array" was thrown when we had "array=true" and "nullable=false". In newer versions, this behaviour changed (and as far as I see not documented).

@xabbuh
Copy link
Member

xabbuh commented Nov 20, 2018

Does #1769 fix this?

phamuyentri pushed a commit to phamuyentri/FOSRestBundle that referenced this issue Dec 10, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants