phone_possible()checks length only (matchinglibphonenumber'sisPossibleNumber()): whether the number has a length that exists for its country calling code, including local-only numbers.phone_valid()checks the full numbering plan (matchinglibphonenumber'sisValidNumber()): country calling code, prefix digits and length.
A TRUE from phone_valid() means the number is well-formed under that
country's numbering plan. It does not mean the number was assigned or is
active.
Arguments
- x
A character vector of phone numbers (or a
dialtone_phonedata frame fromphone_parse()).- region
A single two-letter CLDR region code (such as
"US","GB"or"IN") giving the default country for numbers written without a leading+, orNULLwhen numbers carry an international+prefix.- strict
Logical scalar. When
FALSE(the default),regionis the default region used to parse national-format strings, and any valid international number returnsTRUE. WhenTRUE,regionmust be non-null and the number must also belong toregion(matchingisValidNumberForRegion()).
Value
A logical vector the same length as x: TRUE, FALSE, or NA
where x is NA. Malformed values return FALSE, never an error.
Examples
phone_possible(c("+1 650-253-0000", "+1 111-111-1111", "123", NA))
#> [1] TRUE TRUE FALSE NA
phone_valid(c("+1 650-253-0000", "+1 111-111-1111", "123", NA))
#> [1] TRUE FALSE FALSE NA
# National format requires a default region
phone_valid(c("020 7946 0192", "020 0000 0000"), region = "GB")
#> [1] TRUE TRUE
# strict = TRUE requires the number to belong to `region`
phone_valid(c("+1 650-253-0000", "+1 416-555-0199"), region = "US", strict = TRUE)
#> [1] TRUE FALSE