R/validate_survey_files.R

Defines functions validate_survey_files

#' Validate survey file paths
#'
#' Check whether all supplied survey file paths exist.
#'
#' @param survey_files A character vector of survey file paths.
#'
#' @return Invisibly returns TRUE if all files exist.
#'   Otherwise, raises an error listing the missing files.
#'
#' @keywords internal
#' @noRd
validate_survey_files <- function(survey_files) {
  missing_files <- survey_files[!fs::file_exists(survey_files)]

  if (length(missing_files) > 0L) {
    stop(
      paste0(
        "The following files were not found: ",
        paste(missing_files, collapse = ", ")
      ),
      call. = FALSE
    )
  }

  invisible(TRUE)
}

Try the retroharmonize package in your browser

Any scripts or data that you put into this service are public.

retroharmonize documentation built on Nov. 29, 2026, 5:06 p.m.