Skip to content

add check_length() to standalone-types-check.R #1618

@ateucher

Description

@ateucher

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 or Inf if only a minimum or maximum length is required).

Alternatively, a length argument could be added to the vector checkers such as check_character() and check_logical().

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions