title: Can I override laravel 5.6 validation?
body: <p>I am trying to add condition based validation. I have a  detect function which is responsible for detecting that input is email or a number </p>
  
  <pre><code>$detectInput = $this-&gt;EmailService-&gt;detectInput($request-&gt;email);
  </code></pre>
  
  <p>So <code>$detectInput</code> always returns <code>0</code> or <code>1</code> or <code>2</code> </p>
  
  <pre><code>$messages = [
      'required' =&gt; 'The :attribute field is required.',
      'unique' =&gt; 'The :attribute already exists.',
      'email' =&gt; 'The :attribute is invalid',
  ];
  
  $rules = [
      'email'     =&gt; 'required|string',
  ];
  
  
      $detectInput = $this-&gt;EmailService-&gt;detectInput($request-&gt;email);
      if ($detectInput===1 || $detectInput===0) {
          $rules =  array_set($rules, 'email', 'email|unique:users');
      }
  
      if ($detectInput===2) {
          $rules =  array_set($rules, 'email', 'unique:users,login_number');
      }
  
      $validator = Validator::make($request-&gt;all(), $rules, $messages);
  </code></pre>
  
  <p>The first <code>if-statement</code> is working fine, but I am not able to override when second <code>if-statement</code> get true. I want to override validation that check the input from <code>users.login_number</code> columns value, where value is duplicated or no instead of <code>users.email</code>.</p>
  
  <p>can someone kindly guide me about it, I would appreciate it.</p>