View source: R/validate_spec.R
| validate_spec | R Documentation |
Run artoo's bundled, self-contained checks over a artoo_spec,
scoped to the dataset(s) you are working on, and return a
artoo_check that prints a sectioned report. Every finding is keyed to
an open rule in the shipped catalog (see spec_rules.json); the result
object keeps the findings as a plain data frame in @findings for
programmatic use.
validate_spec(
spec,
data = NULL,
dataset = NULL,
on_error = c("off", "warn", "abort")
)
spec |
The specification to validate. |
data |
Optional input data for controlled-terminology checks.
|
dataset |
Restrict to one or more datasets. Restriction: each name must be a dataset in the spec. |
on_error |
What to do with an error-severity finding.
|
Dataset-scoped. A spec workbook carries many datasets. Pass
dataset to validate only the one(s) you are working on — the
methods, comments, and codelists those datasets reference are checked
for completeness, but unrelated datasets are not. dataset = NULL
validates the whole spec.
Collect, do not stop. Every finding is collected and returned;
validate_spec() does not abort on an error-severity finding unless
on_error = "abort".
A artoo_check object. Its @findings data frame has columns
check, dimension, severity, dataset, variable, message.
Print it for the sectioned report.
artoo_spec() to build a spec; spec_methods() /
spec_comments() for the metadata checked.
# ---- Example 1: validate one dataset ----
#
# Build a spec from the bundled ADaM tables and validate it; the
# result prints a sectioned report and keeps the findings table.
spec <- artoo_spec(
cdisc_adam_datasets, cdisc_adam_variables,
codelists = cdisc_codelists
)
chk <- validate_spec(spec, dataset = "ADSL")
chk@findings
# ---- Example 2: gate on errors with on_error = "abort" ----
#
# Point a key at a missing variable, then validate with on_error = "abort"
# and catch the resulting error.
bad_ds <- cdisc_sdtm_datasets
bad_ds$keys <- "NOTAVAR"
bad <- artoo_spec(bad_ds, cdisc_sdtm_variables, codelists = cdisc_codelists)
tryCatch(
validate_spec(bad, dataset = "DM", on_error = "abort"),
artoo_error_validation = function(e) conditionMessage(e)[1]
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.