ngn-phone-util
v0.0.1
Published
> Nigerian Phone Number Utility
Downloads
4
Readme
ngn-phone-util
Nigerian Phone Number Utility
This module is used validate and test for nigerian phone numbers
Usage
npm install ngn-phone-util
Features
- Auto detect phone number provider and..
- Auto test and validate phone number
Importing library from nodejs
You can import the generated bundle to use the whole library generated by script:
import { test, detect } from 'ngn-phone-util';
let phone = '09031844110';
test(phone); // => true | throws "Error"
// Detect a phone number
let ph = '09031844110';
detect(ph); // => "MTN"
Importing library for the browser
<script src="https://cdn.jsdelivr.net/navicstein/ngn-phone-util/dist/ngn-phone-util.umd.js"></script>
<script>
let phoneIsValid = ngnPhoneUtil.test('09031844110');
if (phoneIsValid) {
// do something with phone
}
</script>
Additionally, you can import the transpiled modules from dist/lib
in case you have a modular library:
import validate from 'ngn-phone-util/dist/lib/validate';
validate(phone: string)
NPM scripts
npm t
: Run test suitenpm start
: Runnpm run build
in watch modenpm run test:watch
: Run test suite in interactive watch modenpm run test:prod
: Run linting and generate coveragenpm run build
: Generate bundles and typings, create docsnpm run lint
: Lints codenpm run commit
: Commit using conventional commit style (husky will tell you to use it if you haven't :wink:)
Todo
- Add a
.format()
function to auto add+234
to numbers as a serialized argin. - Add a
generator
function to randomly generate specific provider numbers.
This project follows the all-contributors specification. Contributions of any kind are welcome!