## Only run examples in interactive R sessions
if (interactive()) {
library(shiny)
library(shinyvalidate)
ui <- fluidPage(
textInput("count", "Count")
)
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_integer()` works well with its
# defaults; a message will be displayed if the
# validation of `input$count` fails
iv$add_rule("count", sv_integer())
# Finally, `enable()` the validation rules
iv$enable()
}
shinyApp(ui, server)
}
Run the code above in your browser using DataLab