sv_not_equal {shinyvalidate} | R Documentation |
Validate that a field is not equal to a specified value
Description
The sv_not_equal()
function compares the field value to a specified value
with the !=
operator.
Usage
sv_not_equal(
rhs,
message_fmt = "Must not be equal to {rhs}.",
allow_multiple = FALSE,
allow_na = FALSE,
allow_nan = FALSE,
allow_inf = FALSE
)
Arguments
rhs |
The right hand side (RHS) value is to be used for the comparison
with the field value. The validation check will effectively be of the form
|
message_fmt |
The validation error message to use if the field fails the
validation test. Use the |
allow_multiple |
If |
allow_na , allow_nan |
If |
allow_inf |
If |
Value
A function suitable for use as an
InputValidator$add_rule()
rule.
See Also
The other comparison-based rule functions: sv_gt()
, sv_gte()
,
sv_lt()
, sv_lte()
, and sv_equal()
(which serves as the opposite
function to sv_not_equal()
).
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_numeric()
,
sv_optional()
,
sv_regex()
,
sv_required()
,
sv_url()
Examples
## Only run examples in interactive R sessions
if (interactive()) {
library(shiny)
library(shinyvalidate)
ui <- fluidPage(
textInput("score", "Number")
)
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_not_equal()` requires a value
# to compare against the field value; a message
# will be shown if the validation of
# `input$score` fails
iv$add_rule("score", sv_not_equal(0))
# Finally, `enable()` the validation rules
iv$enable()
}
shinyApp(ui, server)
}