2010-06-24 09:40:05 +01:00
|
|
|
<?php
|
|
|
|
|
2010-10-02 11:42:31 +01:00
|
|
|
/*
|
2011-01-15 13:29:43 +00:00
|
|
|
* This file is part of the Symfony package.
|
2010-10-02 11:42:31 +01:00
|
|
|
*
|
2011-03-06 11:40:06 +00:00
|
|
|
* (c) Fabien Potencier <fabien@symfony.com>
|
2010-10-02 11:42:31 +01:00
|
|
|
*
|
2011-01-15 13:29:43 +00:00
|
|
|
* For the full copyright and license information, please view the LICENSE
|
|
|
|
* file that was distributed with this source code.
|
2010-10-02 11:42:31 +01:00
|
|
|
*/
|
|
|
|
|
2011-01-15 13:29:43 +00:00
|
|
|
namespace Symfony\Component\Validator;
|
|
|
|
|
2010-08-20 22:09:55 +01:00
|
|
|
use Symfony\Component\Validator\Constraint;
|
2010-06-24 09:40:05 +01:00
|
|
|
|
|
|
|
/**
|
2012-11-22 14:58:46 +00:00
|
|
|
* Validates values and graphs of objects and arrays.
|
2010-06-24 09:40:05 +01:00
|
|
|
*
|
2012-05-26 08:48:33 +01:00
|
|
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
2011-07-20 09:37:57 +01:00
|
|
|
*
|
|
|
|
* @api
|
2010-06-24 09:40:05 +01:00
|
|
|
*/
|
|
|
|
interface ValidatorInterface
|
|
|
|
{
|
2011-01-16 04:41:23 +00:00
|
|
|
/**
|
2012-11-22 14:58:46 +00:00
|
|
|
* Validates a value.
|
2011-01-16 04:41:23 +00:00
|
|
|
*
|
2012-11-22 14:58:46 +00:00
|
|
|
* The accepted values depend on the {@link MetadataFactoryInterface}
|
|
|
|
* implementation.
|
2011-12-13 07:50:54 +00:00
|
|
|
*
|
2012-11-22 14:58:46 +00:00
|
|
|
* @param mixed $value The value to validate
|
|
|
|
* @param array|null $groups The validation groups to validate.
|
|
|
|
* @param Boolean $traverse Whether to traverse the value if it is traversable.
|
|
|
|
* @param Boolean $deep Whether to traverse nested traversable values recursively.
|
|
|
|
*
|
|
|
|
* @return ConstraintViolationListInterface A list of constraint violations. If the
|
|
|
|
* list is empty, validation succeeded.
|
2011-07-20 09:37:57 +01:00
|
|
|
*
|
|
|
|
* @api
|
2011-01-16 04:41:23 +00:00
|
|
|
*/
|
2012-11-22 14:58:46 +00:00
|
|
|
public function validate($value, $groups = null, $traverse = false, $deep = false);
|
2010-06-24 09:40:05 +01:00
|
|
|
|
2011-01-16 04:41:23 +00:00
|
|
|
/**
|
2012-11-22 14:58:46 +00:00
|
|
|
* Validates a property of a value against its current value.
|
|
|
|
*
|
|
|
|
* The accepted values depend on the {@link MetadataFactoryInterface}
|
|
|
|
* implementation.
|
2011-01-16 04:41:23 +00:00
|
|
|
*
|
2012-11-22 14:58:46 +00:00
|
|
|
* @param mixed $containingValue The value containing the property.
|
|
|
|
* @param string $property The name of the property to validate.
|
|
|
|
* @param array|null $groups The validation groups to validate.
|
2011-12-13 07:50:54 +00:00
|
|
|
*
|
2012-11-22 14:58:46 +00:00
|
|
|
* @return ConstraintViolationListInterface A list of constraint violations. If the
|
|
|
|
* list is empty, validation succeeded.
|
2011-07-20 09:37:57 +01:00
|
|
|
*
|
|
|
|
* @api
|
2011-01-16 04:41:23 +00:00
|
|
|
*/
|
2012-11-22 14:58:46 +00:00
|
|
|
public function validateProperty($containingValue, $property, $groups = null);
|
2010-06-24 09:40:05 +01:00
|
|
|
|
2011-01-16 04:41:23 +00:00
|
|
|
/**
|
2012-11-22 14:58:46 +00:00
|
|
|
* Validate a property of a value against a potential value.
|
|
|
|
*
|
|
|
|
* The accepted values depend on the {@link MetadataFactoryInterface}
|
|
|
|
* implementation.
|
2011-01-16 04:41:23 +00:00
|
|
|
*
|
2012-11-22 14:58:46 +00:00
|
|
|
* @param string $containingValue The value containing the property.
|
|
|
|
* @param string $property The name of the property to validate
|
|
|
|
* @param string $value The value to validate against the
|
|
|
|
* constraints of the property.
|
|
|
|
* @param array|null $groups The validation groups to validate.
|
2011-12-13 07:50:54 +00:00
|
|
|
*
|
2012-11-22 14:58:46 +00:00
|
|
|
* @return ConstraintViolationListInterface A list of constraint violations. If the
|
|
|
|
* list is empty, validation succeeded.
|
2011-07-20 09:37:57 +01:00
|
|
|
*
|
|
|
|
* @api
|
2011-01-16 04:41:23 +00:00
|
|
|
*/
|
2012-11-22 14:58:46 +00:00
|
|
|
public function validatePropertyValue($containingValue, $property, $value, $groups = null);
|
2010-06-24 09:40:05 +01:00
|
|
|
|
2011-01-16 04:41:23 +00:00
|
|
|
/**
|
2012-11-22 14:58:46 +00:00
|
|
|
* Validates a value against a constraint or a list of constraints.
|
2011-01-16 04:41:23 +00:00
|
|
|
*
|
2012-11-22 14:58:46 +00:00
|
|
|
* @param mixed $value The value to validate.
|
|
|
|
* @param Constraint|Constraint[] $constraints The constraint(s) to validate against.
|
|
|
|
* @param array|null $groups The validation groups to validate.
|
2011-12-13 07:50:54 +00:00
|
|
|
*
|
2012-11-22 14:58:46 +00:00
|
|
|
* @return ConstraintViolationListInterface A list of constraint violations. If the
|
|
|
|
* list is empty, validation succeeded.
|
2011-07-20 09:37:57 +01:00
|
|
|
*
|
|
|
|
* @api
|
2011-01-16 04:41:23 +00:00
|
|
|
*/
|
2012-11-22 14:58:46 +00:00
|
|
|
public function validateValue($value, $constraints, $groups = null);
|
2011-04-22 16:41:21 +01:00
|
|
|
|
|
|
|
/**
|
2012-11-22 14:58:46 +00:00
|
|
|
* Returns the factory for metadata instances.
|
2011-04-22 16:41:21 +01:00
|
|
|
*
|
2012-11-22 14:58:46 +00:00
|
|
|
* @return MetadataFactoryInterface The metadata factory.
|
2011-07-20 09:37:57 +01:00
|
|
|
*
|
|
|
|
* @api
|
2011-04-22 16:41:21 +01:00
|
|
|
*/
|
2012-07-09 13:50:58 +01:00
|
|
|
public function getMetadataFactory();
|
2011-06-08 11:16:48 +01:00
|
|
|
}
|