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

Youtaka's avatar

Override messages key inside a FormRequest

Hi,

Do you know if is it possible to override messages key inside a FormRequest ?

I have a message like this one :

"platform.name.required" => "Name field is required"

I have a problem when I catch the error in Vue because of the key "platform.name".

I tried to use this notation but the problem still here :

"platform" => [
    "name" => [
        "required" => "Name field is required"
    ]
]

Thank you :)

0 likes
4 replies
Sti3bas's avatar
public function messages()
{
    return [
        'platform.name.required' => 'Name field is required',
    ];
}
Youtaka's avatar

Thank you for your answer. This is what I did. But the problem is not the content of the message, but the key.

https://imgur.com/Bx4hDAk

As you can see, 'errors' has a property 'platform.name'. I can properly access it because of the dot notation.

Sti3bas's avatar
Sti3bas
Best Answer
Level 53

@youtaka not sure why you can't access it. data.errors['platform.name'] will give you an array of errors for platform.name field.

Youtaka's avatar

I see, I didn't know I can access an object property with [ ]...

Thank you =).

Please or to participate in this conversation.