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