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

v_character_scalar()

Value

A validator function that takes a value x and raises an error if:

  • x is not a single character value

  • x is an empty string

Examples

# Create a validator for non-empty character scalars
validator <- v_character_scalar()

# Valid input
validator("hello")

# Invalid inputs (would raise errors)
try(validator(c("hello", "world")))  # vector, not scalar
#> Error : must be a single character value
try(validator(123))  # numeric, not character
#> Error : must be a single character value