did you try @dd($error) to see what you are actually dealing with?
Apr 14, 2024
4
Level 1
Request validation didn't give the field in fault
Hi all,
I'm starting a new simplet test project with Laravel 11.
I'm using a request like always :
$validated = $request->validate([
'nom' => 'required | max:255',
'prenom' => 'required | max:255',
'email' => 'required | email | max:255 | unique:users',
'motdepasse' => 'required | min:8 | confirmed',
'profil_id' => 'required | exists:profils,id',
'actif' => 'required | integer | between:0,1',
]);
And i'm showing the errors like always :
@if ($errors->any())
<div class="alert alert-danger">
<ul>
@foreach ($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
</div>
@endif
But, i'm only get the error type, not the field name in error :
validation.confirmed
I really don't get what i'm doing wrong, it's making me crazy trying to debbug my projet with that :P
Thanks
Level 122
My guess is that you don't have a french translation for validation.confirmed
in english, validation.confirmed is translated to 'confirmed' => 'The :attribute confirmation does not match.',
If you don't have the translation string then :attribute does not get swapped for motdepasse
Also, change your errors display like;
@foreach ($errors->all() as $key => $error)
<li>{{ $key }}: {{ $error }}</li>
@endforeach
1 like
Please or to participate in this conversation.