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

Gabotronix's avatar

Laravel localized validation error message and custom rule

in my app I want to add a regex rule to secure strong passwords and also wanto to show its localized (translated) error validation message, I have been searching but can't find a good example similar to my codebase.

My current validation rules

public static $sanctumRegister = 
    [
        'password' => 'regex:/^(?=.*[a-z])(?=.*[A-Z])(=.*\d).+$/'|min:8|required|string',
    ];

How I validate my requests

$validator = Validator::make($request->all(), AuthValidator::$sanctumRegister);
$this->validateWith($validator);

Thanks in advance!

0 likes
1 reply
vincent15000's avatar

It depends on how you manage the localization in your app.

Please or to participate in this conversation.