-
Notifications
You must be signed in to change notification settings - Fork 138
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 check_length()
to standalone-types-check.R
#1618
Comments
I think that makes sense. I'd just put |
I hadn't thought about the recycling situation, but it's a good point! I proposed the range to address situations like this, where there is a minimum length required (in this case a character vector with length > 0). I agree that requiring a specific range, or even a maximum length is probably not a common scenario, but requiring a non-empty vector that could be any length >=1 is fairly common. Maybe for that case an |
I think the use case is that I want to accept I think that |
It would be nice to be able to check if a vector is of a required length (exact, min or max). The scalar checkers
check_name()
,check_string()
etc., ensure an object is of length 1, but being able to check length constraints > 1 would be helpful. I could see this being implemented as something like:check_length(x, ..., length, arg = caller_arg(x), call = caller_env())
where
length
could be either a scalar integer value to specify an exact required length, or a length 2 vector supplying an allowed range of lengths (which could include-Inf
orInf
if only a minimum or maximum length is required).Alternatively, a
length
argument could be added to the vector checkers such ascheck_character()
andcheck_logical()
.The text was updated successfully, but these errors were encountered: