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!
}
}
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.