function UriHostConstraintValidator::validate
Same name and namespace in other branches
- 11.x core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/UriHostConstraintValidator.php \Drupal\Core\Validation\Plugin\Validation\Constraint\UriHostConstraintValidator::validate()
File
-
core/
lib/ Drupal/ Core/ Validation/ Plugin/ Validation/ Constraint/ UriHostConstraintValidator.php, line 19
Class
- UriHostConstraintValidator
- Validates if a string conforms to the RFC 3986 host component.
Namespace
Drupal\Core\Validation\Plugin\Validation\ConstraintCode
public function validate($value, Constraint $constraint) : void {
assert($constraint instanceof UriHostConstraint);
if ($value === NULL || $value === '') {
return;
}
if (!is_string($value)) {
throw new UnexpectedTypeException($value, 'string');
}
if (!$this->isValid($value)) {
$this->context
->addViolation($constraint->message);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.