4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\Validator\Validator;
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;
20 * Validates PHP values against constraints.
22 * @author Bernhard Schussek <bschussek@gmail.com>
24 interface ValidatorInterface extends MetadataFactoryInterface
27 * Validates a value against a constraint or a list of constraints.
29 * If no constraint is passed, the constraint
30 * {@link \Symfony\Component\Validator\Constraints\Valid} is assumed.
32 * @param mixed $value The value to validate
33 * @param Constraint|Constraint[] $constraints The constraint(s) to validate
35 * @param array|null $groups The validation groups to
36 * validate. If none is given,
37 * "Default" is assumed
39 * @return ConstraintViolationListInterface A list of constraint violations
40 * If the list is empty, validation
43 public function validate($value, $constraints = null, $groups = null);
46 * Validates a property of an object against the constraints specified
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
54 * @return ConstraintViolationListInterface A list of constraint violations
55 * If the list is empty, validation
58 public function validateProperty($object, $propertyName, $groups = null);
61 * Validates a value against the constraints specified for an object's
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
71 * @return ConstraintViolationListInterface A list of constraint violations
72 * If the list is empty, validation
75 public function validatePropertyValue($objectOrClass, $propertyName, $value, $groups = null);
78 * Starts a new validation context and returns a validator for that context.
80 * The returned validator collects all violations generated within its
81 * context. You can access these violations with the
82 * {@link ContextualValidatorInterface::getViolations()} method.
84 * @return ContextualValidatorInterface The validator for the new context
86 public function startContext();
89 * Returns a validator in the given execution context.
91 * The returned validator adds all generated violations to the given
94 * @param ExecutionContextInterface $context The execution context
96 * @return ContextualValidatorInterface The validator for that context
98 public function inContext(ExecutionContextInterface $context);