title: Laravel validation: rules in required_if
body: <p>I have a select list, where the first option is disabled, that's way when the user does not choose an valid option, the result of the select list will not be in the request.</p>
  
  <p>In the validation, the field required, if the value of an other field is for example : <code>1, in case not 1, the field is not required</code>.</p>
  
  <p>The code:</p>
  
  <pre><code>'city_id' =&gt; [
  'required',
  'integer',
  Rule::in(City::availableCities()),
  ],
  'district_id' =&gt; new DistrictValidation(request('city_id')),
  </code></pre>
  
  <p>How I can do that, the <code>district_id</code> throw the validation every time,  regardless of, it is in the request, or not.</p>
  
  <p>Thanks for answers,</p>
  
  <p>Update:
  Maybe you see clearly, if the DistrictValidation rule is here:</p>
  
  <pre><code>class DistrictValidation implements Rule
  {
      protected $city;
      private $messages;
  
      /**
       * Create a new rule instance.
       *
       * @param $cityId
       */
      public function __construct($cityId)
      {
          $this-&gt;city = City::find($cityId);
      }
  
      /**
       * Determine if the validation rule passes.
       *
       * @param  string  $attribute
       * @param  mixed  $value
       * @return bool
       */
      public function passes($attribute, $value)
      {
          dd('here');
          if (!$this-&gt;city) {
              return false;
          }
  
          if (!$this-&gt;city-&gt;hasDistrict) {
              return true;
          }
  
          $validator = Validator::make([$attribute =&gt; $value], [
              $attribute =&gt; [
                  'required',
                  'integer',
                  Rule::in(District::availableDistricts()),
              ]
          ]);
  
          $this-&gt;messages = $validator-&gt;messages();
  
          return $validator-&gt;passes();
      }
      /**
       * Get the validation error message.
       *
       * @return string
       */
      public function message()
      {
         return optional($this-&gt;messages)-&gt;first('district_id');
      }
  }
  </code></pre>