Iso8601StringConstraintValidator.php in Duration Field 3.0.x
File
src/Plugin/Validation/Constraint/Iso8601StringConstraintValidator.php
View source
<?php
namespace Drupal\duration_field\Plugin\Validation\Constraint;
use Symfony\Component\Validator\Constraint;
class Iso8601StringConstraintValidator extends Iso8601StringConstraintValidatorBase {
public function validate($items, Constraint $constraint) {
if (is_array($items)) {
foreach ($items as $item) {
if (!$this
->isIso8601String($item)) {
$this->context
->addViolation($constraint->notIso8601, [
'%value' => (string) $item,
]);
}
}
}
else {
if (!$this
->isIso8601String($items)) {
$this->context
->addViolation($constraint->notIso8601, [
'%value' => (string) $items,
]);
}
}
}
}