From 0d7ecda8a77c1176f5ff7f6e27cc4497b4dfcfe7 Mon Sep 17 00:00:00 2001 From: James McMahon Date: Wed, 13 Nov 2024 20:56:28 +0000 Subject: [PATCH] Update parse_row_filters.R --- R/parse_row_filters.R | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/R/parse_row_filters.R b/R/parse_row_filters.R index 67fa5bb..f17e177 100644 --- a/R/parse_row_filters.R +++ b/R/parse_row_filters.R @@ -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