Closed njwela closed 3 years ago
Hi there
Did you set up your validation rules correctly?
This test shows that everything should work just fine: https://github.com/Propaganistas/Laravel-Phone/blob/0a16a46189bc88ced536c36047bf3b1018056139/tests/PhoneValidatorTest.php#L575-L581
( FYI: The demo app is set up to always require a value. I don't think a comparison can be made in that sense. )
These are my rules
$validator = Validator::make($req->all(), [ 'category' => ['required'], 'location' => ['required'], 'address' => ['required', 'string', 'max:100'], 'title' => ['required', 'string', 'max:100'], 'description' => ['string', 'max:200'], 'case_image' => ['max:1024', 'mimes:jpeg,bmp,png'], 'phone_number' => ['nullable','phone:ZW'], 'addr_lat' => ['required'], 'addr_lng' => ['required'] ]);
Your validation rule looks fine. You could try to inspect the actual received value using dd($req->input('phone_number')
.
If i dont enter anything, it returns null, if i do, return anything i put in the field
I'm afraid I can't help you as the package works fine. The automated test passes and I'm using the nullable/phone validation rule combination myself in several projects without any problems.
This is still an issue at laravel-phone version "^5.1". The test passes but the 'nullable' rule is ignored.
return [
'phone' => ['nullable', 'phone:INTERNATIONAL,US'],
];
The above code returns always an error when a null
value is sent on the $request->phone
field.
This issue should be OPEN.
tried to put the phone number as an optional field but the nullable rule is still being ignore. Have tried the heroku demo app and its showing the same result
Is there a way for me to make the phone number field optional or this is a bug in the package