DrHyde / perl-modules-Number-Phone

Number::Phone and friends
24 stars 32 forks source link

Unable to parse valid GB freephone #112

Closed percivalalb closed 1 year ago

percivalalb commented 1 year ago
$ perl -MNumber::Phone -e 'my $p = Number::Phone->new("+44800716598"); print $p // "undef", "\n";'
undef

This is a Barclays freephone number and the number is valid on https://libphonenumber.appspot.com/phonenumberparser?number=%2B44800716598 but Number::Phone is unable to parse it. I have not looked into the reason why, just there is some discrepancy here. Writing it down here so it is saved.

DrHyde commented 1 year ago

Thanks, I'll take a look.

DrHyde commented 1 year ago

The most recent release was built using OFCOM data that says numbers in that range are one digit longer than they actually are: Screenshot 2022-12-24 at 20 41 09

DrHyde commented 1 year ago

I've put in an egregious hack (0d6430db) for now so it will accept both 9 and 10 digit numbers for that range. That will be in the next release. I'll also contact OFCOM and get them to fix their data up-stream.

DrHyde commented 1 year ago

Incidentally, the reason libphonenumber accepts it is that they've applied that evil hack to the whole of the 0800 number range. From resources/PhoneNumberMetadata.xml:

         <nationalNumberPattern>
           80[08]\d{7}|
           800\d{6}|
           8001111
         </nationalNumberPattern>
percivalalb commented 1 year ago

Thanks for investigating and the insights into phonenumberlib