validate_fraction: Validate fraction values (0-1 range)

View source: R/11.0-core-validators.R

validate_fractionR Documentation

Validate fraction values (0-1 range)

Description

Specialized validator for fraction/proportion values.

Usage

validate_fraction(
  value,
  param_name,
  strategy = "strict",
  allow_zero = TRUE,
  allow_one = TRUE
)

Arguments

value

Value(s) to validate

param_name

Parameter name

strategy

Handling strategy

allow_zero

Whether zero is allowed

allow_one

Whether one is allowed

Value

An object of class fb4_validation (see validation_result). valid is TRUE when all values lie within [0, 1] (or the bounds set by allow_zero and allow_one). Out-of-range values are recorded in errors (strategy "strict") or warnings (strategy "warn").

Examples

validate_fraction(0.5, "diet_proportion")
validate_fraction(c(0.3, 0.7), "fractions")

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