function MediaTestConstraintValidator::validate
Same name in other branches
- 8.9.x core/modules/media/tests/modules/media_test_source/src/Plugin/Validation/Constraint/MediaTestConstraintValidator.php \Drupal\media_test_source\Plugin\Validation\Constraint\MediaTestConstraintValidator::validate()
- 10 core/modules/media/tests/modules/media_test_source/src/Plugin/Validation/Constraint/MediaTestConstraintValidator.php \Drupal\media_test_source\Plugin\Validation\Constraint\MediaTestConstraintValidator::validate()
- 11.x core/modules/media/tests/modules/media_test_source/src/Plugin/Validation/Constraint/MediaTestConstraintValidator.php \Drupal\media_test_source\Plugin\Validation\Constraint\MediaTestConstraintValidator::validate()
File
-
core/
modules/ media/ tests/ modules/ media_test_source/ src/ Plugin/ Validation/ Constraint/ MediaTestConstraintValidator.php, line 18
Class
- MediaTestConstraintValidator
- Validates the MediaTestConstraint.
Namespace
Drupal\media_test_source\Plugin\Validation\ConstraintCode
public function validate($value, Constraint $constraint) {
if ($value instanceof EntityInterface) {
$string_to_test = $value->label();
}
elseif ($value instanceof FieldItemListInterface) {
$string_to_test = $value->value;
}
else {
return;
}
if (strpos($string_to_test, 'love Drupal') === FALSE) {
$this->context
->addViolation($constraint->message);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.