I want to accept international phone number format for only numbers from UAE, using the Propaganistas / Laravel-Phone package.

I tried using the below code snippet, but it allows any international phone number + local phone number from AE.

'phonefield' => 'phone:INTERNATIONAL,AE', 

So with this, it accepts all countries' phone numbers in international format + it will also accept local phone numbers from UAE. However, I want to only accept international format of UAE numbers, how can I do that?

1 Answer

I did this, is this right by any chance? It seems to work.

$input_phone = $data['username']; $phone = new PhoneNumber($input_phone); if (!$phone->isValid() || !$phone->isOfCountry('AE')) return response()->error(null, __('validation.phone', ['attribute' => 'phone']), Response::HTTP_BAD_REQUEST); $data['username'] = $phone->formatE164(); 
1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.