how to validate nested array and show message in laravel

Viewed 1141

I've got an form data like this

enter image description here

What I want to achieve is that in every question must be one answer with correct field. The validation is following:

$this->validate($request, [
    'questions.*.answers.*.correct' => 'required',
    ...
]);

But this validation requires that all answer fields have to be marked as correct.

So, my first question is how to validate this array to check if every question has one correct answer ?
And second one is, if validation fails how do I show which question doesn't have a correct answer ? Is there any wildcard like :index or something to use in my validation messsage?

1 Answers
Related