1.1.1 • Published 1 year ago
dev-rw-phone v1.1.1
dev-rw-phone
This is a simple npm package that validates the structure and format phone numbers from Rwanda.
Installation
npm install dev-rw-phoneor
yarn add dev-rw-phoneBasic Usage
// Load full build
const { phone } = require("dev-rw-phone");
console.log(phone("0780000000"));
// {
// isOk: true,
// error: null,
// normalized: "250780000000",
// formatted: "(+250) 780 000 000",
// telco: "MTN",
// short: "780000000"
// }
console.log(phone("80000000"));
// {
// isOk: false,
// error: "Phone number NOT valid",
// normalized: "80000000",
// formatted: "(+250) 7XX XXX XXX",
// telco: null,
// short: "7XXXXXXXX"
// }Methods
isOk()
const { isOk } = require("dev-rw-phone");
console.log(isOk("0780000000"));
// trueOr
phone("0780000000").isOk;format()
const { format } = require("dev-rw-phone");
console.log(format("0780000000"));
// "(+250) 780 000 000"Or
phone("0780000000").formatted;normalize()
const { normalize } = require("dev-rw-phone");
console.log(normalize("0780000000"));
// "250780000000"Or
phone("0780000000").normalized;short()
const { short } = require("dev-rw-phone");
console.log(short("0780000000"));
// "780000000"Or
phone("0780000000").short;telco()
const { telco } = require("dev-rw-phone");
console.log(telco("0780000000"));
// "MTN"Or
phone("0780000000").telco;phone()
const { phone } = require("dev-rw-phone");
console.log(phone("0780000000"));
// {
// isOk: true,
// error: null,
// normalized: "250780000000",
// formatted: "(+250) 780 000 000",
// telco: "MTN",
// short: "780000000"
// }Contributors
| Alleluia M |
|---|
Licence
MIT
Author
Alleluia M
