Laravel validate array of object JSON

You can try to circumvent the issue by first doing:

$data = [ 'data' => $requests->all() ];

Then you can use the rule you suggested:

$validator = Validator::make($data, [
   'data.*.name' => 'required|string',
   'data.*.' => 'required|string'
]);

Not the most elegant solution but it solves your issue...


I was able to do this in laravel 6 like the following via App\Http\Requests CustomRequestClass

public function rules()
{
    return [
        '*.name' => 'required',
        '*.tag' => 'required'
    ];
}