title: Laravel 5.4 - How to use multiple error messages for the same custom validation rule
body: <p>In order to reuse code, I created my own validator rule in a file named <strong>ValidatorServiceProvider</strong> :</p>
  <pre><code>class ValidatorServiceProvider extends ServiceProvider
  {
      public function boot()
      {
          Validator::extend('checkEmailPresenceAndValidity', function ($attribute, $value, $parameters, $validator) {
              $user = User::where('email', $value)-&gt;first();
              
              // Email has not been found
              if (! $user) {
                  return false;
              }
              
              // Email has not been validated
              if (! $user-&gt;valid_email) {
                  return false;
              }
              
              return true;
          });
      }
  
      public function register()
      {
          //
      }
  }
  </code></pre>
  <p>And I use this rule like this :</p>
  <pre><code>public function rules()
  {
      return [
          'email' =&gt; 'bail|required|checkEmailPresenceAndValidity'
      ];
  }
  </code></pre>
  <p>But, I want to set different error messages for each case, something like this :</p>
  <pre><code>if (! $user) {
      $WHATEVER_INST-&gt;error_message = 'email not found';
      return false;
  }
          
  if (! $user-&gt;valid_email) {
      $WHATEVER_INST-&gt;error_message = 'invalid email';
      return false;
  }
  </code></pre>
  <p>But I don't figure out how to achieve this without doing 2 different rules ...<br />
  Of course it could work with multiple rules but it will also perform multiple SQL queries, and I really want to avoid that.<br />
  Also, keep in mind that in real case I could have more than 2 validations like theses in a single rule.</p>
  <p>Does anyone have an idea ?</p>
  <p>=====<br />
  EDIT 1 :</p>
  <p>Actually, I think that I want something that works in a similar way to the <code>between</code> or <code>size</code> rules.<br />
  They represent one single rule, but provide multiple error messages :</p>
  <pre><code>'size'                 =&gt; [
      'numeric' =&gt; 'The :attribute must be :size.',
      'file'    =&gt; 'The :attribute must be :size kilobytes.',
      'string'  =&gt; 'The :attribute must be :size characters.',
      'array'   =&gt; 'The :attribute must contain :size items.',
  ],
  </code></pre>
  <p>Laravel checks if the value represents a numeric, a file, a string or an array ; and gets the right error message to use.<br />
  How do we achieve this kind of thing with custom rule ?</p>