public function ScheduledDateProvidedConstraintValidator::validate in Sitewide Alert 8
File
- src/
Plugin/ Validation/ Constraint/ ScheduledDateProvidedConstraintValidator.php, line 23
Class
- ScheduledDateProvidedConstraintValidator
- Validates the UniqueInteger constraint.
Namespace
Drupal\sitewide_alert\Plugin\Validation\ConstraintCode
public function validate($entity, Constraint $constraint) {
if ($entity
->isScheduled() && ($entity
->getScheduledStartDateTime() === NULL || $entity
->getScheduledEndDateTime() === NULL)) {
$this->context
->buildViolation($constraint->messageDatesNotProvided)
->atPath('scheduled_date')
->addViolation();
}
}