ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
DataValidator.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
25
27{
29
30 public function __construct(
32 ) {
33 $this->validators = $validators;
34 }
35
36 public function isValid(ElementInterface $element, bool $ignore_marker): bool
37 {
38 return $this->validators->validator($element->getDefinition()->dataType())
39 ->isValid($element, $ignore_marker);
40 }
41
42 protected function getValidator(Type $type): DataValidatorInterface
43 {
44 $validator = $this->validators[$type->value];
45 if (isset($validator)) {
46 return $validator;
47 }
48 throw new \ilMDRepositoryException('Unhandled data type');
49 }
50}
isValid(ElementInterface $element, bool $ignore_marker)
getDefinition()
Defining properties of the metadata element.