Skip to contents

Validates a JSON database file against the appropriate JSON schema to ensure data integrity and structure compliance.

Usage

validate_json_database(json_file, type = "unified")

Arguments

json_file

Path to JSON file to validate

type

Database type ("methods", "measures", "results", "discussion", "appendix", "template", "unified"). Default is "unified".

Value

Character vector of validation errors (empty if valid)

Details

Uses JSON Schema Draft 7 for validation via the jsonvalidate package. Schemas define required fields, data types, and structure for each database type. This ensures consistency across different database files and helps catch errors early.

If jsonvalidate is not installed, validation is skipped with a message.

Examples

if (FALSE) { # \dontrun{
# Validate a measures database
errors <- validate_json_database("measures_db.json", "measures")
if (length(errors) == 0) {
  message("Database is valid!")
} else {
  cat("Validation errors:\n", paste(errors, collapse = "\n"))
}

# Validate unified database
errors <- validate_json_database("boilerplate_unified.json")
} # }