Skip to contents

This function runs standard unit tests on a character argument that should resolve to a specific directory.

Usage

dis_dir(x, null_valid = TRUE, error = TRUE, param = NULL,
    call = NULL, fact_check = "global")

Arguments

x

Required object; a parameter argument to test.

null_valid

Required logical scalar; whether the parameter can be NULL. If FALSE, the function will throw an error if x is NULL. Default is TRUE.

error

Required logical scalar; whether the function should error if the path is not found. If TRUE (default), the function will throw an error if x is not found. If FALSE, the function will create a directory at the given path instead of erroring.

param

Optional character scalar; the parameter name. If NULL (default), the function will attempt to determine the parameter name from the calling environment. If nesting functions, it is recommended to provide the parameter name to ensure the correct parameter is referenced using rlang::caller_arg().

call

Optional environment; the environment in which the function was called. If NULL (default), the function will attempt to determine the calling environment. If nesting functions, it is recommended to provide the calling environment to ensure the correct environment is referenced using rlang::caller_env().

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). If it does not pass all validation tests, it will return an error message if error = TRUE or a message about the creation of a directory if error = FALSE. Note that, if the input is NULL and null_valid is set to TRUE, the detailed unit tests are skipped and the function will return TRUE.

Details

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