From 61a4b5555975b873e560df2e2bdfb82e11d134be Mon Sep 17 00:00:00 2001 From: Pascal Baljet Date: Thu, 27 Nov 2025 09:37:01 +0100 Subject: [PATCH] Multiple errors per field --- v2/the-basics/validation.mdx | 43 ++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/v2/the-basics/validation.mdx b/v2/the-basics/validation.mdx index ed1e177..d12e315 100644 --- a/v2/the-basics/validation.mdx +++ b/v2/the-basics/validation.mdx @@ -136,6 +136,49 @@ export default function Edit() { When using the Vue adapters, you may also access the errors via the `$page.props.errors` object. +### Multiple Errors Per Field + +By default, Inertia's Laravel adapter returns only the first validation error for each field. You may opt-in to receiving all errors by setting the `$withAllErrors` property to `true` in your middleware. + +```php +class HandleInertiaRequests extends Middleware +{ + protected $withAllErrors = true; + + // ... +} +``` + +When enabled, each field will contain an array of error strings instead of a single string. + + + +```vue Vue icon="vuejs" +

{{ error }}

+``` + +```jsx React icon="react" +{errors.email.map((error, index) =>

{error}

)} +``` + +```svelte Svelte icon="s" +{#each errors.email as error} +

{error}

+{/each} +``` + +
+ +You may configure TypeScript to expect arrays instead of strings in a `global.d.ts` file. + +```ts +declare module '@inertiajs/core' { + export interface InertiaConfig { + errorValueType: string[] + } +} +``` + ## Repopulating Input While handling errors in Inertia is similar to full page form submissions, Inertia offers even more benefits. In fact, you don't even need to manually repopulate old form input data.