R/check_list.R

Defines functions check_is_list

Documented in check_is_list

#' Help function checking if a variable is a list.
#'
#' @inherit .check_params params author return seealso
#'
#' @keywords internal
#'
check_is_list <- function(x,
                          error = FALSE) {

  # check if input error is boolean vector of length 1
  check_is_scalar_boolean(x = error,
                          error = TRUE)

  if (!rlang::is_bare_list(x = x)) {

    if (error == TRUE) {

      # error if lst is not a list
      cli::cli_abort( # nolint: return_linter
        c(
          "x" = "{.arg {rlang::caller_arg(x)}} is not a list!"
        ),
        call = rlang::caller_env(),
        wrap = TRUE
      )

    } else {

      return(FALSE)

    }

  } else {

    return(TRUE)

  }

}

Try the OlinkAnalyze package in your browser

Any scripts or data that you put into this service are public.

OlinkAnalyze documentation built on June 24, 2026, 1:06 a.m.