| sv_in_set | R Documentation |
The sv_in_set() function checks whether the field value is a member of a
specified set of values.
sv_in_set(
set,
message_fmt = "Must be in the set of {values_text}.",
set_limit = 3
)
set |
A vector or list of elements for which the field value must be a
part of ( |
message_fmt |
The validation error message to use if a value fails to
match the rule. The message can be customized by using the
|
set_limit |
The limit of |
A function suitable for use as an
InputValidator$add_rule() rule.
The sv_between() function, which tests whether a field values
between two boundary values.
Other rule functions:
compose_rules(),
sv_between(),
sv_email(),
sv_equal(),
sv_gte(),
sv_gt(),
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()) {
library(shiny)
library(shinyvalidate)
ui <- fluidPage(
textInput("rating", "Rating")
)
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_in_set()` requires a value
# set given as a vector; a message will be
# shown if the validation of `input$rating` fails
iv$add_rule("rating", sv_in_set(1:5))
# Finally, `enable()` the validation rules
iv$enable()
}
shinyApp(ui, server)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.