title: set laravel validator based on usertype
body: <pre><code>public function register(Request $request){
  
  
      $validator = \Validator::make($request-&gt;all(), [
          'first_name' =&gt; 'required|min:3',
          'email' =&gt; 'required|email|max:255|unique:users',
          'password' =&gt; 'required|min:6|confirmed',
          'password_confirmation' =&gt; 'required',
          'address' =&gt; 'required',
          'phone_number' =&gt; 'required',
      ]);
  
      if($request-&gt;user_type == 1 ){
          $validator = \Validator::make($request-&gt;all(), [
                  'dob' =&gt; 'required'
              ]);
      }
  
      if($request-&gt;user_type == 2 ){
          $validator = \Validator::make($request-&gt;all(), [
                  'doctor_practice' =&gt; 'required'
              ]);
      }
  
      // then, if it fails, return the error messages in JSON format
      if ($validator-&gt;fails()) {    
          return response()-&gt;json($validator-&gt;messages(), 401);
      }
  </code></pre>
  
  <p>How can I set the validator based on user type? I did try does not work fine. </p>