Learn R Programming

catalytic (version 0.1.0)

validate_positive: Validate Positive or Non-negative Parameter

Description

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.

Usage

validate_positive(param_name, param_value, incl_0 = FALSE, is_vector = FALSE)

Value

NULL if validation passes; otherwise, an error is raised.

Arguments

param_name

A string representing the name of the parameter. Used in the error message.

param_value

The parameter value to validate, either a single numeric or a numeric vector.

incl_0

Logical, if TRUE, allows non-negative values (larger or equal to 0); if FALSE, requires positive values (larger than 0).

is_vector

Logical, if TRUE, treats param_value as a vector; otherwise, expects a single numeric value.