valid2 | R Documentation |
Designed to be called inside a customvalid_*
function (e.g. valid_yes_no()
)
valid2( ..., .choices = character(), .reverse = FALSE, .flip = FALSE, .strict = TRUE, .unname = FALSE )
... |
(character) Selection of available values |
.choices |
(character) Available values |
.reverse |
(logical) Reverse order yes/no |
.flip |
(logical) Flip names and values yes/no |
.strict |
(logical) Be strict about "things that might go wrong" yes/no |
.unname |
(logical) Drop names yes/no |
valid_foo <- function( ... ) { choices <- letters[1:3] names(choices) <- choices %>% toupper() valid::valid2( ..., .choices = choices ) } valid_foo() # Via name valid_foo("A") valid_foo("A", "C") # Via value valid_foo("a") valid_foo("a", "c") # Handling obvious errors try(valid_foo("D")) try(valid_foo("d")) # Handling partial errors try(valid_foo("A", "D")) try(valid_foo("A", "D", .strict = FALSE)) try(valid_foo("a", "d")) try(valid_foo("a", "d", .strict = FALSE))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.