zend-i18n icon indicating copy to clipboard operation
zend-i18n copied to clipboard

PhoneNumber requires country code

Open internalsystemerror opened this issue 5 years ago • 6 comments

  • [x] I was not able to find an open or closed issue matching what I'm seeing.
  • [x] This is not a question. (Questions should be asked on chat (Signup here) or our forums.)

~~Use case, UK business website with enquiry form for UK customers. They are not expected to enter the country code for their phone number. An 11 digit number beginning with 0 is not considered valid. e.g. 0161 123 4567 (calling internationally it would be +44 161 123 4567).~~ The issue only occurs with UK mobile numbers in my testing and the above is actually correct.

Code to reproduce the issue

$phoneNumber = new \Zend\I18n\Validator\PhoneNumber();
$phoneNumber->isValid('07875121234');

Expected results

Considered valid.

Actual results

Considered invalid.

Not sure of an easy fix for this, or whether the docs should state that the country code is expected?

internalsystemerror avatar May 24 '19 10:05 internalsystemerror

I believe this is something the Google library takes into account... Looking at an alternative implementation it works as expected: https://giggsey.com/libphonenumber/.

internalsystemerror avatar May 24 '19 10:05 internalsystemerror

@internalsystemerror The current problem: the patterns for phone numbers in zend-i18n are very old. We need a script to update these patterns and have to rework all unit tests which belongs to the PhoneNumber validator.

froschdesign avatar May 24 '19 10:05 froschdesign

Sorry, this issue report is a feature request and not a bug. The bug are the outdated phone number patterns which are covered in separate issue reports.


I like this feature request because it would be a great improvement for this component!

froschdesign avatar May 24 '19 11:05 froschdesign

On further investigation, the original example given above is in fact valid, and it's only UK mobiles which have an issue: e.g. 0787 512 1234.

internalsystemerror avatar May 24 '19 11:05 internalsystemerror

@internalsystemerror No problem. We have to write unit tests anyway.

froschdesign avatar May 24 '19 11:05 froschdesign

This repository has been closed and moved to laminas/laminas-i18n; a new issue has been opened at https://github.com/laminas/laminas-i18n/issues/3.

weierophinney avatar Dec 31 '19 23:12 weierophinney