testthat expectation that reports the validator's own messages when the
value is invalid, so a failing test shows newdata$x2: must be numeric
rather than a generic "error thrown".
Arguments
- validator
a
restrictionobject created byrestrict().- value
the value to validate.
- ...
context arguments passed to the validator (e.g.
newdata = df).
Details
Requires the testthat package, which is checked when the
expectation runs. Every violation is reported, as with
validation_errors().
See also
Other testthat expectations:
expect_invalid()
Examples
if (requireNamespace("testthat", quietly = TRUE)) {
v <- restrict("x") |> require_numeric()
expect_valid(v, 1:3)
}