laravel / nova-issues

554 stars 35 forks source link

Cannot validate a MultiSelect field #6248

Closed dominik-eller closed 6 months ago

dominik-eller commented 6 months ago

Description:

I am trying to make a MultiSelect field required and I ended up using something like that:

MultiSelect::make('reason')->options([
            'Option A' => 'Option A',
            'Option B' => 'Option B',
            'Option C' => 'Option C',
        ])->rules('required', 'array', 'min:1'),

I also tried to use 'in:Option A,Option B,Option C' but it is not working.

I am casting the reason property to array as suggested in the documentation, but the validation message always returns "The reason field must be an array."

Detailed steps to reproduce the issue on a fresh Nova installation:

even just using ->rules('required') is not working for MultiSelect field.

crynobone commented 6 months ago

The value send on the request is array as json so the correct validation rule should be json.