Skip to contents

Runs Define-XML validation rules (DD-prefix) against a herald_spec object. These rules check the spec structure, cross-references, and value conformance independently of any data.

Usage

validate_spec(spec, rules = NULL)

Arguments

spec

A herald_spec object.

rules

Optional. A list of herald_rule objects, or a config string like "fda-define-xml-2.1". If NULL, loads DD rules from bundled rules.

Value

A herald_validation object with findings from DD rules.

Examples

spec <- herald_spec(
  ds_spec = data.frame(dataset = "DM", label = "Demographics",
                       stringsAsFactors = FALSE),
  var_spec = data.frame(dataset = "DM", variable = "STUDYID",
                        label = "Study ID", data_type = "text",
                        length = "12", stringsAsFactors = FALSE)
)
result <- validate_spec(spec)
result$findings
#>   rule_id impact   dataset variable row        value expected
#> 1  DD0006   High  datasets  dataset   1           DM     <NA>
#> 2  DD0006   High variables  dataset   1           DM     <NA>
#> 3  DD0007   High  datasets    label   1 Demographics     <NA>
#> 4  DD0007   High variables    label   1     Study ID     <NA>
#> 5  DD0021   High variables variable   1      STUDYID     <NA>
#> 6  DD0022   High  datasets    label   1 Demographics     <NA>
#> 7  DD0022   High variables    label   1     Study ID     <NA>
#>                                                                                                                               message
#> 1                                                   Dataset name is missing. Each row in the Datasets sheet must have a dataset name.
#> 2                                                   Dataset name is missing. Each row in the Datasets sheet must have a dataset name.
#> 3                                   Dataset label is missing. Description is required for all ItemGroupDef in regulatory submissions.
#> 4                                   Dataset label is missing. Description is required for all ItemGroupDef in regulatory submissions.
#> 5                                                Variable name is missing. Each row in the Variables sheet must have a variable name.
#> 6 Variable label is missing. Description is required for all ItemDef corresponding to Variable definitions in regulatory submissions.
#> 7 Variable label is missing. Description is required for all ItemDef corresponding to Variable definitions in regulatory submissions.