Oct 16, 2018
0
Level 1
Laravel validation 'different' fails when other attribute is null
Hello I'm having troubles with the different validation.
I have 2 variables that can be null. What I want to achieve is whenever the variable is present, force it to have exactly 5 digits and not to have the same value.
These are the rules that I've set:
'zip_departure' => 'nullable|digits:5',
'zip_arrival' => 'nullable|different:zip_departure|digits:5',
The problem is when I set zip_departure as null it throws up a validation error saying both parameters cannot have the same value. But if I dd() both variables they have:
'zip_departure': null
'zip_arrival': '28100'
What am I missing here?
I'm using Laravel 5.6
Please or to participate in this conversation.