public function DateRecurTimeZoneConstraintValidator::validate in Recurring Dates Field 3.0.x
Same name and namespace in other branches
- 8.2 src/Plugin/Validation/Constraint/DateRecurTimeZoneConstraintValidator.php \Drupal\date_recur\Plugin\Validation\Constraint\DateRecurTimeZoneConstraintValidator::validate()
- 3.x src/Plugin/Validation/Constraint/DateRecurTimeZoneConstraintValidator.php \Drupal\date_recur\Plugin\Validation\Constraint\DateRecurTimeZoneConstraintValidator::validate()
- 3.1.x src/Plugin/Validation/Constraint/DateRecurTimeZoneConstraintValidator.php \Drupal\date_recur\Plugin\Validation\Constraint\DateRecurTimeZoneConstraintValidator::validate()
File
- src/
Plugin/ Validation/ Constraint/ DateRecurTimeZoneConstraintValidator.php, line 18
Class
- DateRecurTimeZoneConstraintValidator
- Validates the DateRecurTimeZone constraint.
Namespace
Drupal\date_recur\Plugin\Validation\ConstraintCode
public function validate($value, Constraint $constraint) {
assert($constraint instanceof DateRecurTimeZoneConstraint);
$timeZones = \DateTimeZone::listIdentifiers();
if (is_string($value) && !in_array($value, $timeZones)) {
$this->context
->addViolation($constraint->invalidTimeZone, [
'%value' => $value,
]);
}
}