You are here

public function ItemsCountConstraintValidator::validate in Media entity slideshow 8

Same name and namespace in other branches
  1. 8.2 src/Plugin/Validation/Constraint/ItemsCountConstraintValidator.php \Drupal\media_entity_slideshow\Plugin\Validation\Constraint\ItemsCountConstraintValidator::validate()

File

src/Plugin/Validation/Constraint/ItemsCountConstraintValidator.php, line 16

Class

ItemsCountConstraintValidator
Validates the ItemsCount constraint.

Namespace

Drupal\media_entity_slideshow\Plugin\Validation\Constraint

Code

public function validate($value, Constraint $constraint) {
  if (!isset($value)) {
    return;
  }
  if ($value
    ->get($constraint->sourceFieldName)
    ->isEmpty()) {
    $this->context
      ->addViolation($constraint->message);
  }
}