title: Trying to validate a JSON request in Laravel
body: <p>I have this json respose and how can I validate this json request in laravel : 
  <a href="https://pastebin.com/TP8VcLnk" rel="nofollow noreferrer">https://pastebin.com/TP8VcLnk</a> I know it's not the same w/ just handling basic inputs.</p>
  
  <p>this is my vue code : </p>
  
  <pre><code>  updateUsersProfile(){
       axios({
          method: 'PUT',
          url: this.updateProfileEndpoint , 
          data: {
            form :  this.form
          },
        }).then(response =&gt; { 
          console.log(response);
        }).catch(error =&gt; {
          console.log(error.response.status);
        });
       } 
  
  </code></pre>
  
  <p>this is my code without the validation part, because I can't seem to validate everything</p>
  
  <pre><code>  public function updateUsersProfile($userId)
        {   
  
          if ( request()-&gt;isJson()){
            /*Validate the request*/
  
            $data = json_decode(request()-&gt;form, true);
  
            return $data ; 
  
  
        }
        else {
          $this-&gt;validate($request,[
            // all validation requirements
          ])
  
           $user = auth()-&gt;user()-&gt;with('details')-&gt;find($userId) ;
           $user-&gt;display_name = request()-&gt;get('display_name') ; 
           $user-&gt;username = request()-&gt;get('username');
           $user-&gt;save();
  
           $user-&gt;details-&gt;first_name = request()-&gt;input('first_name') ; 
           $user-&gt;details-&gt;middle_name = request()-&gt;input('middle_name') ; 
           $user-&gt;details-&gt;last_name = request()-&gt;input('last_name') ; 
           $user-&gt;details-&gt;address = request()-&gt;input('address') ; 
           $user-&gt;details-&gt;alternate_email = request()-&gt;input('alternate_email') ; 
           $user-&gt;details-&gt;bio = request()-&gt;input('bio') ; 
           $user-&gt;details-&gt;address = request()-&gt;input('address') ; 
           $user-&gt;details-&gt;save() ;
  
  
           if (request()-&gt;wantsJson()) {
            return response($user, 201);
          }
  
          return redirect()-&gt;route('students.dashboard');
  
  
  
      }
  </code></pre>