I was working on project which had to validate array input fields, which looked like so:
<input type="text" name="tags[0][id]" value="5" />
<input type="text" name="tags[1][id]" value="6" />
The normal way to validate this is by using a rule like this:
"tags.*.id" => ["required", "exists:tags:id"]
but in this case the required
doesn’t work. So, you have to do this as well:
"tags" => ["required"]
I discovered this somewhere on the internet but I can’t remember where so credit goes to Unknown
.