'Laravel 8 - formatValidationErrors()
In Laravel 5 there was a function formatValidationErrors() that allowed you to format error messages. The application I am updating to Laravel 8 used this to take the validator errors and flashed it to Session. Is there an equivalent for this in Laravel 8? I can't find in the docs.
protected function formatValidationErrors(Validator $validator)
{
if($validator->errors()->all()) {
Session::flash('error', $validator->errors()->all()[0]);
}
return $validator->errors()->all();
}
Solution 1:[1]
You can either add custom validation error message like in here Or you can create your custom exception handler class like in here
If your problem is app-wide then you can use handler class to format all your validations.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | gguney |
