Logo Lanfrica

miketsg/ethiopian-phone

Record type:

software
Creator:
mik
Host:
Set of helper utilities to validate, parse and format Ethiopian phone numbers # Ethiopian-phone > Set of helper utilities to validate, parse and format Ethiopian phone numbers. ## Features * Ethiopian phone number validation and formatting. * Find location data of phone numbers. * Check whether number is mobile or landline. * Works in the browser and Node.JS * ``` ## Note If you only need to validate a phone number on an input form before submission, go with simple web best practices. ```html ``` ## Usage ```js const etPhone = require('ethiopian-phone'); let phone = '0911346652'; etPhone.validate(phone) // True etPhone.format(phone) // 09 11 34 66 52 ``` ### Validate Checks whether given input is a valid Ethiopian phone number. ```js etPhone.validate('0911885641') // True etPhone.validate('+251115150126') // True etPhone.validate('09 11 52 39 17') // True etPhone.validate('09135692') // False etPhone.validate('+4604121343') // False ``` ### Parse Cleans up | normalizes phone number. ```js etPhone.parse('09-21-31-43-32') // 0921314332 etPhone.parse('+(251)116625697') // 251116625697 // Raises detailed error when input is invalid etPhone.parse('09135692') // TypeError: Phone number too short etPhone.parse('+460721343') // TypeError: Not Ethiopian phone number ``` ### Format Converts phone number into an easily readable format. ```js etPhone.format('+251116625697') // 251 112 70 56 97 etPhone.format('0112702784') // 011 270 27 84 etPhone.format('0911885641') // 09 11 88 56 41 ``` ### Find Area Retrieves location data of given phone number based on area code. ```js etPhone.findArea('0113215476') // Mekanisa, South West Addis Ababa etPhone.findArea('0112702784') // Asko, Western Addis Ababa etPhone.findArea('0223319750') // Asela, South East Ethiopia etPhone.findArea('0587764412') // Dejen, North West Ethiopia etPhone.findArea('0916771836') // South Ethiopia ``` * Location data is based on * Some of the data might be outdated due to naming changes. * Detailed location is **only available for Landlin …

Languages

Licenses