-
Couldn't load subscription status.
- Fork 265
Description
Greetings,
I'm working on a laravel / vue-3 app where it makes sense to return all the validation errors for each form field.
I noticed that the Inertia\Middleware\resolveValidationErrors is only returning the first error for each form field. https://github.com/inertiajs/inertia-laravel/blob/2.x/src/Middleware.php
Given the following example with input name => a.
$request->validate([
'name' => ['required', 'min:2', 'max:255', 'email'],
]);
In a non-inertia endpoint laravel would return json with all the validation errors for each field.
{
"message": "The name must be at least 2 characters. (and 1 more error)",
"errors": {
"name": [
"The name must be at least 2 characters.",
"The name must be a valid email address."
]
}
}
Of course I can overwrite the parent method and create my own custom resolveValidationErrors method which returns all the errors for one field. But the problem is still encountered on frontend with useForm helper where the API like errors/setError is built around the backend only returning 1 error per field.
I'm aware that returning all validation errors might be a huge breaking change. Or is there something I have missed?
Kind Regards