Create a custom assertion with a user-defined condition function.
This is a convenience wrapper around assert_output() with clearer semantics.
Usage
assert_custom(condition, message, field = NULL, type = c("assert", "suggest"))Examples
if (FALSE) { # \dontrun{
# Custom validation: answer must have exactly 3 sentences
assert_custom(
~ length(gregexpr("\\.", .x$answer)[[1]]) == 3,
"Answer must have exactly 3 sentences"
)
# Custom validation: summary must be shorter than original text
assert_custom(
function(x) nchar(x$summary) < nchar(x$original),
"Summary must be shorter than original"
)
} # }
