v_numeric_scalar() returns a validator function that checks if a value is a single numeric value. This is useful as a validator function for options managers created with create_options_manager().

v_numeric_scalar()

Value

A validator function that takes a value x and raises an error if x is not a single numeric value.

Examples

# Create a validator for numeric scalars
validator <- v_numeric_scalar()

# Valid input
validator(42)

# Invalid inputs (would raise errors)
try(validator(c(1, 2, 3))) # vector, not scalar
#> Error : must be a single numeric value
try(validator("text")) # not numeric
#> Error : must be a single numeric value