You are here

public static function ConfigValidation::validateCats in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/config/tests/config_test/src/ConfigValidation.php \Drupal\config_test\ConfigValidation::validateCats()

Validates cats.

Parameters

string $string: The string to validate.

\Symfony\Component\Validator\Context\ExecutionContextInterface $context: The validation execution context.

File

core/modules/config/tests/config_test/src/ConfigValidation.php, line 34

Class

ConfigValidation
Provides a collection of validation callbacks for testing purposes.

Namespace

Drupal\config_test

Code

public static function validateCats($string, ExecutionContextInterface $context) {
  if (!in_array($string, [
    'kitten',
    'cats',
    'nyans',
  ])) {
    $context
      ->addViolation('no valid cat');
  }
}