input_check_response: Standardized response to an input check

View source: R/input_check_response.R

input_check_responseR Documentation

Standardized response to an input check

Description

This function provides standardized responses to input checks, ensuring consistency.

Usage

input_check_response(
  check,
  var_name = NULL,
  error = TRUE,
  prefix = "Input {.var {var_name}} is bad:"
)

Arguments

check

[TRUE | character(1)]
Matches the return value of the ⁠check*⁠ functions from the {checkmate} package, i.e., either TRUE if the check was successful, or a character (the error message) else.

var_name

[NULL | character(1)]
Optionally specifies the name of the input being checked. This name will be used for the default value of the prefix argument.

error

[logical(1)]
If check is not TRUE, throw an error?

prefix

[character(1)]
A prefix for the thrown error message, if check is not TRUE and error is TRUE.

Value

TRUE if check is TRUE. If check is not TRUE, depending on error:

  • If error is TRUE, throws an error.

  • If error is FALSE, returns FALSE.

See Also

Other package helpers: Dictionary, Storage, identical_structure(), match_arg(), package_logo(), print_data.frame(), print_matrix(), renv_development_packages(), system_information(), unexpected_error(), user_confirm()

Examples

x <- "1"
y <- 1

### check is successful
input_check_response(
  check = checkmate::check_character(x),
  var_name = "x",
  error = TRUE
)

### standardized check response
## Not run: 
input_check_response(
  check = checkmate::check_character(y),
  var_name = "y",
  error = TRUE
)

## End(Not run)

oeli documentation built on Oct. 16, 2024, 5:08 p.m.