R/check.R

Defines functions check_listdf check_path check_conn

check_conn <- function(conn) {
  if(!inherits(conn, "SQLiteConnection"))
    stop("conn must be an SQLiteConnection", call. = FALSE)
  conn
}

check_path <- function(x){
  check_string(x)
  path_ext <- tools::file_ext(x)
  if(identical(path_ext, "")) {
    return(paste0(x, ".R"))
  }
  if(!identical(path_ext, ".R")){
    return(gsub(path_ext, "R", x))
  }
}

check_listdf <- function(x){
  check_list(x)
  check_named(x)
  if(!all(sapply(x, is.data.frame)))
    stop("All elements of list must be data.frame", call. = FALSE)
  x
}
poissonconsulting/createsqlite documentation built on July 28, 2020, 2:15 p.m.