rlang icon indicating copy to clipboard operation
rlang copied to clipboard

Add `check_named()` to standalone file.

Open mgirlich opened this issue 7 months ago • 0 comments

I frequently see checks that something is named, especially when using ..., e.g. in httr2::req_template():

req_template <- function(...) {
  if (length(dots) > 0 && !is_named(dots)) {
    cli::cli_abort("All elements of {.arg ...} must be named.")
  }
}

It might make sense to also check that the names are unique. So, this would basically become a version of vctrs::vec_names2(..., repair = "check_unique").

I also added an issue in https://github.com/r-lib/vctrs/issues/1895 as I think it makes sense in both places. Also see #1236 for a feature request for checking that dynamic dots are named.

It might also be worth to add check_unnamed() (though this is needed way less often).

Some places I found this check * `httr2::req_template()` * `httr2::modify_list()` * `tidyr::pack()` * `tidyr::separate_wider_regex()` * `tidyr::check_unique_names()` * `tidyr::separate_wider_delim()` (unnamed)

mgirlich avatar Nov 10 '23 05:11 mgirlich