The sv_equal() function compares the field value to a specified value with the == operator.

  message_fmt = "Must be equal to {rhs}.",
  allow_multiple = FALSE,
  allow_na = FALSE,
  allow_nan = FALSE,
  allow_inf = FALSE



The right hand side (RHS) value is to be used for the comparison with the field value. The validation check will effectively be of the form <field> == <rhs>.


The validation error message to use if the field fails the validation test. Use the "{rhs}" string parameter to customize the message, including what was set in rhs. While the default message uses this string parameter, it is not required in a user-defined message_fmt string.


If FALSE (the default), then the length of the input vector must be exactly one; if TRUE, then any length is allowed (including a length of zero; use sv_required() if one or more values should be required).


If FALSE (the default for both options), then any NA or NaN element will cause validation to fail.


If FALSE (the default for both options), then any NA or NaN element will cause validation to fail.


If FALSE (the default), then any Inf or -Inf element will cause validation to fail.


A function suitable for use as an InputValidator$add_rule() rule.

See also

The other comparison-based rule functions: sv_gt(), sv_gte(), sv_lt(), sv_lte(), and sv_not_equal() (which serves as the opposite function to sv_equal()).

Other rule functions: compose_rules(), sv_between(), sv_email(), sv_gte(), sv_gt(), sv_in_set(), sv_integer(), sv_lte(), sv_lt(), sv_not_equal(), sv_numeric(), sv_optional(), sv_regex(), sv_required(), sv_url()


## Only run examples in interactive R sessions
if (interactive()) {


ui <- fluidPage(
  textInput("number", "Number")

server <- function(input, output, session) {
  # Validation rules are set in the server, start by
  # making a new instance of an `InputValidator()`
  iv <- InputValidator$new()

  # Basic usage: `sv_equal()` requires a value
  # to compare against the field value; a message
  # will be shown if the validation of
  # `input$number` fails
  iv$add_rule("number", sv_equal(1))

  # Finally, `enable()` the validation rules

shinyApp(ui, server)