In version 5.2 of Lumen the following validation in Controller is working:
$this->validate($request, [
'nome' => 'required',
'email' => 'required|email',
'cpf' => 'required',
]);
Same as the following View:
@if (count($errors) > 0) {
<div>
<ul>
@foreach($errors->all() as $error){
echo("<li>". $error . "</li>");
}
@endforeach
</ul>
</div>
@endif
It happens that in version 5.5 of Lumen is not working.
The following error is displayed: 1/1) ErrorException Undefined variable: errors in cadastroPessoas.php (line 8) at Application-> Laravel \ Lumen \ Concerns {closure} (8, 'Undefined variable: errors' C: \ wamp64 \ www \ blog \ resources \ views \ domainname.php ', 8, array (' __ path '=>' C: \ wamp64 \ www \ blog \ resources \ '__enable' => object (Factory), 'app' => object (Application)), 'obLevel' => 1, '__env' => object (Factory) 'app' = > object (Application)) in cadastroPessoas.php (line 8) at include ('C: \ wamp64 \ www \ blog \ resources \ views \ cadastroPe ssoas.php