You can separate the validation by sheet index so that each sheet will have it's own validation. To do that you need to implement WithMultipleSheets
contract. In your case that would be like this:
namespace App\Imports;
use Maatwebsite\Excel\Concerns\WithMultipleSheets;
use Maatwebsite\Excel\Concerns\WithValidation;
class SheetImport implements WithMultipleSheets
{
public function sheets(): array
{
return [
0 => new class implements ToCollection, WithValidation
{
public function rules(): array
{
return [
"*.0" => ['required', 'integer'],
"*.1" => ['required'],
"*.2" => ['required', 'max:5'],
];
}
},
1 => new class implements ToCollection, WithValidation
{
public function rules(): array
{
return [
"*.0" => ['required'],
"*.1" => ['required', 'exists:users'],
"*.2" => ['required'],
"*.3" => ['required', 'alpha'],
];
}
},
];
}
}
Note that sheet indices start at zero. You can also create sheep import classes separately as explained at Laravel Excel - Multiple Sheets. The point is that you return sheet import objects from sheets
method.