Support the ongoing development of Laravel.io →
posted 8 years ago
Validation

I'm using laravel 5.4 to make a custom form validation. But why is the custom error message isn't displayed?

Validator::extend('myCustomeValidator', function ($attribute, $value, $parameters, $validator) {
    //some code here
    return false;
});

return Validator::make($data, [
    'myField' => 'myCustomeValidator',
]);

and added the following to the file : ressources\lang\en\validation.php as the documentation advises:

'custom' => [
    'myField' => [
        'myCustomeValidator' => 'You made an error.',
    ],
],

The error is correctly triggered but instead of my custom error message, I get this:

validation.my_custome_validator

What am I missing?

Last updated 3 years ago.
0

Name of the validation rule cannot contain capital letters but can be snake_cased. Like so:

'custom' => [
    'myField' => [
        'my_custome_validator' => 'You made an error.',
    ],
],
Last updated 8 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

warrio4 warrio4 Joined 7 Feb 2017

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.