laravel / nova-issues

553 stars 34 forks source link

Validation rules not working with exclude_unless / exclude_if Validation Rule for Resource #3498

Closed airdev-web closed 3 years ago

airdev-web commented 3 years ago

Greetings from Belgium !

Description:

Can't use Laravel Validation rules exclude_unless (or even with exclude_if). I need my field allergens to be required only if my field is_active is true.

Following code doesn't seem to work. No error code, but the validation doesn't work.

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

Boolean::make('Actif', 'is_active'),
Textarea::make('Allergènes', 'allergens')
    ->rules('exclude_if:is_active,true|required'),

// I also tried this
Textarea::make('Allergènes', 'allergens')
    ->rules('exclude_if:is_active,true', 'required'),

Thanks for the ideas or correct usage, Romain

crynobone commented 3 years ago

Boolean submit 1 and 0 to the backend, I don't think true would work here.