| assert_all_are_uk_telephone_numbers {assertive.data.uk} | R Documentation |
Checks that the input contains UK telephone numbers.
assert_all_are_uk_telephone_numbers(x, na_ignore = FALSE,
severity = getOption("assertive.severity", "stop"))
assert_any_are_uk_telephone_numbers(x, na_ignore = FALSE,
severity = getOption("assertive.severity", "stop"))
is_uk_telephone_number(x)
x |
Input to check. |
na_ignore |
A logical value. If |
severity |
How severe should the consequences of the assertion be?
Either |
is_uk_telephone_number returns TRUE if the input string
contains a valid UK telephone number. The assert_* function returns nothing
but throws an error when the is_* function returns FALSE.
The function doesn't guarantee that the phone number is in use, but checks that the format is correct, and that the area code exists. Spaces, hyphens and round brackets are allowed to appear in arbitrary places. The international UK prefix of 0044 or +44 is allowed.
The regex is adapted from one on the now defunct aa-asterisk.org.uk site with some additional consultation from https://en.wikipedia.org/wiki/List_of_United_Kingdom_dialling_codes
phone_nos <- c("+44 207 219 3475", "08457 90 90 90")
is_uk_telephone_number(phone_nos)
assert_all_are_uk_telephone_numbers(phone_nos)