You are here

public function ExecutionContext::validateValue in Plug 7

Same name in this branch
  1. 7 lib/Symfony/validator/Symfony/Component/Validator/ExecutionContext.php \Symfony\Component\Validator\ExecutionContext::validateValue()
  2. 7 lib/Symfony/validator/Symfony/Component/Validator/Context/ExecutionContext.php \Symfony\Component\Validator\Context\ExecutionContext::validateValue()

Validates a value against a constraint.

Use the parameter <tt>$subPath</tt> to adapt the property path for the validated value. For example, take the following object graph:

<pre> (Person)---($address: Address)---($street: string) ^ </pre>

When the validator validates the <tt>Address</tt> instance, the property path stored in the execution context is "address". When you manually validate the property <tt>$street</tt> now, pass the sub path "street" to adapt the full property path to "address.street":

<pre> $context->validate($address->street, new NotNull(), 'street'); </pre>

Parameters

mixed $value The value to validate.:

Constraint|Constraint[] $constraints The constraint(s) to validate against.:

string $subPath The path to append to the context's property path.:

null|string|string[] $groups The groups to validate in. If you don't pass any: groups here, the current group of the context will be used.

Overrides ExecutionContextInterface::validateValue

Deprecated

Deprecated since version 2.5, to be removed in Symfony 3.0. Use {@link Context\ExecutionContextInterface::getValidator()} instead.

1 method overrides ExecutionContext::validateValue()
LegacyExecutionContext::validateValue in lib/Symfony/validator/Symfony/Component/Validator/Context/LegacyExecutionContext.php
Validates a value against a constraint.

File

lib/Symfony/validator/Symfony/Component/Validator/Context/ExecutionContext.php, line 333

Class

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

Namespace

Symfony\Component\Validator\Context

Code

public function validateValue($value, $constraints, $subPath = '', $groups = null) {
  throw new BadMethodCallException('validateValue() is not supported anymore as of Symfony 2.5. ' . 'Please use getValidator() instead or enable the legacy mode.');
}