Normalize mobile phone numbers into a E.164 format.
(E.T. phone home)
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']
This is a port of Node-Phone specifically this version
-
Development: