DEV Community

David Cantrell
David Cantrell

Posted on

Number::Phone release candidate

I've recently tackled a feature request that's been sitting in the backlog for several years, to use libphonenumber's data to validate numbers with non-geographic country codes. That's codes like +800 (international freephone), +870 (Inmarsat) and so on.

Previous versions would sort of work with these numbers, in that they could be instantiated as objects, but there was no information on validity or any other properties.

For example here it's looking at an Iridium number. First with the previous release:

Number::Phone->new("+881 672520333333333333333732")->format()

+8816 72520333333333333333732

Number::Phone->new("+881 672520732")->is_mobile()

undef (ie, dunno)

and with the release candidate:

Number::Phone->new("+881 672520333333333333333732")

undef (ie, not valid)

Number::Phone->new("+881 672520732")->format()

+881 6 725 20732

Number::Phone->new("+881 672520732")->is_mobile()

1

Much of the code is auto-generated, and this involved quite a bit of hacking around in the build system and object instantiation, so there's the potential for exciting new bugs even for numbers in boring old geographic country codes, although I didn't have to change any of the existing tests so I am hopeful that I avoided that. Here are the changes.

I'd be grateful if you could test this, and assuming that no-one finds any bugs it will be in either the March or June quarterly release. You can download it from here.

Top comments (1)

Collapse
 
drhyde profile image
David Cantrell

Of course the first release candidate was buggy, so there's a second one here.