A simple npm package to format Ethiopian phone numbers to the ISP standard code.
npm install --save phone-formater-eth
<script src="https://cdn.jsdelivr.net/npm/phone-formater-eth@1.1.7/dist/index.min.js"></script>
const { formatPhone, checkOperator, isValid, parse} = require('phone-formater-eth');
Or
import { formatPhone, checkOperator, isValid, parse } from 'phone-formater-eth';
console.log(formatPhone('0912345678')); // Outputs: +251912345678 - Int'l format
console.log(formatPhone('+251712345678',"local")); // Outputs: 0712345678 - Local
console.log(formatPhone('251912345678'."local")); // Outputs: 0912345678 - Local
console.log(formatPhone('09123456789')); // Outputs: +2519123456789
console.log(formatPhone('0712345678',"local")); // Outputs: 0712345678 - Local
console.log(formatPhone('25191234567')); // Outputs: +25191234567
console.log(formatPhone('0801234567')); // Outputs: Invalid Phone
console.log(checkOperator('712345678')); // Outputs: Safaricom
console.log(checkOperator('+251912345678')); // Outputs: Ethio Telecom
console.log(checkOperator('0712345678')); // Outputs: Safaricom
console.log(checkOperator('251912345678')); // Outputs: Ethio Telecom
console.log(checkOperator('0812345678')); // Outputs: Unknown
console.log(isValid('712345678')); // Outputs: true
console.log(isValid('+251912345678')); // Outputs: true
console.log(isValid('07812345678')); // Outputs: false
console.log(isValid('251912345678')); // Outputs: true
console.log(isValid('0812345678')); // Outputs: false
console.log(parse("(251) 911-123-456")); //25191112456
console.log(parse("(251) 911-123-456")); //25191112456
console.log(parse("251-911-123-456")); //25191112456
console.log(parse("2519-11-123-456")); //25191112456
PLease submit your contributions as PRs and also leave a good description for the PR
This project is licensed under the MIT License. See the LICENSE file for more information.