npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

phone-number-network-provider

v1.0.1

Published

A lightweight utility to verify Nigerian phone number network providers by prefix. Supports both CommonJS (require) and ESM (import).

Readme

Nigerian Phone Number Network Provider Validator

A Node.js package to validate phone numbers and verify network provider for Nigerian phone numbers. It supports both sync and async validation, ensuring that phone numbers are valid and belong to a recognized network provider.

Features

  • Sync and Async Validation: Easily validate phone numbers synchronously or asynchronously.
  • Automatic Removal of Country Code: Handles both regular and international formats of Nigerian phone numbers.
  • Supports both CommonJS and ES Modules: Works in both traditional Node.js (require) and modern JavaScript (import).

Installation

You can install the package via npm:

npm i phone-number-network-provider
yarn add phone-number-network-provider

Usage

You can use the package in both JavaScript and TypeScript applications.

1. Importing the Module

CommonJS (Node.js)

const { verifyNetworkProviderSync, verifyNetworkProviderAsync } = require('verify-phone-network-provider');

// Synchronous validation
const resultSync = verifyNetworkProviderSync('08031234567');
console.log(resultSync);

// Asynchronous validation
verifyNetworkProviderAsync('08031234567')
  .then(result => console.log(result))
  .catch(error => console.log(error));

ES Modules (ESM)

import { verifyNetworkProviderSync, verifyNetworkProviderAsync } from 'verify-phone-network-provider';

// Synchronous validation
const resultSync = verifyNetworkProviderSync('08031234567');
console.log(resultSync);

// Asynchronous validation
verifyNetworkProviderAsync('08031234567')
  .then(result => console.log(result))
  .catch(error => console.log(error));

2. Validating Phone Numbers

  • Synchronous Validation:
    This method checks if the phone number is valid, and whether it matches a known network provider (based on prefixes).

    const result = verifyNetworkProviderSync('08031234567');
    console.log(result);

    Returns:
    If the phone number is valid, it returns an object with the network provider's name and isValid: true.
    Otherwise, it returns an object with an array of error messages and isValid: false.

    Example Result:

    {
      telco: 'AIRTEL',
      isValid: true
    }

    Or an error result:

    {
      errors: ["Phone number doesn't match a valid service provider", "Phone number should be 11 characters long"],
      isValid: false
    }
  • Asynchronous Validation:
    This method works similarly to the synchronous method, but returns a Promise for asynchronous handling.

    verifyNetworkProviderAsync('08031234567')
      .then(result => console.log(result))
      .catch(error => console.log(error));

    Returns:
    If the phone number is valid, it resolves with the validation result object. If invalid, it rejects with the error result.

3. Remove Country Code

The phone numbers in Nigeria often come with a country code +234 or 234. This package automatically removes it and transforms the number into a standard format (starting with 0).

For example:

  • +234803123456708031234567
  • 234803123456708031234567

4. Supported Providers

This package supports validation for several Nigerian network providers. It checks the phone number's prefix against a predefined list, including:

  • AIRTEL
  • MTN
  • GLO
  • 9MOBILE
  • SMILE
  • STARCOMMS
  • ZOOMMOBILE
  • MULTI-LINKS
  • NTEL

TypeScript Support

This package comes with TypeScript declaration files, so if you're using TypeScript, you can get full type safety and autocompletion.

import { verifyNetworkProviderSync, verifyNetworkProviderAsync } from 'verify-phone-network-provider';

const result = verifyNetworkProviderSync('08031234567');
console.log(result);

Project Structure

/src
  index.ts        # Main logic for validating phone numbers
  telcos.ts       # List of network providers and their prefixes
/dist
  index.js        # Compiled JavaScript file for distribution
  index.d.ts      # TypeScript declaration file
tsconfig.json     # TypeScript configuration file
package.json      # Project metadata and dependencies
README.md         # Documentation for the package

Contributing

Contributions are welcome! If you'd like to contribute, please fork the repository, make your changes, and submit a pull request. Before submitting, ensure that your code adheres to the following guidelines:

  • Write unit tests for any new functionality.
  • Follow the code style and formatting conventions used in the project.
  • Make sure all tests pass.

License

MIT License. See the LICENSE file for more details.