This package has been deprecated

Author message:

Package no longer supported. Use it at your own risk

rwanda-phone-utils
TypeScript icon, indicating that this package has built-in type declarations

1.1.1 • Public • Published

rwanda-phone-utils

This is a simple npm package that validates the structure and format phone numbers from Rwanda.

NPM

Installation

npm install rwanda-phone-utils

or

yarn add rwanda-phone-utils

Basic Usage

// Load full build
import phone from "rwanda-phone-utils";

console.log(phone("0780000000"));
// {
//     isValid: true,
//     error: null,
//     normalized: "250780000000",
//     formatted: "(+250) 780 000 000",
//     telco: "MTN",
//     short: "780000000",
//     dashed: "0780-000-000",
// }

console.log(phone("80000000"));
// {
//     isValid: false,
//     error: "Phone number NOT valid",
//     normalized: "80000000",
//     formatted: "(+250) 7XX XXX XXX",
//     telco: null,
//     short: "7XXXXXXXX",
//     dashed: "07XX-XXX-XXX"
// }

Methods

isValid()

import { isValid } from "rwanda-phone-utils";

console.log(isValid("0780000000"));
// true

Or

phone("0780000000").isValid;

format()

import { format } from "rwanda-phone-utils";

console.log(format("0780000000"));
// "(+250) 780 000 000"

Or

phone("0780000000").formatted;

normalize()

import { normalize } from "rwanda-phone-utils";

console.log(normalize("0780000000"));
// "250780000000"

Or

phone("0780000000").normalized;

short()

import { short } from "rwanda-phone-utils";

console.log(short("0780000000"));
// "780000000"

Or

phone("0780000000").short;

telco()

import { telco } from "rwanda-phone-utils";

console.log(telco("0780000000"));
// "MTN"

Or

phone("0780000000").telco;

telco()

import { dashed } from "rwanda-phone-utils";

console.log(dashed("0780000000"));
// "0780-000-000"

Or

phone("0780000000").dashed;

phone()

import phone from "rwanda-phone-utils";

console.log(phone("0780000000"));
// {
//     isValid: true,
//     error: null,
//     normalized: "250780000000",
//     formatted: "(+250) 780 000 000",
//     telco: "MTN",
//     short: "780000000",
//     dashed: "0780-000-000"
// }

Contributors


Elie Mugenzi

Licence

MIT

Author

Elie Mugenzi

Readme

Keywords

none

Package Sidebar

Install

npm i rwanda-phone-utils

Weekly Downloads

11

Version

1.1.1

License

MIT

Unpacked Size

24.7 kB

Total Files

46

Last publish

Collaborators

  • eliemugenzi