From 0b1c4a2128e4ffece9551619fb39bc406c4d3b88 Mon Sep 17 00:00:00 2001 From: Carter Thunes Date: Tue, 8 Oct 2024 15:52:01 -0400 Subject: [PATCH] add validation to tcplMthdList --- R/tcplMthdList.R | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/R/tcplMthdList.R b/R/tcplMthdList.R index 2ce6db5..ba924d9 100644 --- a/R/tcplMthdList.R +++ b/R/tcplMthdList.R @@ -7,6 +7,11 @@ tcplMthdList <- function(lvl, type = "mc") { + if (length(lvl) > 1) stop("'lvl' must be an integer of length 1.") + if (!type %in% c("mc", "sc")) stop("Invalid 'type' value.") + if (type == "mc" & !lvl %in% c(2, 3,4, 5, 6)) stop("Invalid 'lvl' value.") + if (type == "sc" & !lvl %in% 1:2) stop("Invalid 'lvl' value.") + if(getOption("TCPL_DRVR") == "API"){ return(tcpl::mthd_list_defaults[grep(paste0(type,lvl), names(tcpl::mthd_list_defaults))][[1]]) }