How to restrict unsuitable requests using validation rules in Laravel 5.8?

65
July 11, 2019, at 9:10 PM

I have only one validation rule in my Laravel project:

$validator = $request->validate([
  'search' => 'nullable|max:20',
  'sortby' => 'nullable|asc|desc',
]);

But if I have any another variable in my Request $_GET['email'] for example, no error returns.

How to prevent unsupported validation inputs via validation rules?

Answer 1

Just ignore them. It's not uncommon for systems outside of your control to add $_GET parameters - any links shared on Facebook, for example, will result in a fbclid (Facebook click ID) parameter coming through.

As long as your code isn't set to blindly do something with any $_GET parameter in the request, there's no harm in having them. Have your code specifically look for and handle search and sortby.

READ ALSO
Sort result with empty strings last

Sort result with empty strings last

I have this locations table:

67
“No module named specutils” although specutils installation went through

“No module named specutils” although specutils installation went through

I am trying to install the Specutils packageI followed these instructions and typed the following command in my Anaconda Prompt terminal:

43
findViewById null on PreferenceFragment

findViewById null on PreferenceFragment

I am using a custom layout in my settings fragment, like below:

35