check_numeric_value: Check Numeric Value

View source: R/11.1-basic-validators.R

check_numeric_valueR Documentation

Check Numeric Value

Description

Fast validation of numeric values with basic range checking. Simplified utility function for common validation needs.

Usage

check_numeric_value(value, name, min_val = -Inf, max_val = Inf)

Arguments

value

Value to validate

name

Parameter name for error messages

min_val

Minimum allowed value (default -Inf)

max_val

Maximum allowed value (default Inf)

Details

Performs essential validations:

  • Not NULL

  • Numeric type

  • Finite values (no NA, NaN, Inf)

  • Within specified range

Value

The original value (numeric, same length as input), returned unchanged when all checks pass. Throws an error if value is NULL, non-numeric, contains non-finite elements (NA, NaN, Inf), or falls outside [min_val, max_val].

Examples

check_numeric_value(5, "weight")
try(check_numeric_value(-1, "weight", min_val = 0))
try(check_numeric_value(NA, "weight"))

fb4package documentation built on May 8, 2026, 1:07 a.m.