title: Return validation error message as JSON - Laravel 6
body: <p>I want to return a failed validation attempt message in JSON. I used something like this before, which was working on Laravel 5, I believe...</p>
  
  <pre><code>if ($validator-&gt;fails()) {    
      return response()-&gt;json($validator-&gt;messages(), 200);
  }
  </code></pre>
  
  <p>However, for our new project we are using Laravel 6 and the above just returns a blank page. </p>
  
  <p>In Laravel 6 the following returns the error message successfully, albeit not in JSON...</p>
  
  <pre><code>if ($validator-&gt;fails()) {  
      $msg = $validator-&gt;messages();
      dd($msg);
  }
  </code></pre>
  
  <p>There must be a change in the way <code>response()</code> works in Laravel 6.</p>
  
  <p>Any ideas how I get the Validation messages to get returned in JSON in Laravel 6? Thanks.</p>