validate | R Documentation |
validate()
is a variant of assert()
that is specifically intended to be
used inside of an S4 validity method definition.
validate(..., msg = NULL)
... |
Any number of R expressions that return |
msg |
|
Like assert()
, validate()
returns TRUE
on success. However, on failure
it returns a character
instead of a stop()
call. This is the current
recommended practice for defining S4 validity methods inside of a
setValidity()
call. Refer to the documentation in the methods package,
specifically validObject()
for detailed information on S4 validity methods.
TRUE
on success, or character(1)
on failure, containing an error
message.
Updated 2021-10-08.
methods::setValidity()
.
methods::validObject()
.
assertthat::validate_that()
.
## TRUE ====
validate(
is.atomic("example"),
is.character("example")
)
## FALSE ====
validate(
isFlag("xxx"),
isPositive(-1)
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.