Support the ongoing development of Laravel.io →
Validation

I have a validation.php file in /workbench/<vendor>/<package>/lang/en. In this file, I have defined an array with the 'custom' index, so that I would be able to specify my own custom validation messages for this particular package.

However, when I try to validate an object (making sure that it fails) and try to read the errors, it doesn't display my custom messages. Instead, it takes the values defined in the custom array of my /app/lang/en/validation.php file.

When I set the custom array of that language file to an empty array, it just displays the key as the error message, so it still doesn't use my own custom message.

I have checked if my custom language file is being read at all by doing: <?php echo Lang::get('<package>::validation.test') ?>, which did return the expected value of "hello". So it's not that my validation.php file isn't being read, it's just that it's not being used for automated validation messages.

<?php // file: /workbench/<vendor>/<package>/lang/en/validation.php return array( 'test' => 'hello', 'custom' => array( 'view' => array( 'required' => 'We need to know your view!', ), ) ); ?>

Would really appreciate some help here!

Last updated 3 years ago.
0

Hi Jeroen... I added my custom messages at the end of the regular messages section of

/workbench/<vendor>/<package>/lang/en

... "unique" => "The :attribute has already been taken.", "url" => "The :attribute format is invalid.", "my_rule" => "My custom message for my_rule",

and worked... not idea why custom messages doesnt work

Last updated 3 years ago.
0

Sign in to participate in this thread!

PHPverse

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.