R/check-arguments.R

Defines functions check_quantity check_active

# nocov start

check_active <- function(active) {
  if (is.logical(active)) {
    active <- ifelse(active, "ACTIVE", "INACTIVE")
  } else if (!is.character(active) || !(active %in% c("ACTIVE", "INACTIVE"))) {
    stop('Argument "active" must be either TRUE, FALSE, "ACTIVE" or "INACTIVE".')
  }

  active
}

check_quantity <- function(quantity) {
  if (!(quantity %in% c("budget", "time"))) stop("Invalid quantity.")
}

# nocov end
datawookie/clockify documentation built on June 6, 2024, 4:39 p.m.