Regions & codes
Constant
Section titled “Constant”| Name | Value | libphonenumber |
|---|---|---|
NF.REGION_CODE_FOR_NON_GEO_ENTITY | '001' | PhoneNumberUtil.REGION_CODE_FOR_NON_GEO_ENTITY |
Used for non-geographical entities (e.g. toll-free ranges) when working with NF.metadataForNonGeographicalRegion.
NF.getCountryCodeForRegion
Country calling code for a region.
Signatures
global static Integer getCountryCodeForRegion(String regionCode)Parameters
| Name | Type | Description |
|---|---|---|
regionCode | String | ISO region (e.g. US). |
Returns
Calling code (e.g. 1), or 0 if unknown.
Throws
None.
libphonenumber
PhoneNumberUtil.getCountryCodeForRegion(String)
Example
Integer cc = NF.getCountryCodeForRegion('US'); // 1NF.getRegionCodeForCountryCode
Main region for a country calling code.
Signatures
global static String getRegionCodeForCountryCode(Integer countryCallingCode)Parameters
| Name | Type | Description |
|---|---|---|
countryCallingCode | Integer | Calling code (e.g. 1). |
Returns
Region code, or ZZ if unknown.
Throws
None.
libphonenumber
PhoneNumberUtil.getRegionCodeForCountryCode(int)
Example
String region = NF.getRegionCodeForCountryCode(1); // "US"NF.getRegionCodesForCountryCode
All regions sharing a calling code (e.g. NANPA).
Signatures
global static List<String> getRegionCodesForCountryCode(Integer countryCallingCode)Parameters
| Name | Type | Description |
|---|---|---|
countryCallingCode | Integer | Calling code. |
Returns
List of region codes; may contain multiple entries.
Throws
None.
libphonenumber
PhoneNumberUtil.getRegionCodesForCountryCode(int)
Example
List<String> regions = NF.getRegionCodesForCountryCode(1);// includes "US", "CA", …NF.getRegionCodeForNumber
Region this phone number belongs to.
Signatures
global static String getRegionCodeForNumber(NF.Phone phone)Parameters
| Name | Type | Description |
|---|---|---|
phone | NF.Phone | Parsed number. |
Returns
Region code, or ZZ if unknown.
Throws
None.
libphonenumber
PhoneNumberUtil.getRegionCodeForNumber(PhoneNumber)
Example
String region = NF.getRegionCodeForNumber(phone); // "US"NF.getRegionCodeForNumberFromRegionList
Picks the matching region from a candidate list (shared calling codes).
Signatures
global static String getRegionCodeForNumberFromRegionList(NF.Phone phone, List<String> regionCodes)Parameters
| Name | Type | Description |
|---|---|---|
phone | NF.Phone | Parsed number. |
regionCodes | List<String> | Candidate regions to test. |
Returns
First matching region, or null.
Throws
None.
libphonenumber
Custom disambiguation (uses validation metadata)
Example
String region = NF.getRegionCodeForNumberFromRegionList( phone, new List<String>{ 'US', 'CA' });NF.getCountryMobileToken
Mobile token prefix for a country calling code (where applicable).
Signatures
global static String getCountryMobileToken(Integer countryCallingCode)Parameters
| Name | Type | Description |
|---|---|---|
countryCallingCode | Integer | Calling code. |
Returns
Token string (e.g. 9 for Argentina), or empty.
Throws
None.
libphonenumber
PhoneNumberUtil.getCountryMobileToken(int)
Example
String token = NF.getCountryMobileToken(54); // "9"NF.getNddPrefixForRegion
National direct dialling prefix for a region.
Signatures
global static String getNddPrefixForRegion(String regionCode, Boolean stripNonDigits)Parameters
| Name | Type | Description |
|---|---|---|
regionCode | String | Region. |
stripNonDigits | Boolean | Whether to strip non-digits from the prefix. |
Returns
NDD prefix or empty string.
Throws
None.
libphonenumber
PhoneNumberUtil.getNddPrefixForRegion(String, boolean)
Example
String ndd = NF.getNddPrefixForRegion('US', true);NF.getNationalSignificantNumber
National significant number (digits without country code).
Signatures
global static String getNationalSignificantNumber(NF.Phone phone)Parameters
| Name | Type | Description |
|---|---|---|
phone | NF.Phone | Parsed number. |
Returns
NSN string.
Throws
None.
libphonenumber
PhoneNumberUtil.getNationalSignificantNumber(PhoneNumber)
Example
String nsn = NF.getNationalSignificantNumber(phone); // "6502530000"NF.getLengthOfGeographicalAreaCode
Length of geographical area code for this number.
Signatures
global static Integer getLengthOfGeographicalAreaCode(NF.Phone phone)Parameters
| Name | Type | Description |
|---|---|---|
phone | NF.Phone | Parsed geographical number. |
Returns
Length in digits, or 0 if not geographical.
Throws
None.
libphonenumber
PhoneNumberUtil.getLengthOfGeographicalAreaCode(PhoneNumber)
Example
Integer len = NF.getLengthOfGeographicalAreaCode(phone);NF.getLengthOfNationalDestinationCode
Length of national destination code.
Signatures
global static Integer getLengthOfNationalDestinationCode(NF.Phone phone)Parameters
| Name | Type | Description |
|---|---|---|
phone | NF.Phone | Parsed number. |
Returns
Length in digits.
Throws
None.
libphonenumber
PhoneNumberUtil.getLengthOfNationalDestinationCode(PhoneNumber)
Example
Integer ndcLen = NF.getLengthOfNationalDestinationCode(phone);NF.isNANPACountry
Whether the region is in the North American Numbering Plan.
Signatures
global static Boolean isNANPACountry(String regionCode)Parameters
| Name | Type | Description |
|---|---|---|
regionCode | String | Region to test. |
Returns
true for NANPA countries (e.g. US, CA).
Throws
None.
libphonenumber
PhoneNumberUtil.isNANPACountry(String)
Example
Boolean nanpa = NF.isNANPACountry('US'); // trueNF.isMobileNumberPortableRegion
Whether mobile number portability applies in the region.
Signatures
global static Boolean isMobileNumberPortableRegion(String regionCode)Parameters
| Name | Type | Description |
|---|---|---|
regionCode | String | Region to test. |
Returns
true if MNP is supported.
Throws
None.
libphonenumber
PhoneNumberUtil.isMobileNumberPortableRegion(String)
Example
Boolean mnp = NF.isMobileNumberPortableRegion('US');NF.getSupportedRegions
All region codes with metadata.
Signatures
global static Set<String> getSupportedRegions()Parameters
Returns
Unmodifiable set of region codes.
Throws
None.
libphonenumber
PhoneNumberUtil.getSupportedRegions()
Example
Set<String> regions = NF.getSupportedRegions();NF.getSupportedCallingCodes
All supported country calling codes.
Signatures
global static Set<Integer> getSupportedCallingCodes()Parameters
Returns
Set of calling codes.
Throws
None.
libphonenumber
PhoneNumberUtil.getSupportedCallingCodes()
Example
Set<Integer> codes = NF.getSupportedCallingCodes();NF.getSupportedGlobalNetworkCallingCodes
Calling codes for global network (non-geographical) entities.
Signatures
global static Set<Integer> getSupportedGlobalNetworkCallingCodes()Parameters
Returns
Set of calling codes.
Throws
None.
libphonenumber
PhoneNumberUtil.getSupportedGlobalNetworkCallingCodes()
Example
Set<Integer> globalCodes = NF.getSupportedGlobalNetworkCallingCodes();NF.getSupportedTypesForRegion
Number types that exist for a region in metadata.
Signatures
global static Set<NF.NumberType> getSupportedTypesForRegion(String regionCode)Parameters
| Name | Type | Description |
|---|---|---|
regionCode | String | Region. |
Returns
Set of NF.NumberType values.
Throws
None.
libphonenumber
PhoneNumberUtil.getSupportedTypesForRegion(String)
Example
Set<NF.NumberType> types = NF.getSupportedTypesForRegion('US');NF.getSupportedTypesForNonGeoEntity
Number types for a non-geographical calling code.
Signatures
global static Set<NF.NumberType> getSupportedTypesForNonGeoEntity(Integer countryCallingCode)Parameters
| Name | Type | Description |
|---|---|---|
countryCallingCode | Integer | Non-geo calling code (e.g. 800). |
Returns
Set of types.
Throws
None.
libphonenumber
PhoneNumberUtil.getSupportedTypesForNonGeoEntity(int)
Example
Set<NF.NumberType> types = NF.getSupportedTypesForNonGeoEntity(800);NF.getExampleNumber
Example numbers for documentation, tests, and UI placeholders.
Signatures
global static NF.Phone getExampleNumber(String regionCode)Valid example for a region.
global static NF.Phone getInvalidExampleNumber(String regionCode)Intentionally invalid example for a region.
global static NF.Phone getExampleNumberForType(String regionCode, NF.NumberType typeValue)Example for a specific line type in a region.
global static NF.Phone getExampleNumberForType(NF.NumberType typeValue)Example for a type when region is implied by metadata.
global static NF.Phone getExampleNumberForNonGeoEntity(Integer countryCallingCode)Example for toll-free and other non-geographical entities.
Parameters
| Name | Type | Description |
|---|---|---|
regionCode | String | Region for regional examples. |
typeValue | NF.NumberType | Line type. |
countryCallingCode | Integer | Non-geo entity code. |
Returns
NF.Phone example, or null if none defined.
Throws
None.
libphonenumber
PhoneNumberUtil.getExampleNumber(…) family
Example
NF.Phone example = NF.getExampleNumber('US');NF.Phone tollFree = NF.getExampleNumberForType('US', NF.NumberType.TOLL_FREE);