Releases: HuluWZ/phone-formatter-eth
Releases · HuluWZ/phone-formatter-eth
v1.1.8 ```parse`` cleans up and normalize phone numbers
v1.1.8 parse cleans up and normalize phone numbers
Usage
const { parse} = require('phone-formater-eth');
Or
import { parse } from 'phone-formater-eth';
- parse - Parse phone number to remove special characters like '-' and '(' ')'
Parameters - phone (string): The phone number to cleaned.
Returns - (string): The cleaned phone number if the phone is valid else "INVALID_PHONE_NUMBER"
Examples
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
v1.1.7 formatPhone with local & int'l option
const { formatPhone, checkOperator, isValid } = require('phone-formater-eth');
- Included another parametet for formatPhone method with type ("local" | "international") by default it's "international"
console.log(formatPhone('0912345678')); // Outputs: +251912345678 - international format console.log(formatPhone('+251712345678',"local")); // Outputs: 0712345678
- isValid - Checks if phone number is valid or not
console.log(isValid('251912345678')); // Outputs: true console.log(isValid('0812345678')); // Outputs: fals
v1.1.4: feat: implemented ``isValid``` check for if it's valid phone number o…
Updates
- implemented
isValid
method - to Returns boolean if it’s Valid phone number or not