You are here

public function ExecutionContext::getValidator in Zircon Profile 8

Same name in this branch
  1. 8 vendor/symfony/validator/Context/ExecutionContext.php \Symfony\Component\Validator\Context\ExecutionContext::getValidator()
  2. 8 core/lib/Drupal/Core/TypedData/Validation/ExecutionContext.php \Drupal\Core\TypedData\Validation\ExecutionContext::getValidator()
Same name and namespace in other branches
  1. 8.0 vendor/symfony/validator/Context/ExecutionContext.php \Symfony\Component\Validator\Context\ExecutionContext::getValidator()

Returns the validator.

Useful if you want to validate additional constraints:

public function validate($value, Constraint $constraint) { $validator = $this->context->getValidator();

$violations = $validator->validateValue($value, new Length(array('min' => 3)));

if (count($violations) > 0) { // ... } }

Return value

ValidatorInterface

Overrides ExecutionContextInterface::getValidator

1 call to ExecutionContext::getValidator()
ExecutionContext::getMetadataFactory in vendor/symfony/validator/Context/ExecutionContext.php
Returns the used metadata factory.

File

vendor/symfony/validator/Context/ExecutionContext.php, line 247

Class

ExecutionContext
The context used and created by {@link ExecutionContextFactory}.

Namespace

Symfony\Component\Validator\Context

Code

public function getValidator() {
  return $this->validator;
}