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\Constraints\GroupSequence;
16 use Symfony\Component\Validator\ConstraintViolationListInterface;
19 * A validator in a specific execution context.
21 * @author Bernhard Schussek <bschussek@gmail.com>
23 interface ContextualValidatorInterface
26 * Appends the given path to the property path of the context.
28 * If called multiple times, the path will always be reset to the context's
29 * original path with the given path appended to it.
31 * @param string $path The path to append
35 public function atPath($path);
38 * Validates a value against a constraint or a list of constraints.
40 * If no constraint is passed, the constraint
41 * {@link \Symfony\Component\Validator\Constraints\Valid} is assumed.
43 * @param mixed $value The value to validate
44 * @param Constraint|Constraint[] $constraints The constraint(s) to validate against
45 * @param string|GroupSequence|(string|GroupSequence)[]|null $groups The validation groups to validate. If none is given, "Default" is assumed
49 public function validate($value, $constraints = null, $groups = null);
52 * Validates a property of an object against the constraints specified
55 * @param object $object The object
56 * @param string $propertyName The name of the validated property
57 * @param string|GroupSequence|(string|GroupSequence)[]|null $groups The validation groups to validate. If none is given, "Default" is assumed
61 public function validateProperty($object, $propertyName, $groups = null);
64 * Validates a value against the constraints specified for an object's
67 * @param object|string $objectOrClass The object or its class name
68 * @param string $propertyName The name of the property
69 * @param mixed $value The value to validate against the property's constraints
70 * @param string|GroupSequence|(string|GroupSequence)[]|null $groups The validation groups to validate. If none is given, "Default" is assumed
74 public function validatePropertyValue($objectOrClass, $propertyName, $value, $groups = null);
77 * Returns the violations that have been generated so far in the context
80 * @return ConstraintViolationListInterface The constraint violations
82 public function getViolations();