Check that a vector conforms to a certain pattern.
chk_regex(x, pattern)
chk_max_length(x, len)
A vector to check.
A str_detect() pattern to match.
Maximum string length.
A logical vector flagging records that have passed or failed the check.
Other vector checks:
chk-dates
,
chk-dummy
,
chk-labels
,
chk-text
,
chk-uniqueness
,
chk-values
x <- c("a_1", "b_2", "c_2", NA, "NULL")
chk_regex(x, "[a-z]_[0-9]")
#> [1] TRUE TRUE TRUE TRUE FALSE
chk_max_length(x, 3)
#> [1] TRUE TRUE TRUE TRUE FALSE