Laravel 5.x包中的自定义错误消息

I am creating a package for Laravel 5.4 and have a few custom regexes with error messages. Normally you put these messages in de validation.php file (which works). But when installing a package I want the user to not have to copy paste those in.

Is there way for a package to have an extra validation language file that will automatically be called when the rule is not found in the regular validation language file?

OK Figured it out.

If you're using Validator::make() call. You can do this

$fields = [
    "fieldA" => "Testing",
    "fieldB" => "TextB",
];

$rules = [
    "fieldA" => [
        "alpha",
    ],
    "fieldB" => [
        "regex:/TextC/",
    ],
];

$messages = [
    "fieldA.alpha" => "Sorry champ, but fieldA must be only characters",
    "fieldB.regex" => "The regex failed here",
];

$validator = Validator::make($fields, $rules, $messages);
if ($validator->fails()) return $validator->messages()->all();

I haven't tested this code - mine is a little different, but this should work.

Reference here: https://laravel.com/docs/5.4/validation#custom-error-messages