https://github.com/steinathan/ngn-phone-util
This module is used to validate and test nigerian phone numbers
https://github.com/steinathan/ngn-phone-util
Last synced: 8 months ago
JSON representation
This module is used to validate and test nigerian phone numbers
- Host: GitHub
- URL: https://github.com/steinathan/ngn-phone-util
- Owner: steinathan
- License: mit
- Created: 2019-11-21T20:55:39.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-11-18T22:29:40.000Z (over 5 years ago)
- Last Synced: 2025-04-12T02:39:02.094Z (about 1 year ago)
- Language: TypeScript
- Size: 285 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: code-of-conduct.md
Awesome Lists containing this project
README
# ngn-phone-util
> Nigerian Phone Number Utility
This module is used validate and test for nigerian phone numbers
### Usage
```bash
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:
```javascript
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
```html
let phoneIsValid = ngnPhoneUtil.test('09031844110');
if (phoneIsValid) {
// do something with phone
}
```
Additionally, you can import the transpiled modules from `dist/lib` in case you have a modular library:
```typescript
import validate from 'ngn-phone-util/dist/lib/validate';
validate(phone: string)
```
### NPM scripts
- `npm t`: Run test suite
- `npm start`: Run `npm run build` in watch mode
- `npm run test:watch`: Run test suite in [interactive watch mode](http://facebook.github.io/jest/docs/cli.html#watch)
- `npm run test:prod`: Run linting and generate coverage
- `npm run build`: Generate bundles and typings, create docs
- `npm run lint`: Lints code
- `npm run commit`: Commit using conventional commit style ([husky](https://github.com/typicode/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](https://github.com/kentcdodds/all-contributors) specification. Contributions of any kind are welcome!