assert_character_vector: Is an Argument a Character Vector?

Description Usage Arguments Value Author(s) Examples

View source: R/assertions.R

Description

Checks if an argument is a character vector

Usage

1
assert_character_vector(arg, values = NULL, optional = FALSE)

Arguments

arg

A function argument to be checked

values

A character vector of valid values for arg

optional

Is the checked parameter optional? If set to FALSE and arg is NULL then an error is thrown

Value

The function throws an error if arg is not a character vector or if any element is not included in the list of valid values. Otherwise, the input is returned invisibly.

Author(s)

Thomas Neitmann

Examples

1
2
3
4
5
6
7
example_fun <- function(chr) {
  assert_character_vector(chr)
}

example_fun(letters)

try(example_fun(1:10))

epijim/admiral documentation built on Feb. 13, 2022, 12:15 a.m.