@types/google-libphonenumber
- Version 7.4.30
- Published
- 24.3 kB
- No dependencies
- MIT license
Install
npm i @types/google-libphonenumber
yarn add @types/google-libphonenumber
pnpm add @types/google-libphonenumber
Overview
TypeScript definitions for google-libphonenumber
Index
Namespaces
Namespaces
namespace google-libphonenumber
module 'google-libphonenumber' {}
class AsYouTypeFormatter
class AsYouTypeFormatter {}
constructor
constructor(region: string);
method clear
clear: () => void;
method inputDigit
inputDigit: (digit: string) => string;
class PhoneNumber
class PhoneNumber {}
method clearCountryCode
clearCountryCode: () => void;
method clearCountryCodeSource
clearCountryCodeSource: () => void;
method clearExtension
clearExtension: () => void;
method clearItalianLeadingZero
clearItalianLeadingZero: () => void;
method clearNationalNumber
clearNationalNumber: () => void;
method clearNumberOfLeadingZeros
clearNumberOfLeadingZeros: () => void;
method clearPreferredDomesticCarrierCode
clearPreferredDomesticCarrierCode: () => void;
method clearRawInput
clearRawInput: () => void;
method countryCodeCount
countryCodeCount: () => number;
method countryCodeSourceCount
countryCodeSourceCount: () => number;
method extensionCount
extensionCount: () => number;
method getCountryCode
getCountryCode: () => number | undefined;
method getCountryCodeOrDefault
getCountryCodeOrDefault: () => number;
method getCountryCodeSource
getCountryCodeSource: () => PhoneNumber.CountryCodeSource | undefined;
method getCountryCodeSourceOrDefault
getCountryCodeSourceOrDefault: () => PhoneNumber.CountryCodeSource;
method getExtension
getExtension: () => string | undefined;
method getExtensionOrDefault
getExtensionOrDefault: () => string;
method getItalianLeadingZero
getItalianLeadingZero: () => boolean | undefined;
method getItalianLeadingZeroOrDefault
getItalianLeadingZeroOrDefault: () => boolean;
method getNationalNumber
getNationalNumber: () => number | undefined;
method getNationalNumberOrDefault
getNationalNumberOrDefault: () => number;
method getNumberOfLeadingZeros
getNumberOfLeadingZeros: () => number | undefined;
method getNumberOfLeadingZerosOrDefault
getNumberOfLeadingZerosOrDefault: () => number;
method getPreferredDomesticCarrierCode
getPreferredDomesticCarrierCode: () => string | undefined;
method getPreferredDomesticCarrierCodeOrDefault
getPreferredDomesticCarrierCodeOrDefault: () => string;
method getRawInput
getRawInput: () => string | undefined;
method getRawInputOrDefault
getRawInputOrDefault: () => string;
method hasCountryCode
hasCountryCode: () => boolean;
method hasCountryCodeSource
hasCountryCodeSource: () => boolean;
method hasExtension
hasExtension: () => boolean;
method hasItalianLeadingZero
hasItalianLeadingZero: () => boolean;
method hasNationalNumber
hasNationalNumber: () => boolean;
method hasNumberOfLeadingZeros
hasNumberOfLeadingZeros: () => boolean;
method hasPreferredDomesticCarrierCode
hasPreferredDomesticCarrierCode: () => boolean;
method hasRawInput
hasRawInput: () => boolean;
method italianLeadingZeroCount
italianLeadingZeroCount: () => number;
method nationalNumberCount
nationalNumberCount: () => number;
method numberOfLeadingZerosCount
numberOfLeadingZerosCount: () => number;
method preferredDomesticCarrierCodeCount
preferredDomesticCarrierCodeCount: () => number;
method rawInputCount
rawInputCount: () => number;
method setCountryCode
setCountryCode: (value: number) => void;
method setCountryCodeSource
setCountryCodeSource: (value: PhoneNumber.CountryCodeSource) => void;
method setExtension
setExtension: (value: string) => void;
method setItalianLeadingZero
setItalianLeadingZero: (value: boolean) => void;
method setNationalNumber
setNationalNumber: (value: number) => number;
method setNumberOfLeadingZeros
setNumberOfLeadingZeros: (value: number) => void;
method setPreferredDomesticCarrierCode
setPreferredDomesticCarrierCode: (value: string) => void;
method setRawInput
setRawInput: (value: string) => void;
class PhoneNumberUtil
class PhoneNumberUtil {}
method extractCountryCode
extractCountryCode: ( fullNumber: StringBuffer, nationalNumber: StringBuffer) => number;
method format
format: (phoneNumber: PhoneNumber, format: PhoneNumberFormat) => string;
method formatInOriginalFormat
formatInOriginalFormat: ( phoneNumber: PhoneNumber, regionDialingFrom?: string) => string;
method formatOutOfCountryCallingNumber
formatOutOfCountryCallingNumber: ( phoneNumber: PhoneNumber, regionDialingFrom?: string) => string;
method getCountryCodeForRegion
getCountryCodeForRegion: (supportedRegion: string) => number;
method getExampleNumber
getExampleNumber: (regionCode: string) => PhoneNumber;
method getExampleNumberForType
getExampleNumberForType: ( regionCode: string, type: PhoneNumberType) => PhoneNumber;
method getInstance
static getInstance: () => PhoneNumberUtil;
method getLengthOfGeographicalAreaCode
getLengthOfGeographicalAreaCode: (number: PhoneNumber) => number;
method getLengthOfNationalDestinationCode
getLengthOfNationalDestinationCode: (number: PhoneNumber) => number;
method getNationalSignificantNumber
getNationalSignificantNumber: (number: PhoneNumber) => string;
method getNddPrefixForRegion
getNddPrefixForRegion: ( regionCode?: string, stripNonDigits?: boolean) => string | undefined;
method getNumberType
getNumberType: (phoneNumber: PhoneNumber) => PhoneNumberType;
method getRegionCodeForCountryCode
getRegionCodeForCountryCode: ( countryCallingCode: number) => RegionCode | RegionCodeUnknown;
method getRegionCodeForNumber
getRegionCodeForNumber: (phoneNumber: PhoneNumber) => RegionCode | undefined;
method getSupportedRegions
getSupportedRegions: () => RegionCode[];
method isAlphaNumber
isAlphaNumber: (number: string) => boolean;
method isLeadingZeroPossible
isLeadingZeroPossible: (countryCallingCode: number) => boolean;
method isNANPACountry
isNANPACountry: (regionCode?: string) => boolean;
method isNumberMatch
isNumberMatch: ( firstNumber: string | PhoneNumber, secondNumber: string | PhoneNumber) => PhoneNumberUtil.MatchType;
method isPossibleNumber
isPossibleNumber: { (number: PhoneNumber): boolean; (phoneNumber: PhoneNumber): boolean;};
method isPossibleNumberForType
isPossibleNumberForType: (number: PhoneNumber, type: PhoneNumberType) => boolean;
method isPossibleNumberForTypeWithReason
isPossibleNumberForTypeWithReason: ( number: PhoneNumber, type: PhoneNumberType) => PhoneNumberUtil.ValidationResult;
method isPossibleNumberString
isPossibleNumberString: (number: string, regionDialingFrom: string) => boolean;
method isPossibleNumberWithReason
isPossibleNumberWithReason: { (number: PhoneNumber): PhoneNumberUtil.ValidationResult; (phoneNumber: PhoneNumber): PhoneNumberUtil.ValidationResult;};
method isValidNumber
isValidNumber: (phoneNumber: PhoneNumber) => boolean;
method isValidNumberForRegion
isValidNumberForRegion: (phoneNumber: PhoneNumber, region?: string) => boolean;
method parse
parse: (number?: string, region?: string) => PhoneNumber;
method parseAndKeepRawInput
parseAndKeepRawInput: (number: string, regionCode?: string) => PhoneNumber;
method truncateTooLongNumber
truncateTooLongNumber: (number: PhoneNumber) => boolean;
class ShortNumberInfo
class ShortNumberInfo {}
method connectsToEmergencyNumber
connectsToEmergencyNumber: ( number: string, regionDialing: RegionCode) => boolean;
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).
Parameter number
the phone number to test
Parameter regionCode
the region where the phone number is being dialed whether the number might be used to connect to an emergency service in the given region
method getExpectedCost
getExpectedCost: (number: PhoneNumber) => ShortNumberInfo.ShortNumberCost;
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 ShortNumberInfo.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.
For example, if a number is STANDARD_RATE in the US, but TOLL_FREE in Canada, the expected cost returned by this method will be STANDARD_RATE, since the NANPA countries share the same country calling code.
Note: If the region from which the number is dialed is known, it is highly preferable to call ShortNumberInfo.getExpectedCostForRegion instead.
Parameter number
the short number for which we want to know the expected cost category the highest expected cost category of the short number in the region(s) with the given country calling code
method getExpectedCostForRegion
getExpectedCostForRegion: ( number: PhoneNumber, regionDialingFrom: RegionCode) => ShortNumberInfo.ShortNumberCost;
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 ShortNumberInfo.isValidShortNumberForRegion. Note that emergency numbers are always considered toll-free.
Parameter number
the short number for which we want to know the expected cost category
Parameter regionDialingFrom
the region from which the number is dialed the expected cost category for that region of the short number. Returns UNKNOWN_COST the number does not match a cost category. Note that an invalid number may match any cost category.
Example 1
Usage:
// The region for which the number was parsed and the region we subsequently check against// need not be the same. Here we parse the number in the US and check it for Canada.const phoneNumber = phoneUtil.parse("110", "US");const regionCode: RegionCode = '"CA"';const shortInfo = ShortNumberInfo.getInstance();if (shortInfo.isValidShortNumberForRegion(phoneNumber, regionCode)) {const cost = shortInfo.getExpectedCostForRegion(phoneNumber, regionCode);// Do something with the cost information here.}
method getInstance
static getInstance: () => ShortNumberInfo;
Returns the singleton instance of the ShortNumberInfo.
method isCarrierSpecific
isCarrierSpecific: (number: PhoneNumber) => boolean;
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 ShortNumberInfo.isValidShortNumber or ShortNumberInfo.isValidShortNumberForRegion.
Parameter number
the valid short number to check whether the short number is carrier-specific, assuming the input was a valid short number
method isCarrierSpecificForRegion
isCarrierSpecificForRegion: ( number: PhoneNumber, regionDialingFrom: RegionCode) => boolean;
Given a valid short number, determines whether it is carrier-specific when dialed from the given region (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 ShortNumberInfo.isValidShortNumber or ShortNumberInfo.isValidShortNumberForRegion. Returns false if the number doesn't match the region provided.
Parameter number
the valid short number to check
Parameter regionDialingFrom
the region from which the number is dialed whether the short number is carrier-specific in the provided region, assuming the input was a valid short number
method isEmergencyNumber
isEmergencyNumber: (number: string, regionCode: RegionCode) => boolean;
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)
impliesconnectsToEmergencyNumber(number, region)
.Parameter number
the phone number to test
Parameter regionCode
the region where the phone number is being dialed whether the number exactly matches an emergency services number in the given region
method isPossibleShortNumber
isPossibleShortNumber: (number: PhoneNumber) => boolean;
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 ShortNumberInfo.isValidShortNumber. See ShortNumberInfo.isPossibleShortNumberForRegion for details.
Parameter number
the short number to check whether the number is a possible short number
method isPossibleShortNumberForRegion
isPossibleShortNumberForRegion: ( number: PhoneNumber, regionDialingFrom: RegionCode) => boolean;
Check whether a short number is a possible number when dialed from the given region. This provides a more lenient check than ShortNumberInfo.isValidShortNumberForRegion.
Parameter number
the short number to check
Parameter regionDialingFrom
the region from which the number is dialed whether the number is a possible short number
method isSmsServiceForRegion
isSmsServiceForRegion: ( number: PhoneNumber, regionDialingFrom: string) => boolean;
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. If it is important that the number is valid, then its validity must first be checked using ShortNumberInfo.isValidShortNumber or ShortNumberInfo.isValidShortNumberForRegion. Returns false if the number doesn't match the region provided.
Parameter number
the valid short number to check
Parameter regionDialingFrom
the region from which the number is dialed whether the short number is an SMS service in the provided region, assuming the input was a valid short number
method isValidShortNumber
isValidShortNumber: (number: PhoneNumber) => boolean;
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 ShortNumberInfo.isValidShortNumberForRegion for details.
Parameter number
the short number for which we want to test the validity whether the short number matches a valid pattern
method isValidShortNumberForRegion
isValidShortNumberForRegion: ( number: PhoneNumber, regionDialingFrom: RegionCode) => boolean;
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.
Parameter number
the short number for which we want to test the validity
Parameter regionDialingFrom
the region from which the number is dialed whether the short number matches a valid pattern
class StringBuffer
class StringBuffer {}
constructor
constructor(opt_a1?: any, ...var_args: any[]);
method append
append: (a1: any, opt_a2?: any, ...var_args: any[]) => StringBuffer;
method toString
toString: () => string;
enum PhoneNumberFormat
enum PhoneNumberFormat { E164, INTERNATIONAL, NATIONAL, RFC3966,}
enum PhoneNumberType
enum PhoneNumberType { FIXED_LINE = 0, MOBILE = 1, FIXED_LINE_OR_MOBILE = 2, TOLL_FREE = 3, PREMIUM_RATE = 4, SHARED_COST = 5, VOIP = 6, PERSONAL_NUMBER = 7, PAGER = 8, UAN = 9, VOICEMAIL = 10, UNKNOWN = -1,}
member FIXED_LINE
FIXED_LINE = 0
member FIXED_LINE_OR_MOBILE
FIXED_LINE_OR_MOBILE = 2
member MOBILE
MOBILE = 1
member PAGER
PAGER = 8
member PERSONAL_NUMBER
PERSONAL_NUMBER = 7
member PREMIUM_RATE
PREMIUM_RATE = 4
member SHARED_COST
SHARED_COST = 5
member TOLL_FREE
TOLL_FREE = 3
member UAN
UAN = 9
member UNKNOWN
UNKNOWN = -1
member VOICEMAIL
VOICEMAIL = 10
member VOIP
VOIP = 6
type RegionCode
type RegionCode = | 'AC' | 'AD' | 'AE' | 'AF' | 'AG' | 'AI' | 'AL' | 'AM' | 'AO' | 'AR' | 'AS' | 'AT' | 'AU' | 'AW' | 'AX' | 'AZ' | 'BA' | 'BB' | 'BD' | 'BE' | 'BF' | 'BG' | 'BH' | 'BI' | 'BJ' | 'BL' | 'BM' | 'BN' | 'BO' | 'BQ' | 'BR' | 'BS' | 'BT' | 'BW' | 'BY' | 'BZ' | 'CA' | 'CC' | 'CD' | 'CF' | 'CG' | 'CH' | 'CI' | 'CK' | 'CL' | 'CM' | 'CN' | 'CO' | 'CR' | 'CU' | 'CV' | 'CW' | 'CX' | 'CY' | 'CZ' | 'DE' | 'DJ' | 'DK' | 'DM' | 'DO' | 'DZ' | 'EC' | 'EE' | 'EG' | 'EH' | 'ER' | 'ES' | 'ET' | 'FI' | 'FJ' | 'FK' | 'FM' | 'FO' | 'FR' | 'GA' | 'GB' | 'GD' | 'GE' | 'GF' | 'GG' | 'GH' | 'GI' | 'GL' | 'GM' | 'GN' | 'GP' | 'GQ' | 'GR' | 'GT' | 'GU' | 'GW' | 'GY' | 'HK' | 'HN' | 'HR' | 'HT' | 'HU' | 'ID' | 'IE' | 'IL' | 'IM' | 'IN' | 'IO' | 'IQ' | 'IR' | 'IS' | 'IT' | 'JE' | 'JM' | 'JO' | 'JP' | 'KE' | 'KG' | 'KH' | 'KI' | 'KM' | 'KN' | 'KP' | 'KR' | 'KW' | 'KY' | 'KZ' | 'LA' | 'LB' | 'LC' | 'LI' | 'LK' | 'LR' | 'LS' | 'LT' | 'LU' | 'LV' | 'LY' | 'MA' | 'MC' | 'MD' | 'ME' | 'MF' | 'MG' | 'MH' | 'MK' | 'ML' | 'MM' | 'MN' | 'MO' | 'MP' | 'MQ' | 'MR' | 'MS' | 'MT' | 'MU' | 'MV' | 'MW' | 'MX' | 'MY' | 'MZ' | 'NA' | 'NC' | 'NE' | 'NF' | 'NG' | 'NI' | 'NL' | 'NO' | 'NP' | 'NR' | 'NU' | 'NZ' | 'OM' | 'PA' | 'PE' | 'PF' | 'PG' | 'PH' | 'PK' | 'PL' | 'PM' | 'PR' | 'PS' | 'PT' | 'PW' | 'PY' | 'QA' | 'RE' | 'RO' | 'RS' | 'RU' | 'RW' | 'SA' | 'SB' | 'SC' | 'SD' | 'SE' | 'SG' | 'SH' | 'SI' | 'SJ' | 'SK' | 'SL' | 'SM' | 'SN' | 'SO' | 'SR' | 'SS' | 'ST' | 'SV' | 'SX' | 'SY' | 'SZ' | 'TA' | 'TC' | 'TD' | 'TG' | 'TH' | 'TJ' | 'TK' | 'TL' | 'TM' | 'TN' | 'TO' | 'TR' | 'TT' | 'TV' | 'TW' | 'TZ' | 'UA' | 'UG' | 'US' | 'UY' | 'UZ' | 'VA' | 'VC' | 'VE' | 'VG' | 'VI' | 'VN' | 'VU' | 'WF' | 'WS' | 'XK' | 'YE' | 'YT' | 'ZA' | 'ZM' | 'ZW';
type RegionCodeUnknown
type RegionCodeUnknown = 'ZZ';
namespace google-libphonenumber.PhoneNumber
namespace google-libphonenumber.PhoneNumber {}
enum CountryCodeSource
enum CountryCodeSource { FROM_NUMBER_WITH_PLUS_SIGN = 1, FROM_NUMBER_WITH_IDD = 5, FROM_NUMBER_WITHOUT_PLUS_SIGN = 10, FROM_DEFAULT_COUNTRY = 20,}
member FROM_DEFAULT_COUNTRY
FROM_DEFAULT_COUNTRY = 20
member FROM_NUMBER_WITH_IDD
FROM_NUMBER_WITH_IDD = 5
member FROM_NUMBER_WITH_PLUS_SIGN
FROM_NUMBER_WITH_PLUS_SIGN = 1
member FROM_NUMBER_WITHOUT_PLUS_SIGN
FROM_NUMBER_WITHOUT_PLUS_SIGN = 10
namespace google-libphonenumber.PhoneNumberUtil
namespace google-libphonenumber.PhoneNumberUtil {}
enum MatchType
enum MatchType { EXACT_MATCH, NO_MATCH, NOT_A_NUMBER, NSN_MATCH, SHORT_NSN_MATCH,}
member EXACT_MATCH
EXACT_MATCH
member NO_MATCH
NO_MATCH
member NOT_A_NUMBER
NOT_A_NUMBER
member NSN_MATCH
NSN_MATCH
member SHORT_NSN_MATCH
SHORT_NSN_MATCH
enum ValidationResult
enum ValidationResult { IS_POSSIBLE, INVALID_COUNTRY_CODE, TOO_SHORT, TOO_LONG, IS_POSSIBLE_LOCAL_ONLY, INVALID_LENGTH,}
member INVALID_COUNTRY_CODE
INVALID_COUNTRY_CODE
The number has an invalid country calling code. =1
member INVALID_LENGTH
INVALID_LENGTH
The number is longer than the shortest valid numbers for this region, shorter than the longest valid numbers for this region, and does not itself have a number length that matches valid numbers for this region. This can also be returned in the case where isPossibleNumberForTypeWithReason was called, and there are no numbers of this type at all for this region. =5
member IS_POSSIBLE
IS_POSSIBLE
The number length matches that of valid numbers for this region. =0
member IS_POSSIBLE_LOCAL_ONLY
IS_POSSIBLE_LOCAL_ONLY
The number length matches that of local numbers for this region only (i.e. numbers that may be able to be dialled within an area, but do not have all the information to be dialled from anywhere inside or outside the country). =4
member TOO_LONG
TOO_LONG
The number is longer than all valid numbers for this region. =3
member TOO_SHORT
TOO_SHORT
The number is shorter than all valid numbers for this region. =2
namespace google-libphonenumber.ShortNumberInfo
namespace google-libphonenumber.ShortNumberInfo {}
enum ShortNumberCost
enum ShortNumberCost { TOLL_FREE = 0, STANDARD_RATE = 1, PREMIUM_RATE = 2, UNKNOWN_COST = 3,}
Cost categories of short numbers.
member PREMIUM_RATE
PREMIUM_RATE = 2
member STANDARD_RATE
STANDARD_RATE = 1
member TOLL_FREE
TOLL_FREE = 0
member UNKNOWN_COST
UNKNOWN_COST = 3
namespace libphonenumber
namespace libphonenumber {}
class AsYouTypeFormatter
class AsYouTypeFormatter {}
constructor
constructor(region: string);
method clear
clear: () => void;
method inputDigit
inputDigit: (digit: string) => string;
class PhoneNumber
class PhoneNumber {}
method clearCountryCode
clearCountryCode: () => void;
method clearCountryCodeSource
clearCountryCodeSource: () => void;
method clearExtension
clearExtension: () => void;
method clearItalianLeadingZero
clearItalianLeadingZero: () => void;
method clearNationalNumber
clearNationalNumber: () => void;
method clearNumberOfLeadingZeros
clearNumberOfLeadingZeros: () => void;
method clearPreferredDomesticCarrierCode
clearPreferredDomesticCarrierCode: () => void;
method clearRawInput
clearRawInput: () => void;
method countryCodeCount
countryCodeCount: () => number;
method countryCodeSourceCount
countryCodeSourceCount: () => number;
method extensionCount
extensionCount: () => number;
method getCountryCode
getCountryCode: () => number | undefined;
method getCountryCodeOrDefault
getCountryCodeOrDefault: () => number;
method getCountryCodeSource
getCountryCodeSource: () => PhoneNumber.CountryCodeSource | undefined;
method getCountryCodeSourceOrDefault
getCountryCodeSourceOrDefault: () => PhoneNumber.CountryCodeSource;
method getExtension
getExtension: () => string | undefined;
method getExtensionOrDefault
getExtensionOrDefault: () => string;
method getItalianLeadingZero
getItalianLeadingZero: () => boolean | undefined;
method getItalianLeadingZeroOrDefault
getItalianLeadingZeroOrDefault: () => boolean;
method getNationalNumber
getNationalNumber: () => number | undefined;
method getNationalNumberOrDefault
getNationalNumberOrDefault: () => number;
method getNumberOfLeadingZeros
getNumberOfLeadingZeros: () => number | undefined;
method getNumberOfLeadingZerosOrDefault
getNumberOfLeadingZerosOrDefault: () => number;
method getPreferredDomesticCarrierCode
getPreferredDomesticCarrierCode: () => string | undefined;
method getPreferredDomesticCarrierCodeOrDefault
getPreferredDomesticCarrierCodeOrDefault: () => string;
method getRawInput
getRawInput: () => string | undefined;
method getRawInputOrDefault
getRawInputOrDefault: () => string;
method hasCountryCode
hasCountryCode: () => boolean;
method hasCountryCodeSource
hasCountryCodeSource: () => boolean;
method hasExtension
hasExtension: () => boolean;
method hasItalianLeadingZero
hasItalianLeadingZero: () => boolean;
method hasNationalNumber
hasNationalNumber: () => boolean;
method hasNumberOfLeadingZeros
hasNumberOfLeadingZeros: () => boolean;
method hasPreferredDomesticCarrierCode
hasPreferredDomesticCarrierCode: () => boolean;
method hasRawInput
hasRawInput: () => boolean;
method italianLeadingZeroCount
italianLeadingZeroCount: () => number;
method nationalNumberCount
nationalNumberCount: () => number;
method numberOfLeadingZerosCount
numberOfLeadingZerosCount: () => number;
method preferredDomesticCarrierCodeCount
preferredDomesticCarrierCodeCount: () => number;
method rawInputCount
rawInputCount: () => number;
method setCountryCode
setCountryCode: (value: number) => void;
method setCountryCodeSource
setCountryCodeSource: (value: PhoneNumber.CountryCodeSource) => void;
method setExtension
setExtension: (value: string) => void;
method setItalianLeadingZero
setItalianLeadingZero: (value: boolean) => void;
method setNationalNumber
setNationalNumber: (value: number) => number;
method setNumberOfLeadingZeros
setNumberOfLeadingZeros: (value: number) => void;
method setPreferredDomesticCarrierCode
setPreferredDomesticCarrierCode: (value: string) => void;
method setRawInput
setRawInput: (value: string) => void;
class PhoneNumberUtil
class PhoneNumberUtil {}
method extractCountryCode
extractCountryCode: ( fullNumber: StringBuffer, nationalNumber: StringBuffer) => number;
method format
format: (phoneNumber: PhoneNumber, format: PhoneNumberFormat) => string;
method formatInOriginalFormat
formatInOriginalFormat: ( phoneNumber: PhoneNumber, regionDialingFrom?: string) => string;
method formatOutOfCountryCallingNumber
formatOutOfCountryCallingNumber: ( phoneNumber: PhoneNumber, regionDialingFrom?: string) => string;
method getCountryCodeForRegion
getCountryCodeForRegion: (supportedRegion: string) => number;
method getExampleNumber
getExampleNumber: (regionCode: string) => PhoneNumber;
method getExampleNumberForType
getExampleNumberForType: ( regionCode: string, type: PhoneNumberType) => PhoneNumber;
method getInstance
static getInstance: () => PhoneNumberUtil;
method getLengthOfGeographicalAreaCode
getLengthOfGeographicalAreaCode: (number: PhoneNumber) => number;
method getLengthOfNationalDestinationCode
getLengthOfNationalDestinationCode: (number: PhoneNumber) => number;
method getNationalSignificantNumber
getNationalSignificantNumber: (number: PhoneNumber) => string;
method getNddPrefixForRegion
getNddPrefixForRegion: ( regionCode?: string, stripNonDigits?: boolean) => string | undefined;
method getNumberType
getNumberType: (phoneNumber: PhoneNumber) => PhoneNumberType;
method getRegionCodeForCountryCode
getRegionCodeForCountryCode: ( countryCallingCode: number) => RegionCode | RegionCodeUnknown;
method getRegionCodeForNumber
getRegionCodeForNumber: (phoneNumber: PhoneNumber) => RegionCode | undefined;
method getSupportedRegions
getSupportedRegions: () => RegionCode[];
method isAlphaNumber
isAlphaNumber: (number: string) => boolean;
method isLeadingZeroPossible
isLeadingZeroPossible: (countryCallingCode: number) => boolean;
method isNANPACountry
isNANPACountry: (regionCode?: string) => boolean;
method isNumberMatch
isNumberMatch: ( firstNumber: string | PhoneNumber, secondNumber: string | PhoneNumber) => PhoneNumberUtil.MatchType;
method isPossibleNumber
isPossibleNumber: { (number: PhoneNumber): boolean; (phoneNumber: PhoneNumber): boolean;};
method isPossibleNumberForType
isPossibleNumberForType: (number: PhoneNumber, type: PhoneNumberType) => boolean;
method isPossibleNumberForTypeWithReason
isPossibleNumberForTypeWithReason: ( number: PhoneNumber, type: PhoneNumberType) => PhoneNumberUtil.ValidationResult;
method isPossibleNumberString
isPossibleNumberString: (number: string, regionDialingFrom: string) => boolean;
method isPossibleNumberWithReason
isPossibleNumberWithReason: { (number: PhoneNumber): PhoneNumberUtil.ValidationResult; (phoneNumber: PhoneNumber): PhoneNumberUtil.ValidationResult;};
method isValidNumber
isValidNumber: (phoneNumber: PhoneNumber) => boolean;
method isValidNumberForRegion
isValidNumberForRegion: (phoneNumber: PhoneNumber, region?: string) => boolean;
method parse
parse: (number?: string, region?: string) => PhoneNumber;
method parseAndKeepRawInput
parseAndKeepRawInput: (number: string, regionCode?: string) => PhoneNumber;
method truncateTooLongNumber
truncateTooLongNumber: (number: PhoneNumber) => boolean;
class ShortNumberInfo
class ShortNumberInfo {}
method connectsToEmergencyNumber
connectsToEmergencyNumber: ( number: string, regionDialing: RegionCode) => boolean;
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).
Parameter number
the phone number to test
Parameter regionCode
the region where the phone number is being dialed whether the number might be used to connect to an emergency service in the given region
method getExpectedCost
getExpectedCost: (number: PhoneNumber) => ShortNumberInfo.ShortNumberCost;
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 ShortNumberInfo.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.
For example, if a number is STANDARD_RATE in the US, but TOLL_FREE in Canada, the expected cost returned by this method will be STANDARD_RATE, since the NANPA countries share the same country calling code.
Note: If the region from which the number is dialed is known, it is highly preferable to call ShortNumberInfo.getExpectedCostForRegion instead.
Parameter number
the short number for which we want to know the expected cost category the highest expected cost category of the short number in the region(s) with the given country calling code
method getExpectedCostForRegion
getExpectedCostForRegion: ( number: PhoneNumber, regionDialingFrom: RegionCode) => ShortNumberInfo.ShortNumberCost;
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 ShortNumberInfo.isValidShortNumberForRegion. Note that emergency numbers are always considered toll-free.
Parameter number
the short number for which we want to know the expected cost category
Parameter regionDialingFrom
the region from which the number is dialed the expected cost category for that region of the short number. Returns UNKNOWN_COST the number does not match a cost category. Note that an invalid number may match any cost category.
Example 1
Usage:
// The region for which the number was parsed and the region we subsequently check against// need not be the same. Here we parse the number in the US and check it for Canada.const phoneNumber = phoneUtil.parse("110", "US");const regionCode: RegionCode = '"CA"';const shortInfo = ShortNumberInfo.getInstance();if (shortInfo.isValidShortNumberForRegion(phoneNumber, regionCode)) {const cost = shortInfo.getExpectedCostForRegion(phoneNumber, regionCode);// Do something with the cost information here.}
method getInstance
static getInstance: () => ShortNumberInfo;
Returns the singleton instance of the ShortNumberInfo.
method isCarrierSpecific
isCarrierSpecific: (number: PhoneNumber) => boolean;
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 ShortNumberInfo.isValidShortNumber or ShortNumberInfo.isValidShortNumberForRegion.
Parameter number
the valid short number to check whether the short number is carrier-specific, assuming the input was a valid short number
method isCarrierSpecificForRegion
isCarrierSpecificForRegion: ( number: PhoneNumber, regionDialingFrom: RegionCode) => boolean;
Given a valid short number, determines whether it is carrier-specific when dialed from the given region (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 ShortNumberInfo.isValidShortNumber or ShortNumberInfo.isValidShortNumberForRegion. Returns false if the number doesn't match the region provided.
Parameter number
the valid short number to check
Parameter regionDialingFrom
the region from which the number is dialed whether the short number is carrier-specific in the provided region, assuming the input was a valid short number
method isEmergencyNumber
isEmergencyNumber: (number: string, regionCode: RegionCode) => boolean;
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)
impliesconnectsToEmergencyNumber(number, region)
.Parameter number
the phone number to test
Parameter regionCode
the region where the phone number is being dialed whether the number exactly matches an emergency services number in the given region
method isPossibleShortNumber
isPossibleShortNumber: (number: PhoneNumber) => boolean;
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 ShortNumberInfo.isValidShortNumber. See ShortNumberInfo.isPossibleShortNumberForRegion for details.
Parameter number
the short number to check whether the number is a possible short number
method isPossibleShortNumberForRegion
isPossibleShortNumberForRegion: ( number: PhoneNumber, regionDialingFrom: RegionCode) => boolean;
Check whether a short number is a possible number when dialed from the given region. This provides a more lenient check than ShortNumberInfo.isValidShortNumberForRegion.
Parameter number
the short number to check
Parameter regionDialingFrom
the region from which the number is dialed whether the number is a possible short number
method isSmsServiceForRegion
isSmsServiceForRegion: ( number: PhoneNumber, regionDialingFrom: string) => boolean;
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. If it is important that the number is valid, then its validity must first be checked using ShortNumberInfo.isValidShortNumber or ShortNumberInfo.isValidShortNumberForRegion. Returns false if the number doesn't match the region provided.
Parameter number
the valid short number to check
Parameter regionDialingFrom
the region from which the number is dialed whether the short number is an SMS service in the provided region, assuming the input was a valid short number
method isValidShortNumber
isValidShortNumber: (number: PhoneNumber) => boolean;
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 ShortNumberInfo.isValidShortNumberForRegion for details.
Parameter number
the short number for which we want to test the validity whether the short number matches a valid pattern
method isValidShortNumberForRegion
isValidShortNumberForRegion: ( number: PhoneNumber, regionDialingFrom: RegionCode) => boolean;
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.
Parameter number
the short number for which we want to test the validity
Parameter regionDialingFrom
the region from which the number is dialed whether the short number matches a valid pattern
class StringBuffer
class StringBuffer {}
constructor
constructor(opt_a1?: any, ...var_args: any[]);
method append
append: (a1: any, opt_a2?: any, ...var_args: any[]) => StringBuffer;
method toString
toString: () => string;
enum PhoneNumberFormat
enum PhoneNumberFormat { E164, INTERNATIONAL, NATIONAL, RFC3966,}
enum PhoneNumberType
enum PhoneNumberType { FIXED_LINE = 0, MOBILE = 1, FIXED_LINE_OR_MOBILE = 2, TOLL_FREE = 3, PREMIUM_RATE = 4, SHARED_COST = 5, VOIP = 6, PERSONAL_NUMBER = 7, PAGER = 8, UAN = 9, VOICEMAIL = 10, UNKNOWN = -1,}
member FIXED_LINE
FIXED_LINE = 0
member FIXED_LINE_OR_MOBILE
FIXED_LINE_OR_MOBILE = 2
member MOBILE
MOBILE = 1
member PAGER
PAGER = 8
member PERSONAL_NUMBER
PERSONAL_NUMBER = 7
member PREMIUM_RATE
PREMIUM_RATE = 4
member SHARED_COST
SHARED_COST = 5
member TOLL_FREE
TOLL_FREE = 3
member UAN
UAN = 9
member UNKNOWN
UNKNOWN = -1
member VOICEMAIL
VOICEMAIL = 10
member VOIP
VOIP = 6
type RegionCode
type RegionCode = | 'AC' | 'AD' | 'AE' | 'AF' | 'AG' | 'AI' | 'AL' | 'AM' | 'AO' | 'AR' | 'AS' | 'AT' | 'AU' | 'AW' | 'AX' | 'AZ' | 'BA' | 'BB' | 'BD' | 'BE' | 'BF' | 'BG' | 'BH' | 'BI' | 'BJ' | 'BL' | 'BM' | 'BN' | 'BO' | 'BQ' | 'BR' | 'BS' | 'BT' | 'BW' | 'BY' | 'BZ' | 'CA' | 'CC' | 'CD' | 'CF' | 'CG' | 'CH' | 'CI' | 'CK' | 'CL' | 'CM' | 'CN' | 'CO' | 'CR' | 'CU' | 'CV' | 'CW' | 'CX' | 'CY' | 'CZ' | 'DE' | 'DJ' | 'DK' | 'DM' | 'DO' | 'DZ' | 'EC' | 'EE' | 'EG' | 'EH' | 'ER' | 'ES' | 'ET' | 'FI' | 'FJ' | 'FK' | 'FM' | 'FO' | 'FR' | 'GA' | 'GB' | 'GD' | 'GE' | 'GF' | 'GG' | 'GH' | 'GI' | 'GL' | 'GM' | 'GN' | 'GP' | 'GQ' | 'GR' | 'GT' | 'GU' | 'GW' | 'GY' | 'HK' | 'HN' | 'HR' | 'HT' | 'HU' | 'ID' | 'IE' | 'IL' | 'IM' | 'IN' | 'IO' | 'IQ' | 'IR' | 'IS' | 'IT' | 'JE' | 'JM' | 'JO' | 'JP' | 'KE' | 'KG' | 'KH' | 'KI' | 'KM' | 'KN' | 'KP' | 'KR' | 'KW' | 'KY' | 'KZ' | 'LA' | 'LB' | 'LC' | 'LI' | 'LK' | 'LR' | 'LS' | 'LT' | 'LU' | 'LV' | 'LY' | 'MA' | 'MC' | 'MD' | 'ME' | 'MF' | 'MG' | 'MH' | 'MK' | 'ML' | 'MM' | 'MN' | 'MO' | 'MP' | 'MQ' | 'MR' | 'MS' | 'MT' | 'MU' | 'MV' | 'MW' | 'MX' | 'MY' | 'MZ' | 'NA' | 'NC' | 'NE' | 'NF' | 'NG' | 'NI' | 'NL' | 'NO' | 'NP' | 'NR' | 'NU' | 'NZ' | 'OM' | 'PA' | 'PE' | 'PF' | 'PG' | 'PH' | 'PK' | 'PL' | 'PM' | 'PR' | 'PS' | 'PT' | 'PW' | 'PY' | 'QA' | 'RE' | 'RO' | 'RS' | 'RU' | 'RW' | 'SA' | 'SB' | 'SC' | 'SD' | 'SE' | 'SG' | 'SH' | 'SI' | 'SJ' | 'SK' | 'SL' | 'SM' | 'SN' | 'SO' | 'SR' | 'SS' | 'ST' | 'SV' | 'SX' | 'SY' | 'SZ' | 'TA' | 'TC' | 'TD' | 'TG' | 'TH' | 'TJ' | 'TK' | 'TL' | 'TM' | 'TN' | 'TO' | 'TR' | 'TT' | 'TV' | 'TW' | 'TZ' | 'UA' | 'UG' | 'US' | 'UY' | 'UZ' | 'VA' | 'VC' | 'VE' | 'VG' | 'VI' | 'VN' | 'VU' | 'WF' | 'WS' | 'XK' | 'YE' | 'YT' | 'ZA' | 'ZM' | 'ZW';
type RegionCodeUnknown
type RegionCodeUnknown = 'ZZ';
namespace libphonenumber.PhoneNumber
namespace libphonenumber.PhoneNumber {}
enum CountryCodeSource
enum CountryCodeSource { FROM_NUMBER_WITH_PLUS_SIGN = 1, FROM_NUMBER_WITH_IDD = 5, FROM_NUMBER_WITHOUT_PLUS_SIGN = 10, FROM_DEFAULT_COUNTRY = 20,}
member FROM_DEFAULT_COUNTRY
FROM_DEFAULT_COUNTRY = 20
member FROM_NUMBER_WITH_IDD
FROM_NUMBER_WITH_IDD = 5
member FROM_NUMBER_WITH_PLUS_SIGN
FROM_NUMBER_WITH_PLUS_SIGN = 1
member FROM_NUMBER_WITHOUT_PLUS_SIGN
FROM_NUMBER_WITHOUT_PLUS_SIGN = 10
namespace libphonenumber.PhoneNumberUtil
namespace libphonenumber.PhoneNumberUtil {}
enum MatchType
enum MatchType { EXACT_MATCH, NO_MATCH, NOT_A_NUMBER, NSN_MATCH, SHORT_NSN_MATCH,}
member EXACT_MATCH
EXACT_MATCH
member NO_MATCH
NO_MATCH
member NOT_A_NUMBER
NOT_A_NUMBER
member NSN_MATCH
NSN_MATCH
member SHORT_NSN_MATCH
SHORT_NSN_MATCH
enum ValidationResult
enum ValidationResult { IS_POSSIBLE, INVALID_COUNTRY_CODE, TOO_SHORT, TOO_LONG, IS_POSSIBLE_LOCAL_ONLY, INVALID_LENGTH,}
member INVALID_COUNTRY_CODE
INVALID_COUNTRY_CODE
The number has an invalid country calling code. =1
member INVALID_LENGTH
INVALID_LENGTH
The number is longer than the shortest valid numbers for this region, shorter than the longest valid numbers for this region, and does not itself have a number length that matches valid numbers for this region. This can also be returned in the case where isPossibleNumberForTypeWithReason was called, and there are no numbers of this type at all for this region. =5
member IS_POSSIBLE
IS_POSSIBLE
The number length matches that of valid numbers for this region. =0
member IS_POSSIBLE_LOCAL_ONLY
IS_POSSIBLE_LOCAL_ONLY
The number length matches that of local numbers for this region only (i.e. numbers that may be able to be dialled within an area, but do not have all the information to be dialled from anywhere inside or outside the country). =4
member TOO_LONG
TOO_LONG
The number is longer than all valid numbers for this region. =3
member TOO_SHORT
TOO_SHORT
The number is shorter than all valid numbers for this region. =2
namespace libphonenumber.ShortNumberInfo
namespace libphonenumber.ShortNumberInfo {}
enum ShortNumberCost
enum ShortNumberCost { TOLL_FREE = 0, STANDARD_RATE = 1, PREMIUM_RATE = 2, UNKNOWN_COST = 3,}
Cost categories of short numbers.
member PREMIUM_RATE
PREMIUM_RATE = 2
member STANDARD_RATE
STANDARD_RATE = 1
member TOLL_FREE
TOLL_FREE = 0
member UNKNOWN_COST
UNKNOWN_COST = 3
Package Files (1)
Dependencies (0)
No dependencies.
Dev Dependencies (0)
No dev dependencies.
Peer Dependencies (0)
No peer dependencies.
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@types/google-libphonenumber
.
- Markdown[](https://www.jsdocs.io/package/@types/google-libphonenumber)
- HTML<a href="https://www.jsdocs.io/package/@types/google-libphonenumber"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 3734 ms. - Missing or incorrect documentation? Open an issue for this package.