These functions perform checks that assert the underlying class of objects passed to them.
check_inherits(): checks that objectxis of classclassusingbase::inherits()check_inherits2(): checks that objectxis of classclassusingbase::.class2()check_inherits_any(): checks that objectxis at least one of the providedclassesviarlang::inherits_any()check_inherits_all(): checks that objectxis all of the providedclassesviarlang::inherits_all()
If validation fails for any of these functions, an error is thrown via check_abort() displaying a friendly
error message.
Usage
check_inherits(
x,
class,
arg = rlang::caller_arg(x),
call = rlang::caller_env()
)
check_inherits2(
x,
class,
arg = rlang::caller_arg(x),
call = rlang::caller_env()
)
check_inherits_any(
x,
classes,
arg = rlang::caller_arg(x),
call = rlang::caller_env()
)
check_inherits_all(
x,
classes,
arg = rlang::caller_arg(x),
call = rlang::caller_env()
)Arguments
- x
The object to check.
- class, classes
The name of the class or classes to use during checking.
- arg
An argument name as a string. This argument will be mentioned in error messages as the input that is at the origin of a problem.
- call
The execution environment of a currently running function, e.g.
caller_env(). The function will be mentioned in error messages as the source of the error. See thecallargument ofabort()for more information.