rlang icon indicating copy to clipboard operation
rlang copied to clipboard

Check helper for "list of" things

Open hadley opened this issue 8 months ago • 0 comments

Something that could replace code like this:

if (!is_bare_list(dots)) {
  stop_input_type(dots, "a list")
}

if (!is_named(dots)) {
  cli::cli_abort(
    "All components of {.arg ...} must be named.",
    call = error_call
  )
}

type_ok <- map_lgl(dots, function(x) is_atomic(x) || is.null(x))
if (any(!type_ok)) {
  cli::cli_abort(
    "All elements of {.code ...} must be either an atomic vector or NULL."
  )
}

hadley avatar Oct 31 '23 21:10 hadley