title: laravel validate Content-Type: application/json request
body: <p>in laravel 5 i made a new request named <code>ApiRequest</code>.</p>
  
  <pre><code>class ApiRequest extends Request
  {
      public function authorize() {
        return $this-&gt;isJson();
      }
      public function rules()
      {
       return [
              //
              ];
      }
  }
  </code></pre>
  
  <p>As you can see i am accepting only json data. And i am receiving the json in controller like this</p>
  
  <pre><code>public function postDoitApi(ApiRequest $payload) {
          $inputJson = json_decode($payload-&gt;getContent()); 
          $name = $inputJson-&gt;name;
  }
  </code></pre>
  
  <p>Which is working fine. I am getting data in <code>$name</code>. But now i need to validate the input json.
  I need to set validation rule in <code>ApiRequest</code> for the <code>name</code> key like this</p>
  
  <pre><code>public function rules()
  {
       return [
              'name' =&gt; 'required|min:6'
              ];
  }
  </code></pre>
  
  <p>Help me to do this. Thanks.</p>