phonenumbers

package module
v2.0.5 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2026 License: MIT Imports: 21 Imported by: 0

README

☎️ phonenumbers

Build Status Go Reference

Go port of Google's libphonenumber. Specifically it tracks the Java implementation — that library's reference implementation, of which the C++ and JavaScript versions are themselves ports. This library is used daily in production for parsing and validation of numbers worldwide and is well maintained.

[!IMPORTANT] This project is a strict port of libphonenumber. Please do not submit feature requests for functionality that doesn't exist there. It also uses the metadata from libphonenumber, so if you encounter unexpected parsing results, please first verify if the problem affects libphonenumber and report there if so. You can use the online demo to quickly check parsing results.

[!TIP] See UPGRADING.md for details on upgrading from 1.x to 2.x.

Installation

% go get github.com/nyaruka/phonenumbers/v2

Usage

import "github.com/nyaruka/phonenumbers/v2"

// parse our phone number
num, err := phonenumbers.Parse("8886418722", "US")

// check if it's a valid number for its region
valid := phonenumbers.IsValidNumber(num)

// format it using national format
formatted := phonenumbers.Format(num, phonenumbers.NATIONAL)

Updating

Metadata

The buildmetadata command regenerates the embedded metadata from an upstream release. It clones the release and rebuilds the gzipped data blobs embedded across the packages (core territory metadata, short numbers, alternate formats, country-code→region, carrier, geocoding, and timezone), recording the release it built from in the generated metadata/version.go.

# resolve and build from the latest upstream release
% go run ./cmd/buildmetadata

# or pin a specific release tag
% go run ./cmd/buildmetadata v9.0.31

This part is mechanical and fully automated.

Code

Regenerating the metadata is only half of a sync — the ported Go code also has to be reconciled against the new release's Java logic changes, which is judgment work rather than a mechanical rebuild.

If you use Claude Code, the sync-upstream skill (.claude/skills/sync-upstream/SKILL.md) walks through the whole process — metadata regen plus the per-file code reconciliation. Invoke it with /sync-upstream or by asking it to sync with upstream. SYNC.md records the upstream version the code is reconciled against and the deliberate divergences from upstream.

Documentation

Overview

Port of java/libphonenumber/src/com/google/i18n/phonenumbers/metadata/source/* alternate-formats loading.

Port of java/libphonenumber/src/com/google/i18n/phonenumbers/AsYouTypeFormatter.java.

Package phonenumbers is a Go port of Google's libphonenumber for parsing, formatting, and validating international phone numbers.

It tracks the Java implementation — libphonenumber's reference implementation, of which the C++ and JavaScript versions are themselves ports. As a result, type names, method names, and tests deliberately mirror their Java counterparts (for example PhoneNumberUtil and PhoneNumberUtilTest) to keep the port easy to verify against upstream. The aim is strictly to match libphonenumber's functionality rather than to add to it.

See SYNC.md for which upstream version each ported file is reconciled against.

Port of java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java (enums).

Port of java/libphonenumber/src/com/google/i18n/phonenumbers/NumberParseException.java (+ package errors).

Port of java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberMatch.java.

Port of java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberMatcher.java.

Port of java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java.

Port of java/libphonenumber/src/com/google/i18n/phonenumbers/ShortNumberInfo.java.

Index

Constants

View Source
const (
	Default_PhoneNumber_NumberOfLeadingZeros = int32(1)
)

Default values for PhoneNumber fields.

Variables

View Source
var (
	PhoneNumber_CountryCodeSource_name = map[int32]string{
		0:  "UNSPECIFIED",
		1:  "FROM_NUMBER_WITH_PLUS_SIGN",
		5:  "FROM_NUMBER_WITH_IDD",
		10: "FROM_NUMBER_WITHOUT_PLUS_SIGN",
		20: "FROM_DEFAULT_COUNTRY",
	}
	PhoneNumber_CountryCodeSource_value = map[string]int32{
		"UNSPECIFIED":                   0,
		"FROM_NUMBER_WITH_PLUS_SIGN":    1,
		"FROM_NUMBER_WITH_IDD":          5,
		"FROM_NUMBER_WITHOUT_PLUS_SIGN": 10,
		"FROM_DEFAULT_COUNTRY":          20,
	}
)

Enum value maps for PhoneNumber_CountryCodeSource.

View Source
var (
	ErrInvalidCountryCode = errors.New("invalid country code")
	ErrNotANumber         = errors.New("the phone number supplied is not a number")
	ErrTooShortNSN        = errors.New("the string supplied is too short to be a phone number")
)
View Source
var ErrEmptyMetadata = metadata.ErrEmptyMetadata

ErrEmptyMetadata is an alias for metadata.ErrEmptyMetadata, kept here for backwards compatibility.

View Source
var ErrNumTooLong = errors.New("the string supplied is too long to be a phone number")
View Source
var ErrTooShortAfterIDD = errors.New("phone number had an IDD, but " +
	"after this was not long enough to be a viable phone number")
View Source
var File_phonenumber_proto protoreflect.FileDescriptor
View Source
var (
	REGION_CODE_FOR_NON_GEO_ENTITY = "001"
)

Functions

func CanBeInternationallyDialled

func CanBeInternationallyDialled(number *PhoneNumber) bool

Returns true if the number can be dialled from outside the region, or unknown. If the number can only be dialled from within the region, returns false. Does not check the number is a valid number. Note that, at the moment, this method does not handle short numbers (which are currently all presumed to not be diallable from outside their country).

func ConnectsToEmergencyNumber

func ConnectsToEmergencyNumber(number string, regionCode string) bool

Returns true if the given number, exactly as dialed, might be used to connect to an emergency service in the given region.

This method accepts a string, rather than a PhoneNumber, because it needs to distinguish cases such as "+1 911" and "911", where the former may not connect to an emergency service in all cases but the latter would. This method takes into account cases where the number might contain formatting, or might have additional digits appended (when it is okay to do that in the specified region).

number: the phone number to test regionCode: the region where the phone number is being dialed return: whether the number might be used to connect to an emergency service in the given region

func ConvertAlphaCharactersInNumber

func ConvertAlphaCharactersInNumber(number string) string

Converts all alpha characters in a number to their respective digits on a keypad, but retains existing formatting.

func FindNumbers

func FindNumbers(text, defaultRegion string) iter.Seq[*PhoneNumberMatch]

FindNumbers returns an iterator over all phone-number matches in text. It is a shortcut for FindNumbersWithLeniency with VALID leniency and no limit on the number of invalid candidates tried. defaultRegion is the region to assume for numbers not written in international format; pass "" or "ZZ" to only consider numbers with a leading plus.

Range over the result with for/range:

for m := range phonenumbers.FindNumbers(text, "US") {
	fmt.Println(m.RawString(), m.Start(), m.End())
}

func FindNumbersWithLeniency

func FindNumbersWithLeniency(text, defaultRegion string, leniency Leniency, maxTries int) iter.Seq[*PhoneNumberMatch]

FindNumbersWithLeniency returns an iterator over all phone-number matches in text at the given leniency. maxTries caps the number of invalid candidates tried before giving up, to bound degenerate inputs with many false positives (use math.MaxInt for no practical limit). Must be >= 0.

func Format

func Format(number *PhoneNumber, numberFormat PhoneNumberFormat) string

Formats a phone number in the specified format using default rules. Note that this does not promise to produce a phone number that the user can dial from where they are - although we do format in either 'national' or 'international' format depending on what the client asks for, we do not currently support a more abbreviated format, such as for users in the same "area" who could potentially dial the number without area code. Note that if the phone number has a country calling code of 0 or an otherwise invalid country calling code, we cannot work out which formatting rules to apply so we return the national significant number with no formatting applied.

func FormatByPattern

func FormatByPattern(number *PhoneNumber,
	numberFormat PhoneNumberFormat,
	userDefinedFormats []*NumberFormat) string

FormatByPattern formats a phone number in the specified format using client-defined formatting rules. Note that if the phone number has a country calling code of zero or an otherwise invalid country calling code, we cannot work out things like whether there should be a national prefix applied, or how to format extensions, so we return the national significant number with no formatting applied.

func FormatInOriginalFormat

func FormatInOriginalFormat(number *PhoneNumber, regionCallingFrom string) string

Formats a phone number using the original phone number format that the number is parsed from. The original format is embedded in the country_code_source field of the PhoneNumber object passed in. If such information is missing, the number will be formatted into the NATIONAL format by default. When the number contains a leading zero and this is unexpected for this country, or we don't have a formatting pattern for the number, the method returns the raw input when it is available.

Note this method guarantees no digit will be inserted, removed or modified as a result of formatting.

func FormatNationalNumberWithCarrierCode

func FormatNationalNumberWithCarrierCode(number *PhoneNumber, carrierCode string) string

Formats a phone number in national format for dialing using the carrier as specified in the carrierCode. The carrierCode will always be used regardless of whether the phone number already has a preferred domestic carrier code stored. If carrierCode contains an empty string, returns the number in national format without any carrier code.

func FormatNationalNumberWithPreferredCarrierCode

func FormatNationalNumberWithPreferredCarrierCode(
	number *PhoneNumber,
	fallbackCarrierCode string) string

Formats a phone number in national format for dialing using the carrier as specified in the preferredDomesticCarrierCode field of the PhoneNumber object passed in. If that is missing, use the fallbackCarrierCode passed in instead. If there is no preferredDomesticCarrierCode, and the fallbackCarrierCode contains an empty string, return the number in national format without any carrier code.

Use formatNationalNumberWithCarrierCode instead if the carrier code passed in should take precedence over the number's preferredDomesticCarrierCode when formatting.

func FormatNumberForMobileDialing

func FormatNumberForMobileDialing(
	number *PhoneNumber,
	regionCallingFrom string,
	withFormatting bool) string

Returns a number formatted in such a way that it can be dialed from a mobile phone in a specific region. If the number cannot be reached from the region (e.g. some countries block toll-free numbers from being called outside of the country), the method returns an empty string.

func FormatOutOfCountryCallingNumber

func FormatOutOfCountryCallingNumber(
	number *PhoneNumber,
	regionCallingFrom string) string

Formats a phone number for out-of-country dialing purposes. If no regionCallingFrom is supplied, we format the number in its INTERNATIONAL format. If the country calling code is the same as that of the region where the number is from, then NATIONAL formatting will be applied.

If the number itself has a country calling code of zero or an otherwise invalid country calling code, then we return the number with no formatting applied.

Note this function takes care of the case for calling inside of NANPA and between Russia and Kazakhstan (who share the same country calling code). In those cases, no international prefix is used. For regions which have multiple international prefixes, the number in its INTERNATIONAL format will be returned instead.

func FormatOutOfCountryKeepingAlphaChars

func FormatOutOfCountryKeepingAlphaChars(
	number *PhoneNumber,
	regionCallingFrom string) string

Formats a phone number for out-of-country dialing purposes.

Note that in this version, if the number was entered originally using alpha characters and this version of the number is stored in raw_input, this representation of the number will be used rather than the digit representation. Grouping information, as specified by characters such as "-" and " ", will be retained.

Caveats:

  • This will not produce good results if the country calling code is both present in the raw input _and_ is the start of the national number. This is not a problem in the regions which typically use alpha numbers.
  • This will also not produce good results if the raw input has any grouping information within the first three digits of the national number, and if the function needs to strip preceding digits/words in the raw input before these digits. Normally people group the first three digits together so this is not a huge problem - and will be fixed if it proves to be so.

func GetCountryCodeForRegion

func GetCountryCodeForRegion(regionCode string) int

Returns the country calling code for a specific region. For example, this would be 1 for the United States, and 64 for New Zealand.

func GetCountryMobileToken

func GetCountryMobileToken(countryCallingCode int) string

Returns the mobile token for the provided country calling code if it has one, otherwise returns an empty string. A mobile token is a number inserted before the area code when dialing a mobile number from that country from abroad.

func GetLengthOfGeographicalAreaCode

func GetLengthOfGeographicalAreaCode(number *PhoneNumber) int

Gets the length of the geographical area code from the PhoneNumber object passed in, so that clients could use it to split a national significant number into geographical area code and subscriber number. It works in such a way that the resultant subscriber number should be diallable, at least on some devices. An example of how this could be used:

number, err := Parse("16502530000", "US")
// ... deal with err appropriately ...
nationalSignificantNumber := GetNationalSignificantNumber(number)
var areaCode, subscriberNumber string

areaCodeLength := GetLengthOfGeographicalAreaCode(number)
if areaCodeLength > 0 {
	areaCode = nationalSignificantNumber[0:areaCodeLength]
	subscriberNumber = nationalSignificantNumber[areaCodeLength:]
} else {
	areaCode = ""
	subscriberNumber = nationalSignificantNumber
}

N.B.: area code is a very ambiguous concept, so the I18N team generally recommends against using it for most purposes, but recommends using the more general national_number instead. Read the following carefully before deciding to use this method:

  • geographical area codes change over time, and this method honors those changes; therefore, it doesn't guarantee the stability of the result it produces.
  • subscriber numbers may not be diallable from all devices (notably mobile devices, which typically requires the full national_number to be dialled in most regions).
  • most non-geographical numbers have no area codes, including numbers from non-geographical entities
  • some geographical numbers have no area codes.

func GetLengthOfNationalDestinationCode

func GetLengthOfNationalDestinationCode(number *PhoneNumber) int

Gets the length of the national destination code (NDC) from the PhoneNumber object passed in, so that clients could use it to split a national significant number into NDC and subscriber number. The NDC of a phone number is normally the first group of digit(s) right after the country calling code when the number is formatted in the international format, if there is a subscriber number part that follows. An example of how this could be used:

number, err := Parse("18002530000", "US")
// ... deal with err appropriately ...
nationalSignificantNumber := GetNationalSignificantNumber(number)
var nationalDestinationCode, subscriberNumber string

nationalDestinationCodeLength := GetLengthOfNationalDestinationCode(number)
if nationalDestinationCodeLength > 0 {
	nationalDestinationCode = nationalSignificantNumber[0:nationalDestinationCodeLength]
	subscriberNumber = nationalSignificantNumber[nationalDestinationCodeLength:]
} else {
	nationalDestinationCode = ""
	subscriberNumber = nationalSignificantNumber
}

Refer to the unittests to see the difference between this function and GetLengthOfGeographicalAreaCode().

func GetNationalSignificantNumber

func GetNationalSignificantNumber(number *PhoneNumber) string

Gets the national significant number of the a phone number. Note a national significant number doesn't contain a national prefix or any formatting.

func GetNddPrefixForRegion

func GetNddPrefixForRegion(regionCode string, stripNonDigits bool) string

Returns the national dialling prefix for a specific region. For example, this would be 1 for the United States, and 0 for New Zealand. Set stripNonDigits to true to strip symbols like "~" (which indicates a wait for a dialling tone) from the prefix returned. If no national prefix is present, we return null.

Warning: Do not use this method for do-your-own formatting - for some regions, the national dialling prefix is used only for certain types of numbers. Use the library's formatting functions to prefix the national prefix when required.

func GetRegionCodeForCountryCode

func GetRegionCodeForCountryCode(countryCallingCode int) string

Returns the region code that matches the specific country calling code. In the case of no region code being found, ZZ will be returned. In the case of multiple regions, the one designated in the metadata as the "main" region for this calling code will be returned. If the countryCallingCode entered is valid but doesn't match a specific region (such as in the case of non-geographical calling codes like 800) the value "001" will be returned (corresponding to the value for World in the UN M.49 schema).

func GetRegionCodeForNumber

func GetRegionCodeForNumber(number *PhoneNumber) string

Returns the region where a phone number is from. This could be used for geocoding at the region level.

func GetRegionCodesForCountryCode

func GetRegionCodesForCountryCode(countryCallingCode int) []string

Returns a list with the region codes that match the specific country calling code. For non-geographical country calling codes, the region code 001 is returned. Also, in the case of no region code being found, an empty list is returned.

func GetSupportedCallingCodes

func GetSupportedCallingCodes() map[int]bool

GetSupportedCallingCodes returns all country calling codes the library has metadata for, covering both non-geographical entities (global network calling codes) and those used for geographical entities. This could be used to populate a drop-down box of country calling codes for a phone-number widget, for instance.

func GetSupportedGlobalNetworkCallingCodes

func GetSupportedGlobalNetworkCallingCodes() map[int]bool

GetSupportedGlobalNetworkCallingCodes returns all global network calling codes the library has metadata for.

func GetSupportedRegions

func GetSupportedRegions() map[string]bool

GetSupportedRegions returns all regions the library has metadata for.

func GetSupportedTypesForNonGeoEntity

func GetSupportedTypesForNonGeoEntity(countryCallingCode int) map[PhoneNumberType]bool

GetSupportedTypesForNonGeoEntity returns the types for a country-code belonging to a non-geographical entity which the library has metadata for. Will not include FIXED_LINE_OR_MOBILE or UNKNOWN. No types are returned for country calling codes that do not map to a known non-geographical entity.

func GetSupportedTypesForRegion

func GetSupportedTypesForRegion(regionCode string) map[PhoneNumberType]bool

GetSupportedTypesForRegion returns the types for a given region which the library has metadata for. Will not include FIXED_LINE_OR_MOBILE or UNKNOWN. No types are returned for invalid or unknown region codes.

func IsAlphaNumber

func IsAlphaNumber(number string) bool

Checks if the number is a valid vanity (alpha) number such as 800 MICROSOFT. A valid vanity number will start with at least 3 digits and will have three or more alpha characters. This does not do region-specific checks - to work out if this number is actually valid for a region, it should be parsed and methods such as IsPossibleNumberWithReason() and IsValidNumber() should be used.

func IsCarrierSpecific

func IsCarrierSpecific(number *PhoneNumber) bool

IsCarrierSpecific given a valid short number, determines whether it is carrier-specific (however, nothing is implied about its validity). Carrier-specific numbers may connect to a different end-point, or not connect at all, depending on the user's carrier. If it is important that the number is valid, then its validity must first be checked using IsValidShortNumber or IsValidShortNumberForRegion.

func IsCarrierSpecificForRegion

func IsCarrierSpecificForRegion(number *PhoneNumber, regionDialingFrom string) bool

IsCarrierSpecificForRegion given a valid short number, determines whether it is carrier-specific when dialed from the given region (however, nothing is implied about its validity). Returns false if the number doesn't match the region provided.

func IsEmergencyNumber

func IsEmergencyNumber(number string, regionCode string) bool

Returns true if the given number exactly matches an emergency service number in the given region.

This method takes into account cases where the number might contain formatting, but doesn't allow additional digits to be appended. Note that isEmergencyNumber(number, region) implies connectsToEmergencyNumber(number, region).

number: the phone number to test regionCode: the region where the phone number is being dialed return: whether the number exactly matches an emergency services number in the given region

func IsMobileNumberPortableRegion

func IsMobileNumberPortableRegion(regionCode string) bool

Returns true if the supplied region supports mobile number portability. Returns false for invalid, unknown or regions that don't support mobile number portability.

func IsNANPACountry

func IsNANPACountry(regionCode string) bool

Checks if this is a region under the North American Numbering Plan Administration (NANPA).

func IsNumberGeographical

func IsNumberGeographical(phoneNumber *PhoneNumber) bool

Tests whether a phone number has a geographical association. It checks if the number is associated to a certain region in the country where it belongs to. Note that this doesn't verify if the number is actually in use.

A similar method is implemented as PhoneNumberOfflineGeocoder.canBeGeocoded, which performs a looser check, since it only prevents cases where prefixes overlap for geocodable and non-geocodable numbers. Also, if new phone number types were added, we should check if this other method should be updated too.

func IsNumberGeographicalForType

func IsNumberGeographicalForType(phoneNumberType PhoneNumberType, countryCallingCode int) bool

Overload of IsNumberGeographical(PhoneNumber), since calculating the phone number type is expensive; if we have already done this, we don't want to do it again.

func IsPossibleNumber

func IsPossibleNumber(number *PhoneNumber) bool

Convenience wrapper around IsPossibleNumberWithReason(). Instead of returning the reason for failure, this method returns a boolean value.

func IsPossibleNumberForType

func IsPossibleNumberForType(number *PhoneNumber, numberType PhoneNumberType) bool

IsPossibleNumberForType returns true if the number is a possible number of the given type (a more lenient check than IsValidNumberForRegion).

func IsPossibleNumberFromRegion

func IsPossibleNumberFromRegion(number string, regionDialingFrom string) bool

IsPossibleNumberFromRegion checks whether a phone number is a possible number given a number in the form of a string, and the region where the number could be dialled from. It provides a more lenient check than IsValidNumber. See IsPossibleNumber for details.

This method first parses the number, then invokes IsPossibleNumber with the resultant PhoneNumber object.

regionDialingFrom is the region we expect the number to be dialled from. Note this is different from the region where the number belongs. For example, the number +1 650 253 0000 belongs to the US. When written in this form, it can be dialled from any region. When written as 650 253 0000, it can only be dialled from within the US.

func IsPossibleShortNumber

func IsPossibleShortNumber(number *PhoneNumber) bool

Check whether a short number is a possible number. If a country calling code is shared by multiple regions, this returns true if it's possible in any of them. This provides a more lenient check than #isValidShortNumber. See IsPossibleShortNumberForRegion(PhoneNumber, string) for details.

func IsPossibleShortNumberForRegion

func IsPossibleShortNumberForRegion(number *PhoneNumber, regionDialingFrom string) bool

Check whether a short number is a possible number when dialed from the given region. This provides a more lenient check than IsValidShortNumberForRegion.

func IsSmsServiceForRegion

func IsSmsServiceForRegion(number *PhoneNumber, regionDialingFrom string) bool

IsSmsServiceForRegion given a valid short number, determines whether it is an SMS service (however, nothing is implied about its validity). An SMS service is where the primary or only intended usage is to receive and/or send text messages (SMSs). This includes MMS as MMS numbers downgrade to SMS if the other party isn't MMS-capable. Returns false if the number doesn't match the region provided.

func IsValidNumber

func IsValidNumber(number *PhoneNumber) bool

Tests whether a phone number matches a valid pattern. Note this doesn't verify the number is actually in use, which is impossible to tell by just looking at a number itself.

func IsValidNumberForRegion

func IsValidNumberForRegion(number *PhoneNumber, regionCode string) bool

Tests whether a phone number is valid for a certain region. Note this doesn't verify the number is actually in use, which is impossible to tell by just looking at a number itself. If the country calling code is not the same as the country calling code for the region, this immediately exits with false. After this, the specific number pattern rules for the region are examined. This is useful for determining for example whether a particular number is valid for Canada, rather than just a valid NANPA number. Warning: In most cases, you want to use IsValidNumber() instead. For example, this method will mark numbers from British Crown dependencies such as the Isle of Man as invalid for the region "GB" (United Kingdom), since it has its own region code, "IM", which may be undesirable.

func IsValidShortNumber

func IsValidShortNumber(number *PhoneNumber) bool

Tests whether a short number matches a valid pattern. If a country calling code is shared by multiple regions, this returns true if it's valid in any of them. Note that this doesn't verify the number is actually in use, which is impossible to tell by just looking at the number itself. See IsValidShortNumberForRegion(PhoneNumber, String) for details.

func IsValidShortNumberForRegion

func IsValidShortNumberForRegion(number *PhoneNumber, regionDialingFrom string) bool

Tests whether a short number matches a valid pattern in a region. Note that this doesn't verify the number is actually in use, which is impossible to tell by just looking at the number itself.

func NormalizeDiallableCharsOnly

func NormalizeDiallableCharsOnly(number string) string

Normalizes a string of characters representing a phone number. This strips all characters which are not diallable on a mobile phone keypad (including all non-ASCII digits).

func NormalizeDigitsOnly

func NormalizeDigitsOnly(number string) string

Normalizes a string of characters representing a phone number. This converts wide-ascii and arabic-indic numerals to European numerals, and strips punctuation and alpha characters.

func ParseAndKeepRawInputToNumber

func ParseAndKeepRawInputToNumber(
	numberToParse, defaultRegion string,
	phoneNumber *PhoneNumber) error

Same as ParseAndKeepRawInput(String, String), but accepts a mutable PhoneNumber as a parameter to decrease object creation when invoked many times.

func ParseToNumber

func ParseToNumber(numberToParse, defaultRegion string, phoneNumber *PhoneNumber) error

Same as Parse(string, string), but accepts mutable PhoneNumber as a parameter to decrease object creation when invoked many times.

func TruncateTooLongNumber

func TruncateTooLongNumber(number *PhoneNumber) bool

Attempts to extract a valid number from a phone number that is too long to be valid, and resets the PhoneNumber object passed in to that valid version. If no valid number could be extracted, the PhoneNumber object passed in will not be modified.

Types

type AsYouTypeFormatter

type AsYouTypeFormatter struct {
	// contains filtered or unexported fields
}

AsYouTypeFormatter formats phone numbers as they are entered. It is a port of libphonenumber's AsYouTypeFormatter (Java reference implementation).

An AsYouTypeFormatter is obtained from GetAsYouTypeFormatter. After that, digits can be added by calling InputDigit on the instance, and the partially formatted phone number is returned each time a digit is added. Clear can be called before formatting a new number.

See AsYouTypeFormatter's tests for more details on how the formatter is to be used.

func GetAsYouTypeFormatter

func GetAsYouTypeFormatter(regionCode string) *AsYouTypeFormatter

GetAsYouTypeFormatter returns an AsYouTypeFormatter for the specific region.

func (*AsYouTypeFormatter) Clear

func (aytf *AsYouTypeFormatter) Clear()

Clear clears the internal state of the formatter, so it can be reused.

func (*AsYouTypeFormatter) GetRememberedPosition

func (aytf *AsYouTypeFormatter) GetRememberedPosition() int

GetRememberedPosition returns the current position in the partially formatted phone number of the character which was previously passed in as the parameter of InputDigitAndRememberPosition.

func (*AsYouTypeFormatter) InputDigit

func (aytf *AsYouTypeFormatter) InputDigit(nextChar rune) string

InputDigit formats a phone number on-the-fly as each digit is entered.

nextChar is the most recently entered digit of a phone number. Formatting characters are allowed, but as soon as they are encountered this method formats the number as entered and not "as you type" anymore. Full width digits and Arabic-indic digits are allowed, and will be shown as they are. It returns the partially formatted phone number.

func (*AsYouTypeFormatter) InputDigitAndRememberPosition

func (aytf *AsYouTypeFormatter) InputDigitAndRememberPosition(nextChar rune) string

InputDigitAndRememberPosition is the same as InputDigit, but remembers the position where nextChar is inserted, so that it can be retrieved later using GetRememberedPosition. The remembered position will be automatically adjusted if additional formatting characters are later inserted/removed in front of nextChar.

type Leniency

type Leniency int

Leniency when finding potential phone numbers in text segments. The levels here are ordered in increasing strictness.

const (
	// POSSIBLE accepts phone numbers that are possible (see IsPossibleNumber),
	// but not necessarily valid (see IsValidNumber).
	POSSIBLE Leniency = iota
	// VALID accepts phone numbers that are possible and valid. Numbers written
	// in national format must have their national-prefix present if it is
	// usually written for a number of this type.
	VALID
	// STRICT_GROUPING accepts phone numbers that are valid and are grouped in a
	// possible way for this locale. For example, a US number written as
	// "65 02 53 00 00" or "650253 0000" is not accepted at this level, whereas
	// "650 253 0000", "650 2530000" or "6502530000" are. Numbers with more than
	// one '/' symbol in the national significant number are also dropped.
	STRICT_GROUPING
	// EXACT_GROUPING accepts phone numbers that are valid and are grouped in the
	// same way that we would have formatted it, or as a single block. For
	// example, a US number written as "650 2530000" is not accepted at this
	// level, whereas "650 253 0000" or "6502530000" are. Numbers with more than
	// one '/' symbol are also dropped.
	EXACT_GROUPING
)

func (Leniency) Verify

func (l Leniency) Verify(number *PhoneNumber, candidate string) bool

type MatchType

type MatchType int
const (
	NOT_A_NUMBER MatchType = iota
	NO_MATCH
	SHORT_NSN_MATCH
	NSN_MATCH
	EXACT_MATCH
)

func IsNumberMatch

func IsNumberMatch(firstNumber, secondNumber string) MatchType

Takes two phone numbers as strings and compares them for equality. This is a convenience wrapper for IsNumberMatch(PhoneNumber, PhoneNumber). No default region is known.

func IsNumberMatchWithNumbers

func IsNumberMatchWithNumbers(firstNumberIn, secondNumberIn *PhoneNumber) MatchType

Takes two phone numbers and compares them for equality.

Returns EXACT_MATCH if the country_code, NSN, presence of a leading zero for Italian numbers and any extension present are the same. Returns NSN_MATCH if either or both has no region specified, and the NSNs and extensions are the same. Returns SHORT_NSN_MATCH if either or both has no region specified, or the region specified is the same, and one NSN could be a shorter version of the other number. This includes the case where one has an extension specified, and the other does not. Returns NO_MATCH otherwise. For example, the numbers +1 345 657 1234 and 657 1234 are a SHORT_NSN_MATCH. The numbers +1 345 657 1234 and 345 657 are a NO_MATCH.

func IsNumberMatchWithOneNumber

func IsNumberMatchWithOneNumber(
	firstNumber *PhoneNumber, secondNumber string) MatchType

Takes two phone numbers and compares them for equality. This is a convenience wrapper for IsNumberMatch(PhoneNumber, PhoneNumber). No default region is known.

type NumberFormat

type NumberFormat = metadata.NumberFormat

The metadata value types from upstream's Phonemetadata. Go's import-cycle rule forces their definitions into the metadata package (its loader returns them and this package depends on that loader), but upstream keeps them top-level and refers to them unqualified — e.g. PhoneNumberUtil's

PhoneMetadata metadata = getMetadataForRegion(...)

Re-exporting them as aliases keeps this package's references unqualified too, so the ported Go stays line-for-line close to the Java source it tracks.

type PhoneMetadata

type PhoneMetadata = metadata.PhoneMetadata

The metadata value types from upstream's Phonemetadata. Go's import-cycle rule forces their definitions into the metadata package (its loader returns them and this package depends on that loader), but upstream keeps them top-level and refers to them unqualified — e.g. PhoneNumberUtil's

PhoneMetadata metadata = getMetadataForRegion(...)

Re-exporting them as aliases keeps this package's references unqualified too, so the ported Go stays line-for-line close to the Java source it tracks.

type PhoneMetadataCollection

type PhoneMetadataCollection = metadata.PhoneMetadataCollection

The metadata value types from upstream's Phonemetadata. Go's import-cycle rule forces their definitions into the metadata package (its loader returns them and this package depends on that loader), but upstream keeps them top-level and refers to them unqualified — e.g. PhoneNumberUtil's

PhoneMetadata metadata = getMetadataForRegion(...)

Re-exporting them as aliases keeps this package's references unqualified too, so the ported Go stays line-for-line close to the Java source it tracks.

func MetadataCollection

func MetadataCollection() (*PhoneMetadataCollection, error)

MetadataCollection returns the embedded territory metadata collection.

func ShortNumberMetadataCollection

func ShortNumberMetadataCollection() (*PhoneMetadataCollection, error)

type PhoneNumber

type PhoneNumber struct {

	// The country calling code for this number, as defined by the International
	// Telecommunication Union (ITU). For example, this would be 1 for NANPA
	// countries, and 33 for France.
	CountryCode *int32 `protobuf:"varint,1,req,name=country_code,json=countryCode" json:"country_code,omitempty"`
	// The National (significant) Number, as defined in International
	// Telecommunication Union (ITU) Recommendation E.164, without any leading
	// zero. The leading-zero is stored separately if required, since this is an
	// uint64 and hence cannot store such information. Do not use this field
	// directly: if you want the national significant number, call the
	// getNationalSignificantNumber method of PhoneNumberUtil.
	//
	// For countries which have the concept of an "area code" or "national
	// destination code", this is included in the National (significant) Number.
	// Although the ITU says the maximum length should be 15, we have found longer
	// numbers in some countries e.g. Germany.
	// Note that the National (significant) Number does not contain the National
	// (trunk) prefix. Obviously, as a uint64, it will never contain any
	// formatting (hyphens, spaces, parentheses), nor any alphanumeric spellings.
	NationalNumber *uint64 `protobuf:"varint,2,req,name=national_number,json=nationalNumber" json:"national_number,omitempty"`
	// Extension is not standardized in ITU recommendations, except for being
	// defined as a series of numbers with a maximum length of 40 digits. It is
	// defined as a string here to accommodate for the possible use of a leading
	// zero in the extension (organizations have complete freedom to do so, as
	// there is no standard defined). Other than digits, some other dialling
	// characters such as "," (indicating a wait) may be stored here.
	Extension *string `protobuf:"bytes,3,opt,name=extension" json:"extension,omitempty"`
	// In some countries, the national (significant) number starts with one or
	// more "0"s without this being a national prefix or trunk code of some kind.
	// For example, the leading zero in the national (significant) number of an
	// Italian phone number indicates the number is a fixed-line number.  There
	// have been plans to migrate fixed-line numbers to start with the digit two
	// since December 2000, but it has not happened yet. See
	// http://en.wikipedia.org/wiki/%2B39 for more details.
	//
	// These fields can be safely ignored (there is no need to set them) for most
	// countries. Some limited number of countries behave like Italy - for these
	// cases, if the leading zero(s) of a number would be retained even when
	// dialling internationally, set this flag to true, and also set the number of
	// leading zeros.
	//
	// Clients who use the parsing functionality of the i18n phone
	// number libraries will have these fields set if necessary automatically.
	ItalianLeadingZero   *bool  `protobuf:"varint,4,opt,name=italian_leading_zero,json=italianLeadingZero" json:"italian_leading_zero,omitempty"`
	NumberOfLeadingZeros *int32 `protobuf:"varint,8,opt,name=number_of_leading_zeros,json=numberOfLeadingZeros,def=1" json:"number_of_leading_zeros,omitempty"`
	// This field is used to store the raw input string containing phone numbers
	// before it was canonicalized by the library. For example, it could be used
	// to store alphanumerical numbers such as "1-800-GOOG-411".
	RawInput *string `protobuf:"bytes,5,opt,name=raw_input,json=rawInput" json:"raw_input,omitempty"`
	// The source from which the country_code is derived.
	CountryCodeSource *PhoneNumber_CountryCodeSource `` /* 156-byte string literal not displayed */
	// The carrier selection code that is preferred when calling this phone number
	// domestically. This also includes codes that need to be dialed in some
	// countries when calling from landlines to mobiles or vice versa. For
	// example, in Columbia, a "3" needs to be dialed before the phone number
	// itself when calling from a mobile phone to a domestic landline phone and
	// vice versa.
	//
	// Note this is the "preferred" code, which means other codes may work as
	// well.
	PreferredDomesticCarrierCode *string `` /* 142-byte string literal not displayed */
	// contains filtered or unexported fields
}

func GetExampleNumber

func GetExampleNumber(regionCode string) *PhoneNumber

Gets a valid number for the specified region.

func GetExampleNumberForNonGeoEntity

func GetExampleNumberForNonGeoEntity(countryCallingCode int) *PhoneNumber

Gets a valid number for the specified country calling code for a non-geographical entity.

func GetExampleNumberForType

func GetExampleNumberForType(typ PhoneNumberType) *PhoneNumber

Gets a valid number for the specified number type (it may belong to any country).

func GetExampleNumberForTypeInRegion

func GetExampleNumberForTypeInRegion(regionCode string, typ PhoneNumberType) *PhoneNumber

Gets a valid number for the specified region and number type.

This is the upstream getExampleNumberForType(String, PhoneNumberType) overload; GetExampleNumberForType is the region-less variant.

func GetInvalidExampleNumber

func GetInvalidExampleNumber(regionCode string) *PhoneNumber

GetInvalidExampleNumber returns an invalid number for the specified region. This is useful for unit-testing purposes, where you want to test what happens with an invalid number. Returns nil when an unsupported region or the region 001 (Earth) is passed in.

func Parse

func Parse(numberToParse, defaultRegion string) (*PhoneNumber, error)

Parses a string and returns it in proto buffer format. This method will throw a NumberParseException if the number is not considered to be a possible number. Note that validation of whether the number is actually a valid number for a particular region is not performed. This can be done separately with IsValidNumber().

func ParseAndKeepRawInput

func ParseAndKeepRawInput(
	numberToParse, defaultRegion string) (*PhoneNumber, error)

Parses a string and returns it in proto buffer format. This method differs from Parse() in that it always populates the raw_input field of the protocol buffer with numberToParse as well as the country_code_source field.

func (*PhoneNumber) Descriptor deprecated

func (*PhoneNumber) Descriptor() ([]byte, []int)

Deprecated: Use PhoneNumber.ProtoReflect.Descriptor instead.

func (*PhoneNumber) GetCountryCode

func (x *PhoneNumber) GetCountryCode() int32

func (*PhoneNumber) GetCountryCodeSource

func (x *PhoneNumber) GetCountryCodeSource() PhoneNumber_CountryCodeSource

func (*PhoneNumber) GetExtension

func (x *PhoneNumber) GetExtension() string

func (*PhoneNumber) GetItalianLeadingZero

func (x *PhoneNumber) GetItalianLeadingZero() bool

func (*PhoneNumber) GetNationalNumber

func (x *PhoneNumber) GetNationalNumber() uint64

func (*PhoneNumber) GetNumberOfLeadingZeros

func (x *PhoneNumber) GetNumberOfLeadingZeros() int32

func (*PhoneNumber) GetPreferredDomesticCarrierCode

func (x *PhoneNumber) GetPreferredDomesticCarrierCode() string

func (*PhoneNumber) GetRawInput

func (x *PhoneNumber) GetRawInput() string

func (*PhoneNumber) ProtoMessage

func (*PhoneNumber) ProtoMessage()

func (*PhoneNumber) ProtoReflect

func (x *PhoneNumber) ProtoReflect() protoreflect.Message

func (*PhoneNumber) Reset

func (x *PhoneNumber) Reset()

func (*PhoneNumber) String

func (x *PhoneNumber) String() string

type PhoneNumberDesc

type PhoneNumberDesc = metadata.PhoneNumberDesc

The metadata value types from upstream's Phonemetadata. Go's import-cycle rule forces their definitions into the metadata package (its loader returns them and this package depends on that loader), but upstream keeps them top-level and refers to them unqualified — e.g. PhoneNumberUtil's

PhoneMetadata metadata = getMetadataForRegion(...)

Re-exporting them as aliases keeps this package's references unqualified too, so the ported Go stays line-for-line close to the Java source it tracks.

type PhoneNumberFormat

type PhoneNumberFormat int
const (
	E164 PhoneNumberFormat = iota
	INTERNATIONAL
	NATIONAL
	RFC3966
)

type PhoneNumberMatch

type PhoneNumberMatch struct {
	// contains filtered or unexported fields
}

PhoneNumberMatch is the immutable match of a phone number within a piece of text. Matches may be found using FindNumbers.

A match consists of the phone number (Number) as well as the start and end byte offsets of the corresponding substring of the searched text. Use RawString to obtain the matched substring. Note that, unlike upstream's Java (which uses UTF-16 char offsets), Start and End are byte offsets into the searched string, so text[match.Start():match.End()] == match.RawString().

func (*PhoneNumberMatch) End

func (m *PhoneNumberMatch) End() int

End returns the exclusive end byte offset of the matched phone number within the searched text.

func (*PhoneNumberMatch) Number

func (m *PhoneNumberMatch) Number() *PhoneNumber

Number returns the phone number matched by the receiver.

func (*PhoneNumberMatch) RawString

func (m *PhoneNumberMatch) RawString() string

RawString returns the raw substring matched as a phone number in the searched text.

func (*PhoneNumberMatch) Start

func (m *PhoneNumberMatch) Start() int

Start returns the start byte offset of the matched phone number within the searched text.

func (*PhoneNumberMatch) String

func (m *PhoneNumberMatch) String() string

String returns a human-readable representation of the match.

type PhoneNumberType

type PhoneNumberType int
const (
	// NOTES:
	//
	// FIXED_LINE_OR_MOBILE:
	//     In some regions (e.g. the USA), it is impossible to distinguish
	//     between fixed-line and mobile numbers by looking at the phone
	//     number itself.
	// SHARED_COST:
	//     The cost of this call is shared between the caller and the
	//     recipient, and is hence typically less than PREMIUM_RATE calls.
	//     See // http://en.wikipedia.org/wiki/Shared_Cost_Service for
	//     more information.
	// VOIP:
	//     Voice over IP numbers. This includes TSoIP (Telephony Service over IP).
	// PERSONAL_NUMBER:
	//     A personal number is associated with a particular person, and may
	//     be routed to either a MOBILE or FIXED_LINE number. Some more
	//     information can be found here:
	//     http://en.wikipedia.org/wiki/Personal_Numbers
	// UAN:
	//     Used for "Universal Access Numbers" or "Company Numbers". They
	//     may be further routed to specific offices, but allow one number
	//     to be used for a company.
	// VOICEMAIL:
	//     Used for "Voice Mail Access Numbers".
	// UNKNOWN:
	//     A phone number is of type UNKNOWN when it does not fit any of
	// the known patterns for a specific region.
	FIXED_LINE PhoneNumberType = iota
	MOBILE
	FIXED_LINE_OR_MOBILE
	TOLL_FREE
	PREMIUM_RATE
	SHARED_COST
	VOIP
	PERSONAL_NUMBER
	PAGER
	UAN
	VOICEMAIL
	UNKNOWN
)

func GetNumberType

func GetNumberType(number *PhoneNumber) PhoneNumberType

Gets the type of a phone number.

type PhoneNumber_CountryCodeSource

type PhoneNumber_CountryCodeSource int32

The source from which the country_code is derived. This is not set in the general parsing method, but in the method that parses and keeps raw_input. New fields could be added upon request.

const (
	// Default value returned if this is not set, because the phone number was
	// created using parse, not parseAndKeepRawInput. hasCountryCodeSource will
	// return false if this is the case.
	PhoneNumber_UNSPECIFIED PhoneNumber_CountryCodeSource = 0
	// The country_code is derived based on a phone number with a leading "+",
	// e.g. the French number "+33 1 42 68 53 00".
	PhoneNumber_FROM_NUMBER_WITH_PLUS_SIGN PhoneNumber_CountryCodeSource = 1
	// The country_code is derived based on a phone number with a leading IDD,
	// e.g. the French number "011 33 1 42 68 53 00", as it is dialled from US.
	PhoneNumber_FROM_NUMBER_WITH_IDD PhoneNumber_CountryCodeSource = 5
	// The country_code is derived based on a phone number without a leading
	// "+", e.g. the French number "33 1 42 68 53 00" when defaultCountry is
	// supplied as France.
	PhoneNumber_FROM_NUMBER_WITHOUT_PLUS_SIGN PhoneNumber_CountryCodeSource = 10
	// The country_code is derived NOT based on the phone number itself, but
	// from the defaultCountry parameter provided in the parsing function by the
	// clients. This happens mostly for numbers written in the national format
	// (without country code). For example, this would be set when parsing the
	// French number "01 42 68 53 00", when defaultCountry is supplied as
	// France.
	PhoneNumber_FROM_DEFAULT_COUNTRY PhoneNumber_CountryCodeSource = 20
)

func (PhoneNumber_CountryCodeSource) Descriptor

func (PhoneNumber_CountryCodeSource) Enum

func (PhoneNumber_CountryCodeSource) EnumDescriptor deprecated

func (PhoneNumber_CountryCodeSource) EnumDescriptor() ([]byte, []int)

Deprecated: Use PhoneNumber_CountryCodeSource.Descriptor instead.

func (PhoneNumber_CountryCodeSource) Number

func (PhoneNumber_CountryCodeSource) String

func (PhoneNumber_CountryCodeSource) Type

func (*PhoneNumber_CountryCodeSource) UnmarshalJSON deprecated

func (x *PhoneNumber_CountryCodeSource) UnmarshalJSON(b []byte) error

Deprecated: Do not use.

type ShortNumberCost

type ShortNumberCost int

ShortNumberCost is the cost category of a short number.

const (
	TOLL_FREE_COST ShortNumberCost = iota
	STANDARD_RATE_COST
	PREMIUM_RATE_COST
	UNKNOWN_COST
)

Cost categories of short numbers. Note these are suffixed with _COST to avoid clashing with the PhoneNumberType constants TOLL_FREE and PREMIUM_RATE.

func GetExpectedCost

func GetExpectedCost(number *PhoneNumber) ShortNumberCost

GetExpectedCost gets the expected cost category of a short number (however, nothing is implied about its validity). If the country calling code is unique to a region, this method behaves exactly the same as GetExpectedCostForRegion. However, if the country calling code is shared by multiple regions, then it returns the highest cost in the sequence PREMIUM_RATE, UNKNOWN_COST, STANDARD_RATE, TOLL_FREE. The reason for the position of UNKNOWN_COST in this order is that if a number is UNKNOWN_COST in one region but STANDARD_RATE or TOLL_FREE in another, its expected cost cannot be estimated as one of the latter since it might be a PREMIUM_RATE number.

Note: If the region from which the number is dialed is known, it is highly preferable to call GetExpectedCostForRegion instead.

func GetExpectedCostForRegion

func GetExpectedCostForRegion(number *PhoneNumber, regionDialingFrom string) ShortNumberCost

GetExpectedCostForRegion gets the expected cost category of a short number when dialed from a region (however, nothing is implied about its validity). If it is important that the number is valid, then its validity must first be checked using IsValidShortNumberForRegion. Note that emergency numbers are always considered toll-free. Returns UNKNOWN_COST if the number does not match a cost category. Note that an invalid number may match any cost category.

func (ShortNumberCost) String

func (c ShortNumberCost) String() string

type ValidationResult

type ValidationResult int
const (
	IS_POSSIBLE ValidationResult = iota
	IS_POSSIBLE_LOCAL_ONLY
	INVALID_COUNTRY_CODE
	TOO_SHORT
	INVALID_LENGTH
	TOO_LONG
)

func IsPossibleNumberForTypeWithReason

func IsPossibleNumberForTypeWithReason(number *PhoneNumber, numberType PhoneNumberType) ValidationResult

IsPossibleNumberForTypeWithReason checks whether a phone number is a possible number of a particular type. For most number types, this is the same result as IsPossibleNumberWithReason. See that method for details.

func IsPossibleNumberWithReason

func IsPossibleNumberWithReason(number *PhoneNumber) ValidationResult

Check whether a phone number is a possible number. It provides a more lenient check than IsValidNumber() in the following sense:

  • It only checks the length of phone numbers. In particular, it doesn't check starting digits of the number.
  • It doesn't attempt to figure out the type of the number, but uses general rules which applies to all types of phone numbers in a region. Therefore, it is much faster than isValidNumber.
  • For fixed line numbers, many regions have the concept of area code, which together with subscriber number constitute the national significant number. It is sometimes okay to dial the subscriber number only when dialing in the same area. This function will return true if the subscriber-number-only version is passed in. On the other hand, because isValidNumber validates using information on both starting digits (for fixed line numbers, that would most likely be area codes) and length (obviously includes the length of area codes for fixed line numbers), it will return false for the subscriber-number-only version.

Directories

Path Synopsis
Port of java/carrier/src/com/google/i18n/phonenumbers/PhoneNumberToCarrierMapper.java.
Port of java/carrier/src/com/google/i18n/phonenumbers/PhoneNumberToCarrierMapper.java.
cmd
buildmetadata command
phoneparser command
Port of java/geocoder/src/com/google/i18n/phonenumbers/geocoding/PhoneNumberOfflineGeocoder.java.
Port of java/geocoder/src/com/google/i18n/phonenumbers/geocoding/PhoneNumberOfflineGeocoder.java.
internal
metadatabuilder
Port of tools/java/common/src/com/google/i18n/phonenumbers/BuildMetadataFromXml.java.
Port of tools/java/common/src/com/google/i18n/phonenumbers/BuildMetadataFromXml.java.
prefixmapper
Port of java/internal/prefixmapper/src/com/google/i18n/phonenumbers/prefixmapper/* (shared prefix lookup).
Port of java/internal/prefixmapper/src/com/google/i18n/phonenumbers/prefixmapper/* (shared prefix lookup).
regexbasedmatcher
Package regexbasedmatcher matches national numbers against the patterns in phone-number metadata.
Package regexbasedmatcher matches national numbers against the patterns in phone-number metadata.
regexcache
Package regexcache caches compiled regular expressions keyed by their pattern string, so the libphonenumber port avoids recompiling the same metadata-derived patterns on every call.
Package regexcache caches compiled regular expressions keyed by their pattern string, so the libphonenumber port avoids recompiling the same metadata-derived patterns on every call.
serialize
Package serialize decodes the gzipped binary blobs the library embeds for its metadata and prefix lookups (carrier, geocoding, timezone, and region maps).
Package serialize decodes the gzipped binary blobs the library embeds for its metadata and prefix lookups (carrier, geocoding, timezone, and region maps).
stringbuilder
Package stringbuilder provides a minimal, mutable string buffer used internally by the libphonenumber port.
Package stringbuilder provides a minimal, mutable string buffer used internally by the libphonenumber port.
Package metadata holds the phone-number metadata value types (a port of upstream's Phonemetadata) together with the hand-written helpers on them.
Package metadata holds the phone-number metadata value types (a port of upstream's Phonemetadata) together with the hand-written helpers on them.
Port of java/geocoder/src/com/google/i18n/phonenumbers/PhoneNumberToTimeZonesMapper.java.
Port of java/geocoder/src/com/google/i18n/phonenumbers/PhoneNumberToTimeZonesMapper.java.

Jump to

Keyboard shortcuts

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