4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\Validator\Validator;
14 use Symfony\Component\Validator\Constraint;
15 use Symfony\Component\Validator\ConstraintViolationListInterface;
18 * A validator in a specific execution context.
20 * @author Bernhard Schussek <bschussek@gmail.com>
22 interface ContextualValidatorInterface
25 * Appends the given path to the property path of the context.
27 * If called multiple times, the path will always be reset to the context's
28 * original path with the given path appended to it.
30 * @param string $path The path to append
34 public function atPath($path);
37 * Validates a value against a constraint or a list of constraints.
39 * If no constraint is passed, the constraint
40 * {@link \Symfony\Component\Validator\Constraints\Valid} is assumed.
42 * @param mixed $value The value to validate
43 * @param Constraint|Constraint[] $constraints The constraint(s) to validate
45 * @param array|null $groups The validation groups to
46 * validate. If none is given,
47 * "Default" is assumed
51 public function validate($value, $constraints = null, $groups = null);
54 * Validates a property of an object against the constraints specified
57 * @param object $object The object
58 * @param string $propertyName The name of the validated property
59 * @param array|null $groups The validation groups to validate. If
60 * none is given, "Default" is assumed
64 public function validateProperty($object, $propertyName, $groups = null);
67 * Validates a value against the constraints specified for an object's
70 * @param object|string $objectOrClass The object or its class name
71 * @param string $propertyName The name of the property
72 * @param mixed $value The value to validate against the
73 * property's constraints
74 * @param array|null $groups The validation groups to validate. If
75 * none is given, "Default" is assumed
79 public function validatePropertyValue($objectOrClass, $propertyName, $value, $groups = null);
82 * Returns the violations that have been generated so far in the context
85 * @return ConstraintViolationListInterface The constraint violations
87 public function getViolations();