Skip to contents

Non-throwing predicate: returns TRUE when value passes every step of validator, FALSE otherwise. Use it to branch on validity instead of wrapping a validator call in tryCatch().

Usage

is_valid(validator, value, ...)

Arguments

validator

a restriction object created by restrict().

value

the value to validate.

...

context arguments passed to the validator (e.g. newdata = df), the same as a direct validator call.

Value

A length-1 logical.

Details

Like validation_errors(), only validation failures are caught; a missing context dependency still raises so a calling mistake is not mistaken for invalid data.

Examples

v <- restrict("x") |> require_numeric(no_na = TRUE)
is_valid(v, 1:5)        # TRUE
#> [1] TRUE
is_valid(v, c(1, NA))   # FALSE
#> [1] FALSE