Skip to contents

Checks that every element of x is found in valid. NULL passes silently. Aborts with an informative error if invalid values are found.

Usage

check_enum(x, valid, arg = rlang::caller_arg(x))

Arguments

x

Character vector to validate, or NULL.

valid

Character vector of allowed values.

arg

Argument name for error messages. Defaults to the name of x in the calling frame.

Value

x invisibly.

Examples

check_enum("active", c("active", "inactive", "pending"))