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@17
|
15 use Symfony\Component\Validator\Constraints\GroupSequence;
|
Chris@0
|
16 use Symfony\Component\Validator\ConstraintViolationListInterface;
|
Chris@0
|
17
|
Chris@0
|
18 /**
|
Chris@0
|
19 * A validator in a specific execution context.
|
Chris@0
|
20 *
|
Chris@0
|
21 * @author Bernhard Schussek <bschussek@gmail.com>
|
Chris@0
|
22 */
|
Chris@0
|
23 interface ContextualValidatorInterface
|
Chris@0
|
24 {
|
Chris@0
|
25 /**
|
Chris@0
|
26 * Appends the given path to the property path of the context.
|
Chris@0
|
27 *
|
Chris@0
|
28 * If called multiple times, the path will always be reset to the context's
|
Chris@0
|
29 * original path with the given path appended to it.
|
Chris@0
|
30 *
|
Chris@0
|
31 * @param string $path The path to append
|
Chris@0
|
32 *
|
Chris@0
|
33 * @return $this
|
Chris@0
|
34 */
|
Chris@0
|
35 public function atPath($path);
|
Chris@0
|
36
|
Chris@0
|
37 /**
|
Chris@0
|
38 * Validates a value against a constraint or a list of constraints.
|
Chris@0
|
39 *
|
Chris@0
|
40 * If no constraint is passed, the constraint
|
Chris@0
|
41 * {@link \Symfony\Component\Validator\Constraints\Valid} is assumed.
|
Chris@0
|
42 *
|
Chris@17
|
43 * @param mixed $value The value to validate
|
Chris@17
|
44 * @param Constraint|Constraint[] $constraints The constraint(s) to validate against
|
Chris@17
|
45 * @param string|GroupSequence|(string|GroupSequence)[]|null $groups The validation groups to validate. If none is given, "Default" is assumed
|
Chris@0
|
46 *
|
Chris@0
|
47 * @return $this
|
Chris@0
|
48 */
|
Chris@0
|
49 public function validate($value, $constraints = null, $groups = null);
|
Chris@0
|
50
|
Chris@0
|
51 /**
|
Chris@0
|
52 * Validates a property of an object against the constraints specified
|
Chris@0
|
53 * for this property.
|
Chris@0
|
54 *
|
Chris@17
|
55 * @param object $object The object
|
Chris@17
|
56 * @param string $propertyName The name of the validated property
|
Chris@17
|
57 * @param string|GroupSequence|(string|GroupSequence)[]|null $groups The validation groups to validate. If none is given, "Default" is assumed
|
Chris@0
|
58 *
|
Chris@0
|
59 * @return $this
|
Chris@0
|
60 */
|
Chris@0
|
61 public function validateProperty($object, $propertyName, $groups = null);
|
Chris@0
|
62
|
Chris@0
|
63 /**
|
Chris@0
|
64 * Validates a value against the constraints specified for an object's
|
Chris@0
|
65 * property.
|
Chris@0
|
66 *
|
Chris@17
|
67 * @param object|string $objectOrClass The object or its class name
|
Chris@17
|
68 * @param string $propertyName The name of the property
|
Chris@17
|
69 * @param mixed $value The value to validate against the property's constraints
|
Chris@17
|
70 * @param string|GroupSequence|(string|GroupSequence)[]|null $groups The validation groups to validate. If none is given, "Default" is assumed
|
Chris@0
|
71 *
|
Chris@0
|
72 * @return $this
|
Chris@0
|
73 */
|
Chris@0
|
74 public function validatePropertyValue($objectOrClass, $propertyName, $value, $groups = null);
|
Chris@0
|
75
|
Chris@0
|
76 /**
|
Chris@0
|
77 * Returns the violations that have been generated so far in the context
|
Chris@0
|
78 * of the validator.
|
Chris@0
|
79 *
|
Chris@0
|
80 * @return ConstraintViolationListInterface The constraint violations
|
Chris@0
|
81 */
|
Chris@0
|
82 public function getViolations();
|
Chris@0
|
83 }
|