felixkiss / uniquewith-validator

Custom Laravel Validator for combined unique indexes
MIT License
389 stars 129 forks source link

How to manage unique_with combination of three columns but to allow two #88

Closed shone83 closed 6 years ago

shone83 commented 6 years ago

I manage to set not to allow these three combination: name, last_name and telephone. The problem is when I want to enter same name and last_name but without telephone (when telephone is empty or null), I need to allow that but in this code it doesn't:

'name'  => 'unique_with:add_members, last_name, telephone_1',

When I make one column unique I use nullable function but here it doesn't work...

felixkiss commented 6 years ago

I think your options are:

shone83 commented 6 years ago

You are right, this helps:

'telephone_1'   => 'nullable|unique_with:add_members, name, last_name',

Thanks ;)