You are here

class ItemsCountConstraintValidator 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

Validates the ItemsCount constraint.

Hierarchy

  • class \Drupal\media_entity_slideshow\Plugin\Validation\Constraint\ItemsCountConstraintValidator extends \Symfony\Component\Validator\ConstraintValidator

Expanded class hierarchy of ItemsCountConstraintValidator

1 file declares its use of ItemsCountConstraintValidator
ConstraintsTest.php in tests/src/Unit/ConstraintsTest.php

File

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

Namespace

Drupal\media_entity_slideshow\Plugin\Validation\Constraint
View source
class ItemsCountConstraintValidator extends ConstraintValidator {

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

}

Members

Namesort descending Modifiers Type Description Overrides
ItemsCountConstraintValidator::validate public function Checks if the passed value is valid.