How to Validate an Array of Objects in Laravel

To validate an array of objects in Laravel, you can use the * identifier for each item in an array, and use the “.” syntax to point to the property.

$validated = $request->validate([
    'row.*.title' => 'required',
    'row.*.post' => 'required',
]);

So the above would read, “Each item in the row array’s title is required,” etc.

2 thoughts on “How to Validate an Array of Objects in Laravel”

  1. thanks very much… I’m getting stuck with this for whole morning but luckily I found your post and I’ve made it…

    Reply

Leave a Comment