Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

panthro's avatar

Validate existence of query string?

I want to have a couple of query string params validated (so they are required).

For example, in my controller I could check:

request()->has(['filter.type', 'filter.id'])

I'm tempted to place this as a FormRequest but feels slightly off as it's not a form.

Where would you place code that validates the query string?

0 likes
3 replies
Snapey's avatar
Snapey
Best Answer
Level 122

With this being a get request (I assume) you probably don't want a validation error thrown so just check the parameters and handle the exception how you need to

1 like

Please or to participate in this conversation.