Skip to contents

assert_not_contains() checks that an output field does not contain pattern, matched as a fixed string. A missing field passes.

Usage

assert_not_contains(
  field = NULL,
  pattern,
  ignore_case = FALSE,
  type = c("assert", "suggest")
)

Arguments

field

The output field to check. With NULL, the whole output is checked, which suits outputs with a single field. A missing field fails the check.

pattern

The string that must not appear.

ignore_case

If TRUE, ignore case when matching.

type

"assert" (the default) for a hard assertion, which makes with_assertions() retry when it fails, or "suggest" for a soft one, which only gives a warning.

Value

An assertion for assertion_set() or with_assertions().

Examples

assert_not_contains("answer", "As an AI")
#> 
#> ── Hard Assertion 
#> • Field: any field
#> • Message: "answer must not contain 'As an AI'"
assert_not_contains("reply", "password", ignore_case = TRUE)
#> 
#> ── Hard Assertion 
#> • Field: any field
#> • Message: "reply must not contain 'password'"