Creation of Input Validator Objects

The shinyvalidate package offers an InputValidator R6 class for adding real-time input validation to Shiny apps. The Shiny app author can then add validation rules for each input field in their UI, using the InputValidator$add_rule() method. If an app contains multiple, independant forms then multiple InputValidator instances (with their own rules) can be created.

InputValidator

Shiny validation object

input_provided()

Check whether an input value has been provided

skip_validation()

Skip any normal validation performed by a rule

Rule Functions

The shinyvalidate rule functions are used to perform the checking of input fields and they are assigned to and managed by a Validator object. This variety of sv_*() functions can be used to make comparison-type validations (e.g., is the input less than 10?), verify that an email address has a valid construction, or check whether a value is even present. The compose_rules() function gives us the opportunity to combine multiple sv_*() functions (and even custom validation functions) such that the first failing validation will issue the failure message.

sv_numeric()

Validate that a field is a number

sv_integer()

Validate that a field is a number that is integer-like

sv_between()

Validate that a field is a number bounded by minimum and maximum values

sv_regex()

Validate that a field matches a regular expression

sv_email()

Validate that a field contains an email address

sv_url()

Validate that a field contains a URL

sv_gt()

Validate that a field is greater than a specified value

sv_gte()

Validate that a field is greater than or equal to a specified value

sv_lte()

Validate that a field is less than or equal to a specified value

sv_lt()

Validate that a field is less than a specified value

sv_equal()

Validate that a field is equal to a specified value

sv_not_equal()

Validate that a field is not equal to a specified value

sv_in_set()

Validate that a field is part of a defined set

sv_required()

Validate that the field is present

sv_optional()

Indicate that a field is optional

compose_rules()

Combine shinyvalidate rule functions