Nigerian Phone Number Validator (JS)
A JS package to validate and format a Nigerian phone number as well as deduce the network provider or area code.
Install using npm: npm install validate_nigerian_phone
Install using yarn: yarn add validate_nigerian_phone
const NigerianPhone = require('validate_nigerian_phone');
const phone = new NigerianPhone('+2348135087966');
// Check if is valid
phone.isValid(); // true
// Get formatted
phone.formatted(); // 08135087966
// Get Network
phone.getNetwork(); // mtn
// Check if is mtn
phone.isMtn(); // True
// Get network from phone number prefix e.g
phone.getNetworkByPrefix('0703'); // mtn
- isValid
- formatted
- getNetwork
- getAreaCode
- isMtn
- isGlo
- isAirtel
- is9mobile
- isSmile
- isMultilinks
- isVisafone
- isNtel
- isStarcomms
- isZoom
- getPrefixesByNetwork
- getNetworkByPrefix
- getAreaCodeByName
Check out the issues on GitHub and/or make a pull request to contribute!