title: Laravel Validation : Validate only if fields are present
body: <p>So I have fields that are to be hidden if it met certain conditions. And now I'm having problem in my validation. Here's what I have:</p>
  
  <p><strong>blade.php</strong></p>
  
  <pre><code>&lt;div class="{{ $room['show_checkin_out'] ? '' : 'hide-fields' }}"&gt;
      &lt;div class="form-group check-in-dtls"&gt;
          &lt;label for="before_checkin"&gt;@lang('before_checkin')&lt;/label&gt;
          &lt;input type="text" class="form-control" id="before_checkin" name="before_checkin" placeholder="@lang('before_checkin')" value="{{ old('before_checkin', '') }}"&gt;
          @if ($errors-&gt;has('before_checkin'))
              &lt;div class="form-group"&gt;
                  &lt;p class="text-danger"&gt;{{ $errors-&gt;first('before_checkin') }}&lt;/p&gt;
              &lt;/div&gt;
          @endif
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p><strong>validation file</strong></p>
  
  <pre><code>'before_checkin' =&gt; ['sometimes', 'required', 'max:255'],
  </code></pre>
  
  <p><strong>css</strong></p>
  
  <pre><code>.hide-fields{
      display: none;
  }
  </code></pre>
  
  <p>I would like the fields to be required only if it is shown and my validation is not working well. For this one, what is the best approach to do?</p>