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.

Leave a Comment