Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

rossiluca's avatar

Access Laravel array validation messages from Inertia

I'm trying to access to all the messages passed from a validation in Laravel.

In the controller I defined this validation method:

request()->validate([
    'registrar_id' => 'required|integer',
    'parameters.*.value' => 'required'
]);

This is what Laravel pass to Inertia props:

props: {
  errors: {
    "parameters.0.value": "The field is required",
    "parameters.1.value": "The field is required"
}

I'm using the new Inertia form validation helper so I have something like this in the Vue component:

<jet-input-error :message="form.errors.*" class="mt-2" />

But I can't access to the specific error in the array, because the <jet-input-error> it's inside a foreach in a form

0 likes
1 reply
juliobitencourt's avatar

Since the key of the error message is a string you can access the error in the object

form.errors["parameters.0.value"]

then, inside your foreach, just concatenate the messages

<div v-for="(parameter, index) in form.parameters" :key="index"
    <jet-input-error :message="form.errors['parameters.' + index + '.value']" />
</div>

Please or to participate in this conversation.