Skip to content

Commit

Permalink
Update parse_row_filters.R
Browse files Browse the repository at this point in the history
  • Loading branch information
Moohan authored Nov 13, 2024
1 parent 4014142 commit e26d1c6
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions R/parse_row_filters.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,21 @@ parse_row_filters <- function(row_filters) {
return(NULL)
}

if (!inherits(row_filters, "list")) {
cli::cli_abort("{.arg row_filters} must be a {.cls list}, not a {.cls {class(row_filters)}}.")
# Check if `row_filters` is a list or a character vector
if (!is.list(row_filters) && !is.character(row_filters)) {
cli::cli_abort("{.arg row_filters} must be a named {.cls list} or a named {.cls character} vector, not a {.cls {class(row_filters)}}.")
}

# If it's a list, ensure it's depth 1 and elements are named
if (is.list(row_filters)) {
if (any(lengths(row_filters) > 1) || any(names(row_filters) == "")) {
cli::cli_abort("{.arg row_filters} must be a list of depth 1 with named elements.")
}
}

# If it's a character vector, ensure it's named
if (is.character(row_filters) && any(names(row_filters) == "")) {
cli::cli_abort("{.arg row_filters} must be a named character vector.")
}

# check if any filters in list have length > 1
Expand Down

0 comments on commit e26d1c6

Please sign in to comment.