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