Skip to contents

Create the default message used when a parameter is found to be a length greater than 1 (i.e. not a scalar).

Usage

dis_msg_scalar(class, stem, param = "param", call = rlang::caller_env())

Arguments

class

Required character scalar; the expected class of an object.

stem

Required character scalar; the end of the error message containing an example of how to correctly format the input. For example, if you require a numeric scalar, you should include stem = "{.code {param} = 1}.". See the documentation for the cli package to find other formatting examples.

param

Required character scalar; the parameter name. The default matches the argument named for environments used through disputeR.

call

Required environment; the environment in which the function was called. If nesting dis_msg_class() 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.

Value

A character string with the default message.

Details

See the vignette on vignette("developing", package = "disputeR") for details about internal validation of arguments for this function. Unlike the core functions, dis_param does not have a fact_check argument. The vignette("developing", package = "disputeR") vignette includes details on how to implement that functionality around dis_param.

Examples

dis_msg_scalar(class = "integer", stem = "{.code {param} = 1}")
#>                                                                                                        
#> "{.arg {param}} must have a length of {.code 1} (i.e. a scalar), not a length of {.code {length(x)}}." 
#>                                                                                                      i 
#>                      "Provide a {.cls integer} scalar for {.arg {param}}, such as {.code {param} = 1}"