
Validate arguments against a given set of options
Source:R/validate_argument.R
validate_argument.Rd
This is a replacement for match.arg()
, however, the error
string should be more informative for users. The name of the affected argument
is shown, and possible typos as well as remaining valid options. Not that
the argument several.ok
is always FALSE
in validate_argument()
, i.e.
this function - unlike match.arg()
- does not allow evaluating several
valid options at once.
Examples
foo <- function(test = "small") {
validate_argument(test, c("small", "medium", "large"))
}
foo("small")
#> [1] "small"
# errors:
# foo("masll")