1
When placing the option required
in the validation rules of Laravel
$validator=\Validator::make($request->all(),['po_bairro'=>'require|string|min:5|max:50']);
it requires you to have the value to continue the program.
However, in my case, I did not put require as an option. I just set string|min:5|max:50
in the rules.
$validator=\Validator::make($request->all(),['po_bairro'=>'string|min:5|max:50']);
When sending the form with the empty field (po_bairro
), he gives me the error of the rule min
.
Here comes the question, but I did not set require, the validator should not let go?
Dump on
$request->input('po_bairro')
to see how it arrives. When you send it empty. I am considering and trying to understand that the "" is entering as string, then it falls into the rule.– David Dias
Test one
array_filter($request->all())
. So Validator really had received nothing from that field.– David Dias