Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add min_length to check_character() #1734

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

Conversation

olivroy
Copy link
Contributor

@olivroy olivroy commented Jul 14, 2024

Sometimes you want something non-empty. allow_zero = FALSE will disallow character(0). Addresses #1618 (comment)

Copy link
Member

@lionel- lionel- left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be allow_empty and apply to all vector types?

Could also be something like length = c("any", "non_empty", "scalar")? It seems like this change deserves some discussion about general vector checks.

@olivroy
Copy link
Contributor Author

olivroy commented Jul 15, 2024

I agree. However allow_empty would be confusing since for check_string(). allow_empty = FALSE is meant to disallow "".

I like the length argument. maybe min_length would be good?

the proposed scalar option would be redundant since check_string() is already there.

Copy link
Contributor Author

@olivroy olivroy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Modify the stop_input_type() call for:

  what <- "character vector"  
  if (min_length > 0) {
    what <- paste0(what, "of length greater or equal to", min_length) 
  }

R/standalone-types-check.R Outdated Show resolved Hide resolved
R/standalone-types-check.R Outdated Show resolved Hide resolved
R/standalone-types-check.R Outdated Show resolved Hide resolved
@olivroy olivroy changed the title Add allow_zero to check_character() Add min_length to check_character() Aug 15, 2024
R/standalone-types-check.R Outdated Show resolved Hide resolved
R/standalone-types-check.R Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants