Search results
I'm simlpy trying to use this package like I've used every other JavaScript library like jQuery, via a script tag in an HTML file. I've compiled libphonenumber using Google's compose tool, via the instructions here. So with this single file, I'm trying to use it as below.
Google's libphonenumber is a library that parses, formats, stores and validates international phone numbers. It is used by Android since version 4.0 and is a phenomenal repository of carrier metadata. Although it compiles down to Java, C++ and JS, its JS port is tightly coupled to the Google Closure library.
- What is it?
- Quick links
- Highlights of functionality
- Java
- JavaScript
- Java code
- Javadoc
- Versioning and Announcements
- Quick Examples
- Mapping Phone Numbers to original carriers
Google's common Java, C++ and JavaScript library for parsing, formatting, and validating international phone numbers. The Java version is optimized for running on smartphones, and is used by the Android framework since 4.0 (Ice Cream Sandwich).
•Reporting an issue? Want to send a pull request? See the contribution guidelines
•Check the frequently asked questions
•Fun! Falsehoods Programmers Believe About Phone Numbers
•Look for READMEs in directories relevant to the code you're interested in.
•For contributors and porters: How to run the Java demo
•For porters: How to make metadata changes
•Parsing, formatting, and validating phone numbers for all countries/regions of the world.
•getNumberType - gets the type of the number based on the number itself; able to distinguish Fixed-line, Mobile, Toll-free, Premium Rate, Shared Cost, VoIP, Personal Numbers, UAN, Pager, and Voicemail (whenever feasible).
•isNumberMatch - gets a confidence level on whether two numbers could be the same.
•getExampleNumber and getExampleNumberForType - provide valid example numbers for all countries/regions, with the option of specifying which type of example phone number is needed.
•isPossibleNumber - quickly guesses whether a number is a possible phone number by using only the length information, much faster than a full validation.
•isValidNumber - full validation of a phone number for a region using length and prefix information.
The Java demo is updated with a slight delay after the GitHub release.
Last demo update: v8.13.30.
Note: Even though the library (main branch/maven release) is at v8.12.57, because of some deployment issues, we were unable to update the Java demo with the new binary version. We will soon fix this. Meantime, please use JS demo.
If this number is lower than the latest release's version number, we are between releases and the demo may be at either version.
The JavaScript demo may be run at various tags; this link will take you to master.
To include the Java code in your application, either integrate with Maven (see wiki) or download the latest jars from the Maven repository.
Javadoc is automatically updated to reflect the latest release at https://javadoc.io/doc/com.googlecode.libphonenumber/libphonenumber/.
We generally choose the release number following these guidelines.
If any of the changes pushed to master since the last release are incompatible with the intent / specification of an existing libphonenumber API or may cause libphonenumber (Java, C++, or JS) clients to have to change their code to keep building, we publish a major release. For example, if the last release were 7.7.3, the new one would be 8.0.0.
If any of those changes enable clients to update their code to take advantage of new functionality, and if clients would have to roll-back these changes in the event that the release was marked as "bad", we publish a minor release. For example, we'd go from 7.7.3 to 7.8.0.
Otherwise, including when a release contains only metadata changes, we publish a sub-minor release, e.g. 7.7.3 to 7.7.4.
Sometimes we make internal changes to the code or metadata that, while not affecting compatibility for clients, could affect compatibility for porters of the library. For such changes we make announcements to libphonenumber-discuss. Such changes are not reflected in the version number, and we would publish a sub-minor release if there were no other changes.
Want to get notified of new releases? During most of the year, excepting holidays and extenuating circumstances, we release fortnightly. We update release tags and document detailed release notes. We also send an announcement to libphonenumber-discuss for every release.
Let's say you have a string representing a phone number from Switzerland. This is how you parse/normalize it into a PhoneNumber object:
At this point, swissNumberProto contains:
PhoneNumber is a class that was originally auto-generated from phonenumber.proto with necessary modifications for efficiency. For details on the meaning of each field, refer to resources/phonenumber.proto.
Now let us validate whether the number is valid:
There are a few formats supported by the formatting method, as illustrated below:
You could also choose to format the number in the way it is dialed from another country:
Caveat: We do not provide data about the current carrier of a phone number, only the original carrier who is assigned the corresponding range. Read about number portability.
More examples on how to use the library can be found in the unit tests.
A simpler (and smaller) rewrite of Google Android's libphonenumber library in javascript. Latest version: 1.11.8, last published: a day ago. Start using libphonenumber-js in your project by running `npm i libphonenumber-js`.
Feb 1, 2023 · Libphonenumber is Google’s library for parsing, formatting, and validating international phone numbers in Java, C++, and JavaScript. That sounds interesting. So, I can use this library to validate the phone numbers of any country.
Google's JavaScript library for parsing, formatting, and validating international phone numbers. How to setup: Checkout closure-library, closure-compiler, closure-linter and python-gflags next to libphonenumber:
People also ask
What is libphonenumber in JavaScript?
Is there a JavaScript implementation of Google libphonenumber?
How do I use Google libphonenumber?
How does libphonenumber work?
Is Google libphonenumber available on npm?
Is libphonenumber a bug?
Libphonenumbers is JavaScript port of Google's libphonenumber library for parsing, formatting, and validating international phone numbers in Node.js.