Skip to content

Commit

Permalink
core_chapter_structure_cols as argument (#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
sda030 authored Jul 22, 2024
1 parent 9fe6ff5 commit 19dd756
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
7 changes: 4 additions & 3 deletions R/validate_chapter_structure.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

validate_chapter_structure <- function(chapter_structure, data=NULL) {
validate_chapter_structure <- function(chapter_structure, data=NULL,
core_chapter_structure_cols = .saros.env$core_chapter_structure_cols) {

# ENSURE THAT .template_name, chapter etc are part of goruping_sturcture?

Expand All @@ -14,8 +15,8 @@ validate_chapter_structure <- function(chapter_structure, data=NULL) {


missing_core_columns <-
.saros.env$core_chapter_structure_cols[
!.saros.env$core_chapter_structure_cols %in% colnames(chapter_structure)
core_chapter_structure_cols[
!core_chapter_structure_cols %in% colnames(chapter_structure)
]
if(length(missing_core_columns)>0) {
cli::cli_abort("{.arg chapter_structure} is missing {.var {missing_core_columns}}.")
Expand Down
5 changes: 4 additions & 1 deletion R/validate_draft_report_args.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,15 @@ validate_draft_report_args <- function(params) {
}
is_bool <- function(x) is.logical(x) && length(x) == 1 && !is.na(x)

core_chapter_structure_cols <-
.saros.env$core_chapter_structure_cols


arg_params <-
list(
# Data frames
data = list(fun = function(x) inherits(x, "data.frame") || inherits(x, "survey")),
chapter_structure = list(fun = function(x) validate_chapter_structure(x)),
chapter_structure = list(fun = function(x) validate_chapter_structure(x, core_chapter_structure_cols = core_chapter_structure_cols)),

# Character vectors (not enums)
mesos_var = list(fun = function(x) is.null(x) || is_string(x)),
Expand Down

0 comments on commit 19dd756

Please sign in to comment.