Validity check capable of validating multiple slots in a single call.
Arguments
- object
Object.
- expected
list
. Named list of expected classes per slot.- subset
logical(1)
. Only check a subset of slots in the object.
Details
To be used inside S4 setValidity()
call or with
validate()
. Particularly useful for checking multiple slotted objects
inside metadata()
.
Examples
## TRUE ====
validateClasses(
object = list(
"a" = character(),
"b" = integer(),
"c" = factor()
),
expected = list(
"a" = "character",
"b" = "integer",
"c" = "factor"
)
)
#> [1] TRUE
## FALSE ====
validateClasses(
object = list(
"a" = character(),
"b" = integer(),
"c" = factor()
),
expected = list(
"a" = "character",
"b" = "character",
"c" = "character"
)
)
#> [1] "Class checks failed: b, c.\nIf supported, 'updateObject()' may help resolve these issues."