field_length: Check number of code points

View source: R/genericrules.R

field_lengthR Documentation

Check number of code points

Description

A convenience function testing for field length.

Usage

field_length(x, n = NULL, min = NULL, max = NULL, ...)

Arguments

x

Bare (unquoted) name of a variable. Otherwise a vector of class character. Coerced to character as necessary.

n

Number of code points required.

min

Mimimum number of code points

max

Maximum number of code points

...

passed to nchar (for example type="width")

Value

A [logical] of size length(x).

Details

The number of code points (string length) may depend on current locale settings or encoding issues, including those caused by inconsistent choices of UTF normalization.

See Also

Other format-checkers: field_format(), number_format()

Examples


df <- data.frame(id = 11001:11003, year = c("2018","2019","2020"), value = 1:3)
rule <- validator(field_length(year, 4), field_length(id, 5))
out <- confront(df, rule) 
as.data.frame(out)


validate documentation built on July 4, 2024, 9:07 a.m.