R/validate_path.R

Defines functions validate_path

Documented in validate_path

#' Validate Path
#'
#' Validate file path to EDMS output is a csv and exits.
#'
#' @inheritParams munge_edms
#'
#' @keywords internal
#'
validate_path <- function(path){

  if(length(path) > 1)
    cli::cli_abort("The {.var path} param can only accept a vector of length 1")

  if(tools::file_ext(path) != "csv")
    cli::cli_abort(c("Expecting user to provide a csv as the {.var path}.",
                     i = "Please provide a csv file."))

  if(!file.exists(path))
    cli::cli_abort(c("File does not exist: {.file {path}}."))
}
USAID-OHA-SI/mindthegap documentation built on Jan. 19, 2025, 3:16 a.m.