validObject
Validate S4 Object

### Description

Test an object to determine if it is a valid S4 object.

### Usage

    validObject(object, test = FALSE, complete = FALSE)

### Arguments

object | the object to be evaluated.
test | logical, specifies what happens if the validity function did not return TRUE, either generating an error (if test is FALSE) or returning the output of the validity function (if test is TRUE).
complete | a logical value. If complete = TRUE, validObject is recursively called on the contents of all slots of object, and any resulting error messages are added to the validity errors from object itself.

Value
Returns TRUE if the object validity function returned TRUE. If the object validity function does not return TRUE, then validObject either generates an error (if test=FALSE), or returns the output of the validation function (typically a string specifying why the object is not valid).
Details
The validity function is the function given as the validity argument to setClass when the class is defined. This function can be retrieved with getClass(myclass)\@validity and changed with setValidity.
See Also
new, getClass, setClass
Examples

    # Create an object with a validation function
    setClass("myClass", rep=representation(x="numeric",y="numeric"),
        validity=function(object) if (object@x < object@y) TRUE else "x>=y")
    xx <- new("myClass", x=1, y=2)
    validObject(xx)  # returns TRUE
    xx@y <- 0  # set slot so object is not valid
    ## Not run:
    validObject(xx)  # error
    ## End(Not run)
    validObject(xx, test=TRUE)  # returns "x>=y"

Package methods version 6.1.5-18
Package Index