1cc96c834e6f69cd101b15bdb2aa3cf3e8b0576f
[yaffs-website] / vendor / symfony / validator / Validator / ContextualValidatorInterface.php
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
12 namespace Symfony\Component\Validator\Validator;
13
14 use Symfony\Component\Validator\Constraint;
15 use Symfony\Component\Validator\ConstraintViolationListInterface;
16
17 /**
18  * A validator in a specific execution context.
19  *
20  * @author Bernhard Schussek <bschussek@gmail.com>
21  */
22 interface ContextualValidatorInterface
23 {
24     /**
25      * Appends the given path to the property path of the context.
26      *
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.
29      *
30      * @param string $path The path to append
31      *
32      * @return $this
33      */
34     public function atPath($path);
35
36     /**
37      * Validates a value against a constraint or a list of constraints.
38      *
39      * If no constraint is passed, the constraint
40      * {@link \Symfony\Component\Validator\Constraints\Valid} is assumed.
41      *
42      * @param mixed                   $value       The value to validate
43      * @param Constraint|Constraint[] $constraints The constraint(s) to validate
44      *                                             against
45      * @param array|null              $groups      The validation groups to
46      *                                             validate. If none is given,
47      *                                             "Default" is assumed
48      *
49      * @return $this
50      */
51     public function validate($value, $constraints = null, $groups = null);
52
53     /**
54      * Validates a property of an object against the constraints specified
55      * for this property.
56      *
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
61      *
62      * @return $this
63      */
64     public function validateProperty($object, $propertyName, $groups = null);
65
66     /**
67      * Validates a value against the constraints specified for an object's
68      * property.
69      *
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
76      *
77      * @return $this
78      */
79     public function validatePropertyValue($objectOrClass, $propertyName, $value, $groups = null);
80
81     /**
82      * Returns the violations that have been generated so far in the context
83      * of the validator.
84      *
85      * @return ConstraintViolationListInterface The constraint violations
86      */
87     public function getViolations();
88 }