type_check_each: Vectorised List Type Checking

View source: R/type_check.R

type_check_eachR Documentation

Vectorised List Type Checking

Description

Apply type_check to each element in a list of targets against a single template. The template lookup table is built once and reused across every target, amortising the hash-table construction.

Usage

type_check_each(
  template,
  targets,
  with_cast = FALSE,
  log_items = c("casts", "missing", "excess", "debug")[c(1, 3)]
)

Arguments

template

A named list to use as a template.

targets

A list of named lists/dataframes to check against the template.

with_cast

If true, edits each target instead of just checking types.

log_items

Which debug info to print. Mirrors type_check.

Value

A list of the targets, with their types appropriately cast. Names of targets are preserved.

Examples

type_check_each(
  list("a" = character(0), "b" = integer(0)),
  list(list("a" = 1, "b" = 2.5), list("a" = "x", "b" = 3L)),
  TRUE, NULL
)

structenforcement documentation built on July 1, 2026, 5:07 p.m.