CRAN R build status Lifecycle: maturing


shinyvalidate adds input validation capabilities to Shiny.


Install the latest CRAN release:


Or, you can install the latest development version from GitHub using the remotes package.


Basic usage

To add validation to your Shiny app, you need to:

  1. Create an InputValidator object: iv <- InputValidator$new()

  2. Add one or more validation rules to the InputValidator: iv$add_rule("title", sv_required())

  3. Turn the validator on: iv$enable()

That’s all you need to do to get validation messages to show up. Here is a simple example:

Screencast of empty 'Name' and 'Email' fields showing error messages beneath them, and the user providing valid input that clears the errors


ui <- fluidPage(
  textInput("name", "Name"),
  textInput("email", "Email")

server <- function(input, output, session) {
  iv <- InputValidator$new()
  iv$add_rule("name", sv_required())
  iv$add_rule("email", sv_required())
  iv$add_rule("email", sv_email())

shinyApp(ui, server)

To learn about other features of shinyvalidate, including deferred validation, programmatically accessing validation results, and validating Shiny modules, see Introduction to shinyvalidate.

Input widget compatibility

shinyvalidate should work with all of the inputs that are included in Shiny. It will also work with most custom inputs that follow Bootstrap 3 or 4 conventions. Other types of custom inputs can include their own logic for displaying shinyvalidate error messages; see the article Displaying validation errors to learn more.

Prior art