Validation
Validation methods operate on an NF.Phone (from NF.parse) or, for string overloads, on raw text without parsing first.
NF.isValid
Returns whether a parsed number is valid for its region and number type.
Signatures
global static Boolean isValid(NF.Phone phone)Parameters
| Name | Type | Description |
|---|---|---|
phone | NF.Phone | Parsed number. Must not be null. |
Returns
true if the number is a valid phone number; false otherwise.
Throws
None.
libphonenumber
PhoneNumberUtil.isValidNumber(PhoneNumber)
Example
NF.Phone phone = NF.parse(contact.Phone, 'US');if (NF.isValid(phone)) { contact.Phone = NF.format(phone, NF.Format.E164);}NF.isValidForRegion
Returns whether the number is valid and belongs to the given region.
Signatures
global static Boolean isValidForRegion(NF.Phone phone, String regionCode)Parameters
| Name | Type | Description |
|---|---|---|
phone | NF.Phone | Parsed number. |
regionCode | String | ISO region to test (e.g. US). |
Returns
true if valid for that region.
Throws
None.
libphonenumber
PhoneNumberUtil.isValidNumberForRegion(PhoneNumber, String)
Example
NF.Phone phone = NF.parse('650-253-0000', 'US');Boolean usNumber = NF.isValidForRegion(phone, 'US'); // trueNF.isPossible
Checks whether a number has a possible length and structure (weaker than valid).
Signatures
global static Boolean isPossible(NF.Phone phone)Use when you already parsed the value. No parsing overhead.
global static Boolean isPossible(String rawNumber, String defaultRegion)Use on Lead import or web-form fields without calling NF.parse first. Parses internally, then checks possibility.
Parameters
Parameters depend on the signature; see Signatures above.
| Name | Type | Description |
|---|---|---|
phone | NF.Phone | Parsed number (isPossible(NF.Phone)). |
rawNumber | String | Raw text (isPossible(String, String)). |
defaultRegion | String | Region when no + is present (string overload). |
Returns
true if the number is possible; does not guarantee validity.
Throws
The isPossible(String, String) signature may throw NF.ParseException if parsing fails internally.
libphonenumber
PhoneNumberUtil.isPossibleNumber(PhoneNumber) / isPossibleNumber(CharSequence, String)
Example
// String overload: quick check on a dirty import rowBoolean possible = NF.isPossible('+1 650-253-0000', 'US'); // true
// Phone overload: after parseNF.Phone phone = NF.parse(contact.Phone, 'US');Boolean possibleParsed = NF.isPossible(phone); // trueNF.isPossibleForType
Checks whether the number is possible for a specific line type.
Signatures
global static Boolean isPossibleForType(NF.Phone phone, NF.NumberType typeValue)Parameters
| Name | Type | Description |
|---|---|---|
phone | NF.Phone | Parsed number. |
typeValue | NF.NumberType | Type to test (e.g. MOBILE). See Types. |
Returns
true if possible for that type.
Throws
None.
libphonenumber
PhoneNumberUtil.isPossibleNumberForType(PhoneNumber, PhoneNumberType)
Example
NF.Phone phone = NF.parse('+1 650-253-0000', 'US');Boolean ok = NF.isPossibleForType(phone, NF.NumberType.FIXED_LINE_OR_MOBILE);NF.possibleReason
Returns why a number is only possible, or confirms it is possible.
Signatures
global static NF.ValidationResult possibleReason(NF.Phone phone)Parameters
| Name | Type | Description |
|---|---|---|
phone | NF.Phone | Parsed number. |
Returns
NF.ValidationResult; typically IS_POSSIBLE or a failure reason. See Types.
Throws
None.
libphonenumber
PhoneNumberUtil.isPossibleNumberWithReason(PhoneNumber)
Example
NF.ValidationResult reason = NF.possibleReason(phone);// reason → NF.ValidationResult.IS_POSSIBLENF.possibleReasonForType
Like NF.possibleReason, scoped to a number type.
Signatures
global static NF.ValidationResult possibleReasonForType(NF.Phone phone, NF.NumberType typeValue)Parameters
| Name | Type | Description |
|---|---|---|
phone | NF.Phone | Parsed number. |
typeValue | NF.NumberType | Type to evaluate. |
Returns
Throws
None.
libphonenumber
PhoneNumberUtil.isPossibleNumberForTypeWithReason(PhoneNumber, PhoneNumberType)
Example
NF.ValidationResult r = NF.possibleReasonForType(phone, NF.NumberType.MOBILE);NF.typeOf
Classifies a valid number (mobile, fixed line, toll-free, etc.).
Signatures
global static NF.NumberType typeOf(NF.Phone phone)Parameters
| Name | Type | Description |
|---|---|---|
phone | NF.Phone | Parsed number. |
Returns
NF.NumberType; e.g. MOBILE, FIXED_LINE_OR_MOBILE, UNKNOWN.
Throws
None.
libphonenumber
PhoneNumberUtil.getNumberType(PhoneNumber)
Example
NF.NumberType lineType = NF.typeOf(phone);// lineType → NF.NumberType.FIXED_LINE_OR_MOBILE (US example)NF.isGeographical
Returns whether a number or type is geographical (area-code based).
Signatures
global static Boolean isGeographical(NF.Phone phone)Classifies a parsed number.
global static Boolean isGeographical(NF.NumberType typeValue, Integer countryCallingCode)Classifies a type and calling code without a parsed number (e.g. routing rules).
Parameters
Parameters depend on the signature; see Signatures above.
| Name | Type | Description |
|---|---|---|
phone | NF.Phone | Parsed number (isGeographical(NF.Phone)). |
typeValue | NF.NumberType | Number type (isGeographical(NF.NumberType, Integer)). |
countryCallingCode | Integer | Country calling code (type + code overload). |
Returns
true if geographical.
Throws
None.
libphonenumber
PhoneNumberUtil.isNumberGeographical(PhoneNumber) / isNumberGeographical(PhoneNumberType, int)
Example
Boolean geo = NF.isGeographical(phone);
Boolean mobileGeo = NF.isGeographical(NF.NumberType.MOBILE, 1); // false for US mobileNF.isAlphaNumber
Returns whether the string contains alphabetic characters as used in vanity numbers.
Signatures
global static Boolean isAlphaNumber(String value)Parameters
| Name | Type | Description |
|---|---|---|
value | String | Raw phone text. |
Returns
true if the string is considered an alpha number.
Throws
None.
libphonenumber
PhoneNumberUtil.isAlphaNumber(CharSequence)
Example
Boolean vanity = NF.isAlphaNumber('1800 MICROSOFT'); // trueNF.isNumberMatch
Compares two numbers for equality at various strictness levels.
Signatures
global static NF.MatchType isNumberMatch(NF.Phone first, NF.Phone second)Compare two parsed values (e.g. duplicate detection after normalization).
global static NF.MatchType isNumberMatch(String first, String second)Compare two raw strings with default parsing. Useful in batch dedup without building NF.Phone objects.
global static NF.MatchType isNumberMatch(NF.Phone first, String second)Compare stored parsed value against user input or import text.
Parameters
Returns
NF.MatchType (e.g. EXACT_MATCH, NSN_MATCH, NO_MATCH). See Types.
Throws
Signatures that take String arguments may throw NF.ParseException.
libphonenumber
PhoneNumberUtil.isNumberMatch(…) (overloads)
Example
// Phone + String: stored E.164 vs user-typed displayNF.Phone stored = NF.parse('+16502530000', 'US');NF.MatchType match = NF.isNumberMatch(stored, '+1 650-253-0000');// match → EXACT_MATCH
// String + String: import dedup without explicit parseNF.MatchType raw = NF.isNumberMatch('650-253-0000', '(650) 253-0000');// raw → EXACT_MATCH (with default region applied during parse)
// Phone + PhoneNF.MatchType both = NF.isNumberMatch(stored, stored.copy());// both → EXACT_MATCHNF.truncateTooLongNumber
Truncates a number that is too long to fit metadata rules, mutating the passed NF.Phone.
Signatures
global static Boolean truncateTooLongNumber(NF.Phone phone)Parameters
| Name | Type | Description |
|---|---|---|
phone | NF.Phone | Parsed number to truncate in place. |
Returns
true if truncation was applied.
Throws
None.
libphonenumber
PhoneNumberUtil.truncateTooLongNumber(PhoneNumber)
Example
NF.Phone phone = NF.parse(longInput, 'US');if (NF.truncateTooLongNumber(phone)) { // phone national number was shortened}NF.canBeInternationallyDialled
Returns whether the number can be dialled from outside its home country.
Signatures
global static Boolean canBeInternationallyDialled(NF.Phone phone)Parameters
| Name | Type | Description |
|---|---|---|
phone | NF.Phone | Parsed number. |
Returns
true if international dialling is allowed for this number.
Throws
None.
libphonenumber
PhoneNumberUtil.canBeInternationallyDialled(PhoneNumber)
Example
NF.Phone phone = NF.parse('+1 650-253-0000', 'US');Boolean intl = NF.canBeInternationallyDialled(phone); // true