Skip to content
This repository has been archived by the owner on Aug 22, 2024. It is now read-only.

Latest commit

 

History

History
39 lines (29 loc) · 1.45 KB

README.md

File metadata and controls

39 lines (29 loc) · 1.45 KB

extra-terrestrial

Normalize mobile phone numbers into a E.164 format.

(E.T. phone home)

Test cases:

import (
	phone "github.com/dicefm/extra-terrestrial"
)
phone.Normalise("+852 6569-8900", "") // return ['+85265698900', 'HKG']
phone.Normalise("(817) 569-8900", "") // return ['+18175698900, 'USA']
phone.Normalise("(817) 569-8900", "") // return ['+18175698900, 'USA']
phone.Normalise("(817) 569-8900", "USA") // return ['+18175698900', 'USA']
phone.Normalise("(817) 569-8900", "HKG") // return ErrNotFound
phone.Normalise("+1(817) 569-8900", "HKG") // return ErrNotFound, as it is not a valid HKG mobile phone number
phone.Normalise("+1(817) 569-8900", "") // return ['+18175698900', 'USA']
phone.Normalise("(817) 569-8900", "") // return ['+18175698900', 'USA']
phone.Normalise("6123-6123", "") // return [], as default country is USA
phone.Normalise("6123-6123", "HKG") // return ['+85261236123', 'HKG']

Note:

This is a port of Node-Phone specifically this version

Dependencies