| sv_url | R Documentation |
A validation function, suitable for use with InputValidator$add_rule(),
that checks whether an input value is a valid URL.
sv_url(message = "Not a valid URL", allow_multiple = FALSE, allow_na = FALSE)
message |
The validation error message to use if a value doesn't match a regex pattern for URL detection. |
allow_multiple |
If |
allow_na |
If |
A function suitable for use as an
InputValidator$add_rule() rule.
The sv_email() function, another specialized regex-based function
for validating email addresses. For general regex-based validation the
sv_regex() function is useful.
Other rule functions:
compose_rules(),
sv_between(),
sv_email(),
sv_equal(),
sv_gte(),
sv_gt(),
sv_in_set(),
sv_integer(),
sv_lte(),
sv_lt(),
sv_not_equal(),
sv_numeric(),
sv_optional(),
sv_regex(),
sv_required()
## 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)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.