class ScheduledDateProvidedConstraintValidator in Sitewide Alert 8
Validates the UniqueInteger constraint.
Hierarchy
- class \Drupal\sitewide_alert\Plugin\Validation\Constraint\ScheduledDateProvidedConstraintValidator extends \Symfony\Component\Validator\ConstraintValidator
Expanded class hierarchy of ScheduledDateProvidedConstraintValidator
File
- src/
Plugin/ Validation/ Constraint/ ScheduledDateProvidedConstraintValidator.php, line 11
Namespace
Drupal\sitewide_alert\Plugin\Validation\ConstraintView source
class ScheduledDateProvidedConstraintValidator extends ConstraintValidator {
/**
* Validator 2.5 and upwards compatible execution context.
*
* @var \Symfony\Component\Validator\Context\ExecutionContextInterface
*/
protected $context;
/**
* {@inheritdoc}
*/
public function validate($entity, Constraint $constraint) {
if ($entity
->isScheduled() && ($entity
->getScheduledStartDateTime() === NULL || $entity
->getScheduledEndDateTime() === NULL)) {
$this->context
->buildViolation($constraint->messageDatesNotProvided)
->atPath('scheduled_date')
->addViolation();
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ScheduledDateProvidedConstraintValidator:: |
protected | property | Validator 2.5 and upwards compatible execution context. | |
ScheduledDateProvidedConstraintValidator:: |
public | function | Checks if the passed value is valid. |