I am trying to conditionally validate an array input in Laravel. I am following the documentation provided here. But the documentation does not provide details on how to do it on an array input. Below is the code that I am trying
$rule = [
'report.*' => 'max:255',
'comment.*' => 'exclude_if:report.*,file|max:65535'
];
$validator = Validator::make($array, $rule);
Here the report is a file input and comment is a text area field.
<input type="file" name="report[0]"/>
<input type="file" name="report[1]"/>
<textarea name="comment[0]"></textarea>
<textarea name="comment[1]"></textarea>
The comment field is required if the corresponding file input is empty. How can I achieve this in Laravel 7?