1.0.9 • Published 3 years ago

@exuus/rwanda-phone-utils v1.0.9

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

@exuus/rwanda-phone-utils

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

NPM

Installation

npm install @exuus/rwanda-phone-utils

or

yarn add @exuus/rwanda-phone-utils

Basic Usage

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

phoneUtils("0780000000")
// {
//     isValid: true,
//     error: null,
//     normalized: "0780000000",
//     formatted: "(+250) 780 000 000",
//     telco: "MTN",
//     short: "780000000",
//     dashed: "+(250)-780-000-000",
//     format: function
// }

phoneUtils("80000000");
// {
//     isValid: false,
//     error: "Phone number is invalid",
//     normalized: null,
//     formatted: null,
//     unformatted: 80000000,
//     telco: null,
//     short: null,
//     dashed: null
//     format: function
// }

Format

Get the formatted phone number according to the option (shape) passed in.

phoneUtils("+250780000000").format() // default
// 780000000

phoneUtils("+250788000000").format("dashed-normalized")
// 0780-000-000

List of all available formats

FormatOutput
short780000000
normalized0780000000
unformatted250780000000
dashed+(250)-795-844-487
dashed-short795-844-487
dashed-normalized0795-844-487
dashed-unformatted250-795-844-487
space+(250) 795 844 487
space-short795 844 487
space-normalized0795 844 487
space-unformatted250 795 844 487

Formatting an invalid number will give your an error message

phoneUtils("+1780000000").format("short")
// Phone number is invalid

Contributors

Elie MugenziHadad

Licence

MIT

Author

Elie Mugenzi

1.0.9

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago