validate_positive: Validate Positive or Non-negative Parameter

validate_positiveR Documentation

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)

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.

Value

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


catalytic documentation built on April 4, 2025, 5:51 a.m.