Chris@0: Chris@0: * Chris@0: * For the full copyright and license information, please view the LICENSE Chris@0: * file that was distributed with this source code. Chris@0: */ Chris@0: Chris@0: namespace Symfony\Component\Validator\Validator; Chris@0: Chris@0: use Symfony\Component\Validator\Constraint; Chris@17: use Symfony\Component\Validator\Constraints\GroupSequence; Chris@0: use Symfony\Component\Validator\ConstraintViolationListInterface; Chris@0: use Symfony\Component\Validator\Context\ExecutionContextInterface; Chris@0: use Symfony\Component\Validator\Mapping\Factory\MetadataFactoryInterface; Chris@0: Chris@0: /** Chris@0: * Validates PHP values against constraints. Chris@0: * Chris@0: * @author Bernhard Schussek Chris@0: */ Chris@0: interface ValidatorInterface extends MetadataFactoryInterface Chris@0: { Chris@0: /** Chris@0: * Validates a value against a constraint or a list of constraints. Chris@0: * Chris@0: * If no constraint is passed, the constraint Chris@0: * {@link \Symfony\Component\Validator\Constraints\Valid} is assumed. Chris@0: * Chris@17: * @param mixed $value The value to validate Chris@17: * @param Constraint|Constraint[] $constraints The constraint(s) to validate against Chris@17: * @param string|GroupSequence|(string|GroupSequence)[]|null $groups The validation groups to validate. If none is given, "Default" is assumed Chris@0: * Chris@0: * @return ConstraintViolationListInterface A list of constraint violations Chris@0: * If the list is empty, validation Chris@0: * succeeded Chris@0: */ Chris@0: public function validate($value, $constraints = null, $groups = null); Chris@0: Chris@0: /** Chris@0: * Validates a property of an object against the constraints specified Chris@0: * for this property. Chris@0: * Chris@17: * @param object $object The object Chris@17: * @param string $propertyName The name of the validated property Chris@17: * @param string|GroupSequence|(string|GroupSequence)[]|null $groups The validation groups to validate. If none is given, "Default" is assumed Chris@0: * Chris@0: * @return ConstraintViolationListInterface A list of constraint violations Chris@0: * If the list is empty, validation Chris@0: * succeeded Chris@0: */ Chris@0: public function validateProperty($object, $propertyName, $groups = null); Chris@0: Chris@0: /** Chris@0: * Validates a value against the constraints specified for an object's Chris@0: * property. Chris@0: * Chris@17: * @param object|string $objectOrClass The object or its class name Chris@17: * @param string $propertyName The name of the property Chris@17: * @param mixed $value The value to validate against the property's constraints Chris@17: * @param string|GroupSequence|(string|GroupSequence)[]|null $groups The validation groups to validate. If none is given, "Default" is assumed Chris@0: * Chris@0: * @return ConstraintViolationListInterface A list of constraint violations Chris@0: * If the list is empty, validation Chris@0: * succeeded Chris@0: */ Chris@0: public function validatePropertyValue($objectOrClass, $propertyName, $value, $groups = null); Chris@0: Chris@0: /** Chris@0: * Starts a new validation context and returns a validator for that context. Chris@0: * Chris@0: * The returned validator collects all violations generated within its Chris@0: * context. You can access these violations with the Chris@0: * {@link ContextualValidatorInterface::getViolations()} method. Chris@0: * Chris@0: * @return ContextualValidatorInterface The validator for the new context Chris@0: */ Chris@0: public function startContext(); Chris@0: Chris@0: /** Chris@0: * Returns a validator in the given execution context. Chris@0: * Chris@0: * The returned validator adds all generated violations to the given Chris@0: * context. Chris@0: * Chris@0: * @return ContextualValidatorInterface The validator for that context Chris@0: */ Chris@0: public function inContext(ExecutionContextInterface $context); Chris@0: }