You are here

public function EntityTestEntityLevelValidator::validate in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/system/tests/modules/entity_test/src/Plugin/Validation/Constraint/EntityTestEntityLevelValidator.php \Drupal\entity_test\Plugin\Validation\Constraint\EntityTestEntityLevelValidator::validate()

Checks if the passed value is valid.

Parameters

mixed $value The value that should be validated:

Constraint $constraint The constraint for the validation:

Overrides ConstraintValidatorInterface::validate

File

core/modules/system/tests/modules/entity_test/src/Plugin/Validation/Constraint/EntityTestEntityLevelValidator.php, line 28
Contains \Drupal\entity_test\Plugin\Validation\Constraint\EntityTestEntityLevelValidator.

Class

EntityTestEntityLevelValidator
Constraint validator for the EntityTestEntityLevel constraint.

Namespace

Drupal\entity_test\Plugin\Validation\Constraint

Code

public function validate($value, Constraint $constraint) {
  if ($value->name->value === 'entity-level-violation') {
    $this->context
      ->buildViolation($constraint->message)
      ->addViolation();
  }
}