Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Phone number format and validation library [closed]

Tags:

phone-number

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?

like image 870
Bill the Lizard Avatar asked Feb 01 '09 18:02

Bill the Lizard


3 Answers

Google recently released libphonenumber for parsing, formatting, storing and validating international phone numbers.

like image 114
Bill the Lizard Avatar answered Oct 23 '22 13:10

Bill the Lizard


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

Data: the ITU's National Numbering Plans index.

like image 36
ayrnieu Avatar answered Oct 23 '22 14:10

ayrnieu


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.

like image 43
Phliplip Avatar answered Oct 23 '22 14:10

Phliplip