Learn R Programming

assertive.data.uk (version 0.0-2)

assert_all_are_uk_car_licences: Is the string a valid UK car licence plate number?

Description

Checks that the input contains UK car licence plate numbers.

Usage

assert_all_are_uk_car_licences(x, na_ignore = FALSE,
  severity = getOption("assertive.severity", "stop"))

assert_any_are_uk_car_licences(x, na_ignore = FALSE, severity = getOption("assertive.severity", "stop"))

assert_all_are_uk_car_licenses(x, na_ignore = FALSE, severity = getOption("assertive.severity", "stop"))

assert_any_are_uk_car_licenses(x, na_ignore = FALSE, severity = getOption("assertive.severity", "stop"))

is_uk_car_licence(x)

is_uk_car_license(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_national_insurance_number returns TRUE if the input string contains a valid UK car licence plate number The assert_* function returns nothing but throw an error when the is_* function returns FALSE.

References

Regex taken from http://www.regexlib.com/REDetails.aspx?regexp_id=527.

Examples

Run this code
# NOT RUN {
licences <- c(
  #1903 to 1931
  "A 1", "AA 9999",                   #ok
  "A 01",                             #zero prefix on number
  "S0", "G0", "RG0", "LM0",           #ok, special plates
  #1931 to 1963
  "AAA 1", "AAA 999",                 #ok
  "III 1", "QQQ 1", "ZZZ 1",          #disallowed letters
  "AAA 01",                           #zero prefix on number
  #1931 to 1963 alt
  "1 AAA", "9999 AAA",                #ok
  "1 III", "1 QQQ", "1 ZZZ",          #disallowed letters
  "01 AAA",                           #zero prefix on number
  #1963 to 1982
  "AAA 1A", "AAA 999A",               #ok
  "AAA 1I", "AAA 1O", "AAA 1Q",       #disallowed letters
  "AAA 1U", "AAA 1Z", 
  "AAA 01A",                          #zero prefix on number
  #1982 to 2001
  "A1 AAA", "A999 AAA",               #ok    
  "I1 AAA", "O1 AAA",                 #disallowed letters
  "U1 AAA", "Z1 AAA",
  "A01 AAA",                          #zero prefix on number
  #2001 to 2051
  "AA00 AAA", "AA99 AAA",             #ok
  "II00 AAA", "QQ00 AAA", "ZZ00 AAA", #disallowed letters
  "AA00 III", "AA00 QQQ"
)
is_uk_car_licence(licences)
assert_any_are_uk_car_licences(licences)
#These examples should fail.
assertive.base::dont_stop(assert_all_are_uk_car_licences(licences))
# }

Run the code above in your browser using DataLab