Skip to contents

Check the type and properties of a variable

Usage

check_type(
  x,
  type,
  patt = NULL,
  check_fn = NULL,
  description = NULL,
  nullable = FALSE,
  can_be_empty = FALSE,
  allow.na = FALSE,
  ignore.case = FALSE
)

Arguments

x

[any] The variable to check.

type

[character] The expected type of the variable.

patt

[character(1)] A regular expression pattern to match against.

check_fn

[function(1)] A custom function to check the variable.

description

[character(1)] A description of the checks being performed when using patt or check_fn.

nullable

[logical(1)] A logical value indicating whether the variable can be NULL.

can_be_empty

[logical(1)] A logical value indicating whether the variable can be empty.

allow.na

[logical(1)] A logical value indicating whether NA values are allowed. When all is NA, the variable is considered valid if allow.na is TRUE.

ignore.case

[logical(1)] A logical value indicating whether to ignore case when matching when using patt.

Value

[logical(1)|character(1)] TRUE if the variable passes all checks, an error message otherwise.