Validate forms that are dynamically added into the view

I have a livewire component that generates input fields via foreach loop based on how items the customer would like to buy. But I cant seen to validate if required due to if the input is null it doesn’t come across in the array. Therefore livewire doesn’t know it exists.

Using Laravel 8, Livewire v2

Component Controller

class TourBookingForm extends Component
public $qtySelected = 1;

public $inputs = [];

public function store(){
    $validatedDate = $this->validate([
        'inputs.*.*.firstname' => 'required',
        'inputs.*.*.firstname' => 'name field is required',

Blade File:

<form wire:submit.prevent="store>
@for ($i = 1; $i <= $qtySelected; $i++)
<div class="mt-1 sm:mt-0 sm:col-span-2">

    <input type="text" 
        value="{{ old('first_name') }}">

    @error('inputs.' . $i . '.' . $p . '.firstname') <span class="text-danger error">{{ $message }} 


eg if $qtySelected is 3, it will require inputs.1.1.firstname, inputs.2.1.firstname, inputs.3.1.firstname

in some case if a checkbox is selected it would require more inputs inputs.2.2.firstname


I was able to solve this with the flag variable.

protected function rules()
    $array = [];

    for ($i = 1; $i <= $this->qtySelected; $i++) {

        $array['inputs.' . $i . '.1.firstname'] = 'required';
        $array['inputs.' . $i . '.pax'] = 'required';
        $array['inputs.' . $i . '.2.firstname'] = 'required_if:inputs.' . $i . '.pax,==,twin';

    return $array;

Running a for loop in the rules method. Which allowed me to set required for all inputs. then also using the required_if.