views:

1218

answers:

4

This question asking for a phone number format API in Java got me wondering why such an API doesn't seem to exist. Given the number of validation classes available under Apache Commons, I would have thought such an API would be included.

My question is, does anyone know of a phone number formatting/validation library available in any language that could be used as a model for a small Java open source project? Also, other than the large number of different phone number formats used throughout the world, does anyone know of any reason that such a project would be infeasible?

A: 

Like it was said in the answers to the other question, no one's seen any for Java, and like you said, it would be nearly impossible due to the difference of phone number formats across the world.

And if you know the different formats for the regions that you're targeting, then it's usually pretty easy to implement it in regular expressions.

Ben Alpert
+7  A: 

Such an API in any language: Number::Phone (example submodule: Number::Phone::US).

Data: the ITU's National Numbering Plans index.

ayrnieu
Crap, there are a lot of countries. :)
Bill the Lizard
Thanks for the ITU link, even Qatar's data is current (this is rare).
Osama ALASSIRY
A: 

I think one problem is that there's so many different phone number formats in the world.

Rory
A: 

At http://www.geonames.org/ they have a database you can download, theres regEx rules for phone numbers included in the country info dataset.

http://download.geonames.org/export/dump/

Look for the 'countryInfo.txt' file.

I suggest you build your own validator based upon that.

Phliplip
Wooops... Sorry, the RegEx is for postal-codes. It countains the country phone prefix though ie. +45 for Denmark
Phliplip