v_numeric_range() returns a validator function that checks if a value
is a single numeric value within a specified range. This is useful as a
validator function for bounded numeric options in options managers created
with create_options_manager().
v_numeric_range(min = -Inf, max = Inf)A validator function that takes a value x and raises an error if:
x is not a single numeric value
x is less than min or greater than max
# Create a validator for values between 0 and 1
validator <- v_numeric_range(min = 0, max = 1)
# Valid inputs
validator(0.5)
validator(0)
validator(1)
# Invalid inputs (would raise errors)
try(validator(-0.1)) # below minimum
#> Error : must be between 0 and 1
try(validator(1.5)) # above maximum
#> Error : must be between 0 and 1
try(validator(c(0.5, 0.7))) # vector, not scalar
#> Error : must be a single numeric value