phone

package
v0.0.0-...-02908d0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 5, 2018 License: MIT Imports: 4 Imported by: 2

Documentation

Index

Constants

View Source
const (
	PLUS_SIGN_REGEX       = `(?i)^\+`
	NON_DIGIT_CHAR        = `(?i)\D`
	ZERO_DIGIT_CHARS      = `^0+`
	EIGHT_DIGIT_CHARS     = `^8+`
	RUS_START_DIGIT_CHARS = `^89`
)

Variables

View Source
var (
	NON_LEADING_ZERO_COUNTRIES = []string{"GAB", "CIV", "COG"}

	ErrNotFound  = fmt.Errorf("No valid format found.")
	ErrPhoneMiss = fmt.Errorf("Unable to locate data from phone number.")
)
View Source
var (
	ISO3166_PhoneData []*PhoneData = []*PhoneData{}/* 226 elements not displayed */

)

Functions

func IsValidPhoneISO3166

func IsValidPhoneISO3166(p string, data *PhoneData) bool

Types

type PhoneData

type PhoneData struct {
	CountryData        countries.CountryData
	PhoneCode          string
	MobileBeginsWith   []string
	PhoneNumberLengths []int
}

func GetDefaultISO3166

func GetDefaultISO3166() *PhoneData

func GetISO3166

func GetISO3166(country string) *PhoneData

func GetISO3166ByPhone

func GetISO3166ByPhone(phone string) (*PhoneData, error)

func NewPhoneData

func NewPhoneData() *PhoneData

type PhoneResult

type PhoneResult struct {
	PhoneNumber string
	Country     string
}

func NewPhoneResult

func NewPhoneResult(phone, country string) *PhoneResult

func Normalise

func Normalise(p, c string) (*PhoneResult, error)

type Result

type Result struct {
	PhoneNumber string
	PhoneData   *PhoneData
}

func NewResult

func NewResult(phone string, data *PhoneData) *Result

func (Result) AsPhoneResult

func (r Result) AsPhoneResult() *PhoneResult

func (Result) WithPlusSign

func (r Result) WithPlusSign() *Result

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL