Skip to content

Commit

Permalink
Add allow_zero to check_character()
Browse files Browse the repository at this point in the history
  • Loading branch information
olivroy authored Jul 14, 2024
1 parent f185e62 commit 1f7ac86
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions R/standalone-types-check.R
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
# ---
# repo: r-lib/rlang
# file: standalone-types-check.R
# last-updated: 2023-03-13
# last-updated: 2024-07-14
# license: https://unlicense.org
# dependencies: standalone-obj-type.R
# imports: rlang (>= 1.1.0)
# ---
#
# ## Changelog
# 2024-07-14:
# - `check_character()` gains `allow_zero` to allow prohibiting `character(0)` (@olivroy)
#
# 2023-03-13:
# - Improved error messages of number checkers (@teunbrand)
Expand Down Expand Up @@ -460,10 +462,11 @@ check_formula <- function(x,
check_character <- function(x,
...,
allow_null = FALSE,
allow_zero = TRUE,
arg = caller_arg(x),
call = caller_env()) {
if (!missing(x)) {
if (is_character(x)) {
if (is_character(x) && (allow_zero || length(x) > 0)) {
return(invisible(NULL))
}
if (allow_null && is_null(x)) {
Expand Down

0 comments on commit 1f7ac86

Please sign in to comment.