Issue with array validation with OC v3 and Laravel 9

On my local and staging server, the following validation rule works as expected on OC v2. But it is not working on the client server and OC v3.

the form data

Array
(

    [industries] => Array
        (
            [0] => 19
            [1] => 17
        )
)

the validation rule

$rules = [
    'industries'            => 'required|array|exists:voilaah_astar_industries,id',
];

on the server client, the validation does not pass and replied The industries must be an array. where on my local it works as expected.

what is going on here?

Apparently with Laravel 9 validation, you must define the array key that must be present in the array.

but in my case, i dont have any key, but an index array.

any existing validation of array in OC v3 will not work as in v1 and v2 anymore

I believe that the min:1 rule would suffice.

$rules = [
    'industries' => 'required|min:1|exists:voilaah_astar_industries,id',
];

actually, Laravel 9 validation sysmte detects that the attributes is an array, so this is works:

$rules = [
    'industries' => 'required|exists:voilaah_astar_industries,id',
];
1 Like