Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@devmehq/phone-number-validator-js

Package Overview
Dependencies
Maintainers
1
Versions
207
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@devmehq/phone-number-validator-js

This library includes the geocoding, carrier mapping and timezone mapping functionalities that are available in some of googles libphonenumber libraries

  • 1.2.8
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
898
increased by7.54%
Maintainers
1
Weekly downloads
 
Created
Source

Phone Number information lookup, validation, carrier name, geo and timezone infos

NPM version Build Status Downloads UNPKG

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.

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'): Promise<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'): Promise<string | null> - Resolves to the carrier or null if non could be found (e.g. for fixed line numbers)
  • timezones(phonenumber: PhoneNumber): Promise<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) // Zurich
const locationDE = geocoder(fixedLineNumber, 'de') // Zürich
const locationIT = geocoder(fixedLineNumber, 'it') // Zurigo

const mobileNumber = parsePhoneNumberFromString('+8619912345678')
const carrierEN = carrier(mobileNumber) // China Telecom
const carrierZH = carrier(mobileNumber, 'zh') // 中国电信

const fixedLineNumber2 = parsePhoneNumberFromString('+49301234567')
const tzones = timezones(fixedLineNumber2) // ['Europe/Berlin']

Keywords

FAQs

Package last updated on 04 Dec 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc