title: How to validate an input field if value is not null in Laravel
body: <p>I am trying to create and update users with laravel 5.4</p>
  
  <p>This is the validation added for create user. It works.</p>
  
  <pre><code>$this-&gt;validate($request, [
      'name' =&gt; 'required|max:255',
      'email' =&gt; 'required|email|max:255|unique:users',
      'password' =&gt; 'required|min:6|confirmed',
  ]);
  </code></pre>
  
  <p>On update the password field is not required. But validate the min:6 and confirmed rule if the password field is not null. Tried with <code>sometimes</code>.. but not working..</p>
  
  <pre><code>$this-&gt;validate($request, [
      'name' =&gt; 'required|max:255',
      'email' =&gt; 'required|email|max:255|unique:users,email,'.$id,
      'password' =&gt; 'sometimes|min:6|confirmed',
  ]);
  </code></pre>