validate_safeframe: Checks the content of a safeframe object

View source: R/validate_safeframe.R

validate_safeframeR Documentation

Checks the content of a safeframe object

Description

This function evaluates the validity of a safeframe object by checking the object class, its tags, and the types of variables. It combines validation checks made by validate_types() and validate_tags(). See 'Details' section for more information on the checks performed.

Usage

validate_safeframe(x, ...)

Arguments

x

a safeframe object

...

<dynamic-dots> A named list with tags in x as list names and the related types as list values.

Details

The following checks are performed:

  • x is a safeframe object

  • variables in x have a well-formed label attribute

  • variables correspond to the specified types

Value

If checks pass, a safeframe object; otherwise issues an error.

See Also

  • validate_types() to check if variables have the right types

  • validate_tags() to perform a series of checks on the tags

Examples


## create a valid safeframe
x <- cars |>
  make_safeframe(
    mph = "speed",
    distance = "dist"
  )
x

## validation
validate_safeframe(x,
  mph = c("numeric", "factor"),
  distance = "numeric"
)

## the below issues an error
## note: tryCatch is only used to avoid a genuine error in the example
tryCatch(validate_safeframe(x,
  mph = c("numeric", "factor"),
  distance = "factor"
), error = paste)

safeframe documentation built on June 28, 2025, 1:08 a.m.