Skip to content

Eul45/ethio-helpers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Ethio-Helpers πŸ‡ͺπŸ‡Ή

A lightweight, zero-dependency utility library for validating and formatting Ethiopian mobile phone numbers.
Supports both Ethio Telecom and Safaricom.


Ethio Helpers Demo
See it in action: Auto-validation & Formatting


πŸš€ 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) and 07 (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

About

A lightweight JavaScript utility to validate and format Ethiopian mobile phone numbers (Ethio Telecom & Safaricom).

Topics

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors