testthat expectation that the value violates the validator, optionally with a message matching a regular expression.
Arguments
- validator
a
restrictionobject created byrestrict().- value
the value to validate.
- ...
context arguments passed to the validator (e.g.
newdata = df).- regexp
optional regular expression the failure messages must match. All messages are joined with newlines before matching.
Details
Requires the testthat package, which is checked when the expectation runs. A missing context dependency is a usage error and propagates.
See also
Other testthat expectations:
expect_valid()
Examples
if (requireNamespace("testthat", quietly = TRUE)) {
v <- restrict("x") |> require_numeric()
expect_invalid(v, "a", regexp = "must be numeric")
}