Validating JSON input Laravel
<p>I am using laravel , and json input from the client. I would like to know if there is a way to create a form request that does json validation instead of url parameters. I found this class online :</p>

<pre><code>&lt;?php
namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

abstract class JsonRequest extends FormRequest {

    /**
     * Get the validator instance for the request.
     *
     * @return \Illuminate\Validation\Validator
     */
    protected function getValidatorInstance()
    {
        $factory = $this-&gt;container-&gt;make('Illuminate\Validation\Factory');

        if (method_exists($this, 'validator'))
        {
            return $this-&gt;container-&gt;call([$this, 'validator'], compact('factory'));
        }
        return $factory-&gt;make(
            $this-&gt;json()-&gt;all(), $this-&gt;container-&gt;call([$this, 'rules']), $this-&gt;messages(), $this-&gt;attributes()
        );
    }
}
</code></pre>

<p>Now , when I make a class that extends this instead of Request, I am able to validate. This is an example:</p>

<pre><code>&lt;?php

namespace App\Http\Requests;

use App\Http\Middleware\AuthTokenMiddleware;
use App\Http\Requests\Request;
use Illuminate\Support\Facades\Input;

class VotesCreateRequest extends JsonRequest
{


    public function response(array $errors)
    {

        //
        return response()-&gt;json(["error_list" =&gt; $errors], 200);


    }


    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {return true;


        if(AuthTokenMiddleware::getUser()-&gt;can('access-group',Input::get("grp_id"))){
            return true;
        }
        else{
            return false;
        }
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {


        return [

            'sub_items'=&gt;'required|array',
            'sub_items.*.email' =&gt;'required'
        ];
    }
}
</code></pre>

<p>But I want to know how to validate items inside items of the json file .</p>

<p>For example, i have :
{"sub_items":["something","another thing","yet another","another ","last"]}</p>

<p>How do I validate if all these items in sub sub_items are of type email ?</p>