-3

Question : I am using Google's LibPhoneNumber package to validate phone numbers in Java. When the country is set to US, 7777777779 and 2234567890 are being classed as invalid numbers, but 7866438057 is valid. Why is this? I've tried reading why they may be invalid, such as on the US phone number wikipedia page, but I see no answer.

Code :

    PhoneNumberUtil phoneUtil = PhoneNumberUtil.getInstance();
    try {
        PhoneNumber parsedNumber = phoneUtil.parse(number, iso3Country);
        //Is it a valid number for the locale?
        if (!phoneUtil.isValidNumber(parsedNumber)) {
            //TODO Throw error!
        }
    }
Andy A
  • 4,191
  • 7
  • 38
  • 56
  • 1
    I don't see how this is relevant to java, this is more to do with the way US phone numbers are produced. – w4etwetewtwet Apr 08 '13 at 12:03
  • Mmm. That is probably true to be fair. Mmm, do you know of a relevant sister site of stackoverflow this question should be on? – Andy A Apr 08 '13 at 12:05
  • Not really, there's probably one out there though. – w4etwetewtwet Apr 08 '13 at 12:05
  • The library is a third party library hosted on Google Code.. you can read their [release notes](https://code.google.com/p/libphonenumber/source/browse/trunk/java/release_notes.txt) and one thing is evident that it is improving... there might be some bugs like the one you faced. – AurA Apr 08 '13 at 12:06

1 Answers1

9

It's probably because 777 and 223 aren't U.S. area codes.

I think this is the official list of area codes in the North American Numbering Plan, which includes the U.S., Canada, and many smaller countries.

Samuel Edwin Ward
  • 6,526
  • 3
  • 34
  • 62