For each element of x
:
is_parsed(x)
: Was this successfully parsed?
is_valid(x)
: Is this a valid phone number?
is_possible(x)
: Is this a possible phone number? Return type depends on
detailed
.
is_parsed(x)
is_valid(x)
is_possible(x, detailed = FALSE, type = NULL)
A phone vector.
If FALSE
, is_possible
returns a logical vector. If
TRUE
, it returns a character vector with "IS_POSSIBLE"
or the reason
for failure. See Details section for possible return values.
If provided, checks if x
is possible for the given phone number type.
Possible return values for is_possible(x, detailed = TRUE)
:
"INVALID_COUNTRY_CODE"
: The number has an invalid country calling code.
"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.
"IS_POSSIBLE"
: The number length matches that of valid numbers for this
region.
"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).
"TOO_LONG"
: The number is longer than all valid numbers for this region.
"TOO_SHORT"
: The number is shorter than all valid numbers for this
region.
is_valid()
: PhoneNumberUtil.isValidNumber()
is_possible()
: PhoneNumberUtil.isPossibleNumber()
is_possible(detailed = TRUE)
: PhoneNumberUtil.isPossibleNumberWithReason()
is_possible(type = type)
: PhoneNumberUtil.isPossibleNumberForType()
is_possible(detailed = TRUE, type = type)
: PhoneNumberUtil.sPossibleNumberForTypeWthReason()
Other phone functions:
dialr-example
,
dialr-match
,
dialr-phone
,
dialr-region
,
dialr-type
,
dialr
x <- phone(c(0, 0123, "0412 345 678", "61412987654", "03 9123 4567", "+12015550123"), "AU")
is_parsed(x)
#> [1] FALSE TRUE TRUE TRUE TRUE TRUE
is_valid(x)
#> [1] FALSE FALSE TRUE TRUE TRUE TRUE
is_possible(x)
#> [1] FALSE FALSE TRUE TRUE TRUE TRUE
is_possible(x, detailed = TRUE)
#> [1] NA "TOO_SHORT" "IS_POSSIBLE" "IS_POSSIBLE" "IS_POSSIBLE"
#> [6] "IS_POSSIBLE"
is_possible(x, type = "MOBILE")
#> [1] FALSE FALSE TRUE TRUE TRUE TRUE
is_possible(x, detailed = TRUE, type = "MOBILE")
#> [1] NA "TOO_SHORT" "IS_POSSIBLE" "IS_POSSIBLE" "IS_POSSIBLE"
#> [6] "IS_POSSIBLE"