@eyuel_engida/ethio-helpers
v1.0.0
Published
A utility to validate Ethiopian phone numbers
Downloads
10
Readme
Ethio-Helpers 🇪🇹
A lightweight, zero-dependency utility library for validating and formatting Ethiopian mobile phone numbers.
Supports both Ethio Telecom and Safaricom.
🚀 Installation
npm install @eyuel_engida/ethio-helpers🛠 Usage
JavaScript
const { isEthioPhone, formatEthioPhone } = require('@eyuel_engida/ethio-helpers');
// --- 1. Validation ---
// Checks if the number is a valid Ethio Telecom (09) or Safaricom (07) number
console.log(isEthioPhone('0911234567')); // true
console.log(isEthioPhone('+251712345678')); // true
console.log(isEthioPhone('0811234567')); // false (Invalid prefix)
console.log(isEthioPhone('0111550000')); // false (Landline)
// --- 2. Formatting ---
// Converts messy inputs into the standard international format: +251 9XX XXX XXX
const formatted = formatEthioPhone('0911223344');
console.log(formatted);
// Output: "+251 911 223 344"
const formattedSafaricom = formatEthioPhone('0712345678');
console.log(formattedSafaricom);
// Output: "+251 712 345 678"✨ Features
- ✅ Validation: Correctly identifies valid
09(Ethio Telecom) and07(Safaricom) prefixes - ✅ Flexible Input: Supports numbers with
+251,251,0, or no prefix - ✅ Formatting: Auto-formats valid numbers into a clean, standardized UI-friendly format
- 🪶 Zero Dependencies: Fast, lightweight, and dependency-free
👨💻 Author
Created by Eyuel
📄 License
ISC
