Skip to contents

A wrapper around validated_reactive_val() that uses stbl::stabilize_chr() to validate and coerce its value. This is a convenience function that constructs the validation_expr for you.

Usage

vrv_chr(
  value = NULL,
  default = NULL,
  allow_null = TRUE,
  allow_na = TRUE,
  min_size = NULL,
  max_size = NULL,
  regex = NULL,
  label = NULL,
  env = rlang::caller_env()
)

vrv_chr_scalar(
  value = NULL,
  default = NULL,
  label = NULL,
  allow_null = TRUE,
  allow_zero_length = TRUE,
  allow_na = TRUE,
  regex = NULL,
  env = rlang::caller_env()
)

Arguments

value

(various) The initial value. This value will be coerced via the validation expression when accessed. If this value is reactive, an observer with priority = Inf will be created to attempt to keep the validated value in sync with that reactive.

default

(various, including expression or reactive expression) A value to use when the current value is not valid according to the defined rules. Defaults to NULL.

allow_null

(length-1 logical, expression, or reactive expression) Is NULL an acceptable value?

allow_na

(length-1 logical, expression, or reactive expression) Are NA values okay?

min_size

(length-1 integer, expression, or reactive expression) The minimum size of the vector.

max_size

(length-1 integer, expression, or reactive expression) The maximum size of the vector.

regex

(character, expression, or reactive expression) One or more regular expressions to test against the values. See stbl::stabilize_chr() for details.

label

(length-1 character or NULL) An optional label for the validated_reactive_value, used for debugging.

env

(environment) The environment in which to evaluate the validation_expr.

allow_zero_length

(length-1 logical, expression, or reactive expression) Is a zero-length vector acceptable?

Value

A vrv object which returns a validated character vector.