validateClasses: Validate expected classes

View source: R/validateClasses.R

validateClassesR Documentation

Validate expected classes

Description

Validity check capable of validating multiple slots in a single call.

Usage

validateClasses(object, expected, subset = FALSE)

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().

Value

logical(1) (TRUE) on sucess or character(1) containing informative message on failure.

Note

Updated 2023-04-26.

See Also

  • validate().

  • methods::setValidity().

  • methods::validObject().

Examples

## TRUE ====
validateClasses(
    object = list(
        "a" = character(),
        "b" = integer(),
        "c" = factor()
    ),
    expected = list(
        "a" = "character",
        "b" = "integer",
        "c" = "factor"
    )
)

## FALSE ====
validateClasses(
    object = list(
        "a" = character(),
        "b" = integer(),
        "c" = factor()
    ),
    expected = list(
        "a" = "character",
        "b" = "character",
        "c" = "character"
    )
)

steinbaugh/goalie documentation built on Jan. 17, 2024, 5:16 p.m.