Skip to contents

This function returns a standard error message for missing parameters.

Usage

dis_not_missing(.f, param = "x", call = rlang::caller_env(),
    fact_check = "global")

Arguments

.f

Required logical scalar; the output of missing(x)) or rlang::is_missing(x), substituting the parameter name passed to either function as needed.

param

Required character scalar; the parameter name. The default uses the variable name x, but this value can be set to a different static character scalar. Alternatively, you can use rlang::caller_arg() to pull the parameter name passed by the function dis_not_missing() is nested within. Regardless of the approach taken here, the resulting character scalar should match the object name passed to .f.

call

Required environment; the environment in which the function was called. If nesting dis_not_missing within another function, it is recommended to provide the calling environment to ensure the correct environment is referenced using rlang::caller_env() (default). If there are multiple levels of nesting, the call argument can be used to pass an environment created in the outermost function.

fact_check

Required character scalar; whether to override fact checking environment setting. If "global" (default), dis_character will follow the global setting. If "always", dis_character will ignore any global setting and will always check x. This argument is primarily intended for Shiny developers who wish to use disputeR in modules. See the vignette on vignette("developing", package = "disputeR") for details on how to use this function.

Value

This function will return either TRUE (if the input passes all validation checks) or an error message.

Details

See the vignette on vignette("developing", package = "disputeR") for details about internal validation of arguments for this function.

Examples

# create example function that uses dis_param()
example <- function(x){
  dis_not_missing(.f = rlang::is_missing(x))
}

# example function
example(x = "test")
#> [1] TRUE

# create example function that uses dis_param() with different variable name
example <- function(var){
  dis_not_missing(.f = rlang::is_missing(var), param = "var")
}

# example function
example(var = "test")
#> [1] TRUE