dialr-valid: Phone number validity checks

dialr-validR Documentation

Phone number validity checks

Description

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.

Usage

is_parsed(x)

is_valid(x)

is_possible(x, detailed = FALSE, type = NULL)

Arguments

x

A phone vector.

detailed

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.

type

If provided, checks if x is possible for the given phone number type.

Details

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.

libphonenumber reference

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()

See Also

Other phone functions: dialr-example, dialr-match, dialr-phone, dialr-region, dialr-type, dialr

Examples

  x <- phone(c(0, 0123, "0412 345 678", "61412987654", "03 9123 4567", "+12015550123"), "AU")

  is_parsed(x)
  is_valid(x)

  is_possible(x)
  is_possible(x, detailed = TRUE)

  is_possible(x, type = "MOBILE")
  is_possible(x, detailed = TRUE, type = "MOBILE")

dialr documentation built on Oct. 17, 2023, 1:11 a.m.