title: How to pass variable to Laravel Validator Rule
body: <h2>The Issue</h2>
  <p>Consider this:</p>
  <pre><code>protected $rules = array(
      'mobile_number' =&gt; 'phone:AUTO,mobile,:country_code'
  );
  </code></pre>
  <p>In the above example, the value of <code>country_code</code> needs to change dependant on a variable defined prior to the validation taking place.</p>
  <p>With this in mind, is it possible to pass a variable into a Laravel Validation rule?</p>
  <p>Please bear in mind, this is how I call my validation:</p>
  <pre><code>if(!$this-&gt;some_validator-&gt;with($data)-&gt;passes()){
  
      // Get the validation errors and throw the exception
      $error_info = $this-&gt;some_validator-&gt;formatErrorMessages();
      throw new ExampleException(ExampleExceptionType::$VALIDATION_ERROR,$error_info);
  }
  </code></pre>