What is the definition of a 'valid' phone number in Python's libphonenumber

2.5k Views Asked by At

I've been using the Python Google Phone Numbers library, and find it to be a good alternative to Twilio.

Does the is.valid_number method check if the number is actually connected to a human, or just that its in a correct/valid format/style? For example, obviously a phone number 123 won't be valid because its format is wrong, but if 408-800-1000 is a base corporate phone number and they've given their current employees numbers like 408-800-1001, 408-800-1002, 408-800-1003... and haven't yet reached past 408-800-1007... would something like 408-800-1008 return valid or not?

1

There are 1 best solutions below

0
On

A static library most certainly won't know anything about company internal extensions. That library is merely a combination of country specific format validators plus a database of known assigned blocks. The information is not validated in realtime against a live system, so is never guaranteed to be accurate (if a number has been assigned or unassigned yesterday, it won't know about it until that built-in database is being updated). Even if a certain block of numbers is known as being assigned, there's no guarantee that any one individual number within that block is currently in use.

The best this library can tell you is that a number looks like a number that could plausibly be in use. Whether it's actually in use and belongs to the user you're interacting with can only be verified by sending a validation code to that number, or some similar validation loop.