Version 1
[yaffs-website] / vendor / symfony / validator / Validator / ValidatorInterface.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 use Symfony\Component\Validator\Context\ExecutionContextInterface;
17 use Symfony\Component\Validator\Mapping\Factory\MetadataFactoryInterface;
18
19 /**
20  * Validates PHP values against constraints.
21  *
22  * @author Bernhard Schussek <bschussek@gmail.com>
23  */
24 interface ValidatorInterface extends MetadataFactoryInterface
25 {
26     /**
27      * Validates a value against a constraint or a list of constraints.
28      *
29      * If no constraint is passed, the constraint
30      * {@link \Symfony\Component\Validator\Constraints\Valid} is assumed.
31      *
32      * @param mixed                   $value       The value to validate
33      * @param Constraint|Constraint[] $constraints The constraint(s) to validate
34      *                                             against
35      * @param array|null              $groups      The validation groups to
36      *                                             validate. If none is given,
37      *                                             "Default" is assumed
38      *
39      * @return ConstraintViolationListInterface A list of constraint violations
40      *                                          If the list is empty, validation
41      *                                          succeeded
42      */
43     public function validate($value, $constraints = null, $groups = null);
44
45     /**
46      * Validates a property of an object against the constraints specified
47      * for this property.
48      *
49      * @param object     $object       The object
50      * @param string     $propertyName The name of the validated property
51      * @param array|null $groups       The validation groups to validate. If
52      *                                 none is given, "Default" is assumed
53      *
54      * @return ConstraintViolationListInterface A list of constraint violations
55      *                                          If the list is empty, validation
56      *                                          succeeded
57      */
58     public function validateProperty($object, $propertyName, $groups = null);
59
60     /**
61      * Validates a value against the constraints specified for an object's
62      * property.
63      *
64      * @param object|string $objectOrClass The object or its class name
65      * @param string        $propertyName  The name of the property
66      * @param mixed         $value         The value to validate against the
67      *                                     property's constraints
68      * @param array|null    $groups        The validation groups to validate. If
69      *                                     none is given, "Default" is assumed
70      *
71      * @return ConstraintViolationListInterface A list of constraint violations
72      *                                          If the list is empty, validation
73      *                                          succeeded
74      */
75     public function validatePropertyValue($objectOrClass, $propertyName, $value, $groups = null);
76
77     /**
78      * Starts a new validation context and returns a validator for that context.
79      *
80      * The returned validator collects all violations generated within its
81      * context. You can access these violations with the
82      * {@link ContextualValidatorInterface::getViolations()} method.
83      *
84      * @return ContextualValidatorInterface The validator for the new context
85      */
86     public function startContext();
87
88     /**
89      * Returns a validator in the given execution context.
90      *
91      * The returned validator adds all generated violations to the given
92      * context.
93      *
94      * @param ExecutionContextInterface $context The execution context
95      *
96      * @return ContextualValidatorInterface The validator for that context
97      */
98     public function inContext(ExecutionContextInterface $context);
99 }