isPossibleNumberWithReason method

ValidationResult isPossibleNumberWithReason(
  1. PhoneNumber number
)

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 some numbers (particularly fixed-line), many regions have the concept of area code, which together with subscriber number constitute the national significant number. It is sometimes okay to dial only the subscriber number when dialing in the same area. This function will return [isPossibleLocalOnly] 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. [number] the number that needs to be checked [isPossibleNumberWithReason] returns a ValidationResult object which indicates whether the number is possible
  • Implementation

    ValidationResult isPossibleNumberWithReason(PhoneNumber number) {
      return isPossibleNumberForTypeWithReason(number, PhoneNumberType.unknown);
    }