1<?php 2 3/* 4 * This file is part of the Symfony package. 5 * 6 * (c) Fabien Potencier <fabien@symfony.com> 7 * 8 * For the full copyright and license information, please view the LICENSE 9 * file that was distributed with this source code. 10 */ 11 12namespace Symfony\Component\Validator\Validator; 13 14use Symfony\Component\Validator\Constraint; 15use Symfony\Component\Validator\Constraints\GroupSequence; 16use Symfony\Component\Validator\ConstraintViolationListInterface; 17 18/** 19 * A validator in a specific execution context. 20 * 21 * @author Bernhard Schussek <bschussek@gmail.com> 22 */ 23interface ContextualValidatorInterface 24{ 25 /** 26 * Appends the given path to the property path of the context. 27 * 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. 30 * 31 * @param string $path The path to append 32 * 33 * @return $this 34 */ 35 public function atPath($path); 36 37 /** 38 * Validates a value against a constraint or a list of constraints. 39 * 40 * If no constraint is passed, the constraint 41 * {@link \Symfony\Component\Validator\Constraints\Valid} is assumed. 42 * 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 46 * 47 * @return $this 48 */ 49 public function validate($value, $constraints = null, $groups = null); 50 51 /** 52 * Validates a property of an object against the constraints specified 53 * for this property. 54 * 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 58 * 59 * @return $this 60 */ 61 public function validateProperty($object, $propertyName, $groups = null); 62 63 /** 64 * Validates a value against the constraints specified for an object's 65 * property. 66 * 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 71 * 72 * @return $this 73 */ 74 public function validatePropertyValue($objectOrClass, $propertyName, $value, $groups = null); 75 76 /** 77 * Returns the violations that have been generated so far in the context 78 * of the validator. 79 * 80 * @return ConstraintViolationListInterface The constraint violations 81 */ 82 public function getViolations(); 83} 84