This function checks whether a parameter value is positive (or non-negative if incl_0
is set to TRUE
).
It can handle both single numeric values and vectors, and it raises an error with an informative
message if the validation fails.
validate_positive(param_name, param_value, incl_0 = FALSE, is_vector = FALSE)
NULL
if validation passes; otherwise, an error is raised.
A string representing the name of the parameter. Used in the error message.
The parameter value to validate, either a single numeric or a numeric vector.
Logical, if TRUE
, allows non-negative values (larger or equal to 0); if FALSE
, requires positive values (larger than 0).
Logical, if TRUE
, treats param_value
as a vector; otherwise, expects a single numeric value.