Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

krishantalwar's avatar

laravel excel import validate each row on conditional basic

I want to validate each row separately .

example in

SR.NO	   check_required	   type
 1	                 yes	                   
 2	                no	              office

1 row there is coloum check_required has yes then i need to check in 1 row . I need to validate there type must has some value

2 row there is coloum check_required has no then i need to check in 2 row . I dont need to validate the type has value or not

i try with this but it not work

'*.type' => ['exclude_unless:check_required,no|required'],

i try with this but it not work

public function withValidator($validator)
{
    $validator->sometimes('*.type', 'required', function($input) {
        dd($input);
       return strtolower($input->check_required) !=  "no";
   });

}

but it error for both records . i need it give error for only for first row

i try to die input . i see it give the array of all rows.

0 likes
0 replies

Please or to participate in this conversation.