is_uk_telephone_number: Is the string a valid UK telephone number?

Description Usage Arguments Value Note References Examples

Description

Checks that the input contains UK telephone numbers.

Usage

1
2
3
4
5
6
7
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)

Arguments

x

Input to check.

na_ignore

A logical value. If FALSE, NA values cause an error; otherwise they do not. Like na.rm in many stats package functions, except that the position of the failing values does not change.

severity

How severe should the consequences of the assertion be? Either "stop", "warning", "message", or "none".

Value

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.

Note

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.

References

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

Examples

1
2
3
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)

assertive.data.uk documentation built on May 2, 2019, 12:34 p.m.