Laravel 5.4 - How to use multiple error messages for the same custom validation rule
问题 In order to reuse code, I created my own validator rule in a file named ValidatorServiceProvider : class ValidatorServiceProvider extends ServiceProvider { public function boot() { Validator::extend('checkEmailPresenceAndValidity', function ($attribute, $value, $parameters, $validator) { $user = User::where('email', $value)->first(); // Email has not been found if (! $user) { return false; } // Email has not been validated if (! $user->valid_email) { return false; } return true; }); } public