Answer the question
In order to leave comments, you need to log in
Laravel 5.4 Validator & Why does it filter randomly?
In the HTML form, the fields are:
category (Select), title (Input), text (TextArea) In the Validator
controller
'category' => 'required|exists:categories,code',
'title' => 'required|between:15,150',
'text' => 'required|between:30,5000',
if ($validator->fails()) {
dd($validator->messages());
}
return back()->withErrors($validator)->withInput();
Answer the question
In order to leave comments, you need to log in
Outcome: Many here began to "yell" look at the documentation, etc. Apparently they write like this everywhere where the question is more complicated than 2 + 2.
Therefore, maybe someone will come across I tell. Tested with different session drivers. There was a Google Recaptcha on the village! (not connected for validation in the validator)
So, if there is a session driver - SESSION_DRIVER=cookie And fill in some of the fields incorrectly, and then click the recaptcha "I'm not a robot" and send, then if there are errors, it will redirect back, but with an empty $validator-> messages()
The most interesting thing is that recaptcha itself as a functional is not connected in the system!!! The process of pressing the button is important, apparently at this moment it changes the DOM in the browser and somehow affects it.
If you do not click it, then the validator works and redirects correctly!
But when I changed the driver to SESSION_DRIVER=database
That all earned without errors!
By trial, it turned out that recaptcha affects the session in the Chrome browser when SESSION_DRIVER=cookie
is set in the Laravel settings.
If there is someone who will link all this in more detail, it will be great!
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question