Skip to content

Commit

Permalink
#468 multiple_units: fix case of all units NA
Browse files Browse the repository at this point in the history
  • Loading branch information
bundfussr committed Oct 31, 2024
1 parent 4c4d10d commit 839c2fa
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions R/assertions.R
Original file line number Diff line number Diff line change
Expand Up @@ -1107,7 +1107,7 @@ assert_function <- function(arg,
#' @param required_unit Expected unit(s)
#'
#' If the argument is set to `NULL`, it is checked only whether the unit is
#' unique.
#' unique within the parameter.
#'
#' *Permitted Values*: A character vector or `NULL`
#'
Expand Down Expand Up @@ -1195,7 +1195,7 @@ assert_unit <- function(dataset,
pull(`_unit`) %>%
unique()

if (length(units) != 1L) {
if (length(units) > 1L) {
message <-
message %||%
"Multiple units {.val {units}} found for {.val {param}}. Please review and update the units."
Expand All @@ -1207,7 +1207,7 @@ assert_unit <- function(dataset,
)
}

if (!is.null(required_unit) && !(tolower(units) %in% tolower(required_unit))) {
if (!is.null(required_unit) && tolower(units) %notin% tolower(required_unit)) {
# change cli `.val` to end with OR instead of AND
divid <- cli_div(theme = list(.val = list("vec-last" = ", or ", "vec_sep2" = " or ")))

Expand Down
2 changes: 1 addition & 1 deletion man/assert_unit.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 839c2fa

Please sign in to comment.