Going from the Dev docs on Laravel
$messages = $validator->messages();
echo $messages->first('email');
Could also try getting all messages for one input (to debug)
foreach ($messages->get('email') as $message)
{
//
}
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi all,
I'm using the 4.3 version to test it out, but I have a problem that I don't seem to find the solution to.
When I use the new FormRequest object as shown in the video by Jeffrey, everything works as it should, I get the $errors variable, but I cannot display single error.
If I loop through $errors->all() I get all errors as a list, but when I do $errors->first('first_name') I don't get anything.
Some had the same problem? Any solutions?
Unfortunately, it is not possible to do $errors->first() yet, when using a FormRequest. But chances are great that it is possible when Laravel 4.3 will be released. I guess that it is not possible because of this line: https://github.com/laravel/framework/blob/master/src/Illuminate/Foundation/Http/FormRequest.php#L149
So I think you can override formatErrors() in your FormRequest to solve your problem for the time being (however, I did not try this myself, so I could be wrong).
Please or to participate in this conversation.