types-check
Installation
SKILL.md
Input validation in R functions
This skill describes tidyverse style for validating function inputs. It focuses on rlang's exported type checkers along with the standalone file of check_* functions. These functions are carefully designed to produce clear, actionable error messages:
check_string(123)
#> Error: `123` must be a single string, not the number 123.
check_number_whole(3.14, min = 1, max = 10)
#> Error: `3.14` must be a whole number, not the number 3.14.
It assumes that the user has already run usethis::use_standalone("r-lib/rlang", "types-check"), and imports rlang in their package. If not, confirm with the user before continuing.
Function reference
Scalars (single values)
Use scalar checkers when arguments parameterise the function (configuration flags, names, single counts), rather than represent vectors of user data. They all assert a single value.