doesNotContain static method

void doesNotContain(
  1. String? textToSearch,
  2. String substring,
  3. String message
)

Asserts that the given textToSearch does not contain the given substring.

Throws an InvalidArgumentException with the given message if the substring is found in textToSearch.

Example:

Assert.doesNotContain(email, ' ', 'Email cannot contain spaces');

Implementation

static void doesNotContain(String? textToSearch, String substring, String message) {
  if (textToSearch != null && textToSearch.contains(substring)) {
    throw InvalidArgumentException(message);
  }
}