Phone Number information lookup, validation, carrier name, geo and timezone infos
Verify phone number, validate format, checking carrier name, geo and timezone infos.
This library includes phone number lookup and validation, and the geocoding, carrier mapping and timezone mapping functionalities that are available in some of googles libphonenumber libraries.
To reduce the amount of data that needs to be loaded to geocode / carrier map a phone-number for each mapping only the relevant number prefixes are loaded from a binary json file (BSON).
When the prefix could not be found in the provided locale the library tries to fall back to en
as locale.
The library supports Node.js only at the moment.
Features
✅ Check phone number validity
✅ Check phone number format
✅ Check phone number carrier name
✅ Check phone number geo location (city)
✅ Check phone number timezone
✅ Check phone number country code
Use cases
- Increase delivery rate of SMS campaigns by removing invalid phone numbers
- Increase SMS open rate and your marketing IPs reputation
- Protect your website from spam, bots and fake phone numbers
- Protect your product signup form from fake phone numbers
- Protect your website forms from fake phone numbers
- Protect your self from fraud orders and accounts using fake phone numbers
- Integrate phone number verification into your website forms
- Integrate phone number verification into your backoffice administration and order processing
- Integrate phone number verification into your mobile apps
API / Cloud Hosted Service
We offer this phone verification and validation and more advanced features
in our Scalable Cloud API Service Offering - You could try it here Phone Number Verification
Self-hosting - installation and usage instructions
Installation
npm install @devmehq/phone-number-validator-js
or
yarn add @devmehq/phone-number-validator-js
Usage
The available methods are:
geocoder(phonenumber: PhoneNumber, locale?: GeocoderLocale = 'en'): string | null
- Resolved to the geocode or null if no geocode could be found (e.g. for mobile numbers)carrier(phonenumber: PhoneNumber, locale?: CarrierLocale = 'en'): string | null
- Resolves to the carrier or null if non could be found (e.g. for fixed line numbers)timezones(phonenumber: PhoneNumber): Array<string> | null
- Resolved to an array of timezones or null if non where found.
Examples
import { geocoder, carrier, timezones, parsePhoneNumberFromString } from '@devmehq/phone-number-validator-js'
const fixedLineNumber = parsePhoneNumberFromString('+41431234567')
const locationEN = geocoder(fixedLineNumber)
const locationDE = geocoder(fixedLineNumber, 'de')
const locationIT = geocoder(fixedLineNumber, 'it')
const mobileNumber = parsePhoneNumberFromString('+8619912345678')
const carrierEN = carrier(mobileNumber)
const carrierZH = carrier(mobileNumber, 'zh')
const fixedLineNumber2 = parsePhoneNumberFromString('+49301234567')
const tzones = timezones(fixedLineNumber2)
Testing
yarn test
Contributing
Please feel free to open an issue or create a pull request and fix bugs or add features, All contributions are welcome. Thank you!
LICENSE MIT