[Validator] Moved constraints Optional and Required to the Constraints\ namespace
This commit is contained in:
parent
9b6d30cf37
commit
a868048a82
@ -113,3 +113,37 @@ UPGRADE FROM 2.x to 3.0
|
|||||||
```
|
```
|
||||||
Yaml::parse(file_get_contents($fileName));
|
Yaml::parse(file_get_contents($fileName));
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Validator
|
||||||
|
|
||||||
|
* The constraints `Optional` and `Required` were moved to the
|
||||||
|
`Symfony\Component\Validator\Constraints\` namespace. You should adapt
|
||||||
|
the path wherever you used them.
|
||||||
|
|
||||||
|
Before:
|
||||||
|
|
||||||
|
```
|
||||||
|
use Symfony\Component\Validator\Constraints as Assert;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Assert\Collection({
|
||||||
|
* "foo" = @Assert\Collection\Required(),
|
||||||
|
* "bar" = @Assert\Collection\Optional(),
|
||||||
|
* })
|
||||||
|
*/
|
||||||
|
private $property;
|
||||||
|
```
|
||||||
|
|
||||||
|
After:
|
||||||
|
|
||||||
|
```
|
||||||
|
use Symfony\Component\Validator\Constraints as Assert;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Assert\Collection({
|
||||||
|
* "foo" = @Assert\Required(),
|
||||||
|
* "bar" = @Assert\Optional(),
|
||||||
|
* })
|
||||||
|
*/
|
||||||
|
private $property;
|
||||||
|
```
|
||||||
|
@ -1,6 +1,13 @@
|
|||||||
CHANGELOG
|
CHANGELOG
|
||||||
=========
|
=========
|
||||||
|
|
||||||
|
2.3.0
|
||||||
|
-----
|
||||||
|
|
||||||
|
* copied the constraints `Optional` and `Required` to the
|
||||||
|
`Symfony\Component\Validator\Constraints\` namespace and deprecated the original
|
||||||
|
classes.
|
||||||
|
|
||||||
2.2.0
|
2.2.0
|
||||||
-----
|
-----
|
||||||
|
|
||||||
|
@ -17,6 +17,8 @@ use Symfony\Component\Validator\Exception\ConstraintDefinitionException;
|
|||||||
/**
|
/**
|
||||||
* @Annotation
|
* @Annotation
|
||||||
*
|
*
|
||||||
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
|
*
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
class All extends Constraint
|
class All extends Constraint
|
||||||
|
@ -16,6 +16,8 @@ use Symfony\Component\Validator\Constraint;
|
|||||||
/**
|
/**
|
||||||
* @Annotation
|
* @Annotation
|
||||||
*
|
*
|
||||||
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
|
*
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
class Blank extends Constraint
|
class Blank extends Constraint
|
||||||
|
@ -16,6 +16,8 @@ use Symfony\Component\Validator\Constraint;
|
|||||||
/**
|
/**
|
||||||
* @Annotation
|
* @Annotation
|
||||||
*
|
*
|
||||||
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
|
*
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
class Callback extends Constraint
|
class Callback extends Constraint
|
||||||
|
@ -16,6 +16,8 @@ use Symfony\Component\Validator\Constraint;
|
|||||||
/**
|
/**
|
||||||
* @Annotation
|
* @Annotation
|
||||||
*
|
*
|
||||||
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
|
*
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
class Choice extends Constraint
|
class Choice extends Constraint
|
||||||
|
@ -12,13 +12,15 @@
|
|||||||
namespace Symfony\Component\Validator\Constraints;
|
namespace Symfony\Component\Validator\Constraints;
|
||||||
|
|
||||||
use Symfony\Component\Validator\Constraint;
|
use Symfony\Component\Validator\Constraint;
|
||||||
use Symfony\Component\Validator\Constraints\Collection\Required;
|
use Symfony\Component\Validator\Constraints\Required;
|
||||||
use Symfony\Component\Validator\Constraints\Collection\Optional;
|
use Symfony\Component\Validator\Constraints\Optional;
|
||||||
use Symfony\Component\Validator\Exception\ConstraintDefinitionException;
|
use Symfony\Component\Validator\Exception\ConstraintDefinitionException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Annotation
|
* @Annotation
|
||||||
*
|
*
|
||||||
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
|
*
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
class Collection extends Constraint
|
class Collection extends Constraint
|
||||||
|
@ -11,17 +11,16 @@
|
|||||||
|
|
||||||
namespace Symfony\Component\Validator\Constraints\Collection;
|
namespace Symfony\Component\Validator\Constraints\Collection;
|
||||||
|
|
||||||
use Symfony\Component\Validator\Constraint;
|
use Symfony\Component\Validator\Constraints\Optional as BaseOptional;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Annotation
|
* @Annotation
|
||||||
|
*
|
||||||
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
|
*
|
||||||
|
* @deprecated Deprecated in 2.3, to be removed in 3.0. Use
|
||||||
|
* {@link \Symfony\Component\Validator\Constraints\Optional} instead.
|
||||||
*/
|
*/
|
||||||
class Optional extends Constraint
|
class Optional extends BaseOptional
|
||||||
{
|
{
|
||||||
public $constraints = array();
|
|
||||||
|
|
||||||
public function getDefaultOption()
|
|
||||||
{
|
|
||||||
return 'constraints';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -11,17 +11,16 @@
|
|||||||
|
|
||||||
namespace Symfony\Component\Validator\Constraints\Collection;
|
namespace Symfony\Component\Validator\Constraints\Collection;
|
||||||
|
|
||||||
use Symfony\Component\Validator\Constraint;
|
use Symfony\Component\Validator\Constraints\Required as BaseRequired;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Annotation
|
* @Annotation
|
||||||
|
*
|
||||||
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
|
*
|
||||||
|
* @deprecated Deprecated in 2.3, to be removed in 3.0. Use
|
||||||
|
* {@link \Symfony\Component\Validator\Constraints\Required} instead.
|
||||||
*/
|
*/
|
||||||
class Required extends Constraint
|
class Required extends BaseRequired
|
||||||
{
|
{
|
||||||
public $constraints = array();
|
|
||||||
|
|
||||||
public function getDefaultOption()
|
|
||||||
{
|
|
||||||
return 'constraints';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ namespace Symfony\Component\Validator\Constraints;
|
|||||||
use Symfony\Component\Validator\Constraint;
|
use Symfony\Component\Validator\Constraint;
|
||||||
use Symfony\Component\Validator\ConstraintValidator;
|
use Symfony\Component\Validator\ConstraintValidator;
|
||||||
use Symfony\Component\Validator\Exception\UnexpectedTypeException;
|
use Symfony\Component\Validator\Exception\UnexpectedTypeException;
|
||||||
use Symfony\Component\Validator\Constraints\Collection\Optional;
|
use Symfony\Component\Validator\Constraints\Optional;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
|
@ -17,6 +17,8 @@ use Symfony\Component\Validator\Exception\MissingOptionsException;
|
|||||||
/**
|
/**
|
||||||
* @Annotation
|
* @Annotation
|
||||||
*
|
*
|
||||||
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
|
*
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
class Count extends Constraint
|
class Count extends Constraint
|
||||||
|
@ -16,6 +16,8 @@ use Symfony\Component\Validator\Constraint;
|
|||||||
/**
|
/**
|
||||||
* @Annotation
|
* @Annotation
|
||||||
*
|
*
|
||||||
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
|
*
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
class Country extends Constraint
|
class Country extends Constraint
|
||||||
|
@ -16,6 +16,8 @@ use Symfony\Component\Validator\Constraint;
|
|||||||
/**
|
/**
|
||||||
* @Annotation
|
* @Annotation
|
||||||
*
|
*
|
||||||
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
|
*
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
class Date extends Constraint
|
class Date extends Constraint
|
||||||
|
@ -16,6 +16,8 @@ use Symfony\Component\Validator\Constraint;
|
|||||||
/**
|
/**
|
||||||
* @Annotation
|
* @Annotation
|
||||||
*
|
*
|
||||||
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
|
*
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
class DateTime extends Constraint
|
class DateTime extends Constraint
|
||||||
|
@ -16,6 +16,8 @@ use Symfony\Component\Validator\Constraint;
|
|||||||
/**
|
/**
|
||||||
* @Annotation
|
* @Annotation
|
||||||
*
|
*
|
||||||
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
|
*
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
class Email extends Constraint
|
class Email extends Constraint
|
||||||
|
27
src/Symfony/Component/Validator/Constraints/Existence.php
Normal file
27
src/Symfony/Component/Validator/Constraints/Existence.php
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Symfony package.
|
||||||
|
*
|
||||||
|
* (c) Fabien Potencier <fabien@symfony.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Symfony\Component\Validator\Constraints;
|
||||||
|
|
||||||
|
use Symfony\Component\Validator\Constraint;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
|
*/
|
||||||
|
abstract class Existence extends Constraint
|
||||||
|
{
|
||||||
|
public $constraints = array();
|
||||||
|
|
||||||
|
public function getDefaultOption()
|
||||||
|
{
|
||||||
|
return 'constraints';
|
||||||
|
}
|
||||||
|
}
|
@ -16,6 +16,8 @@ use Symfony\Component\Validator\Constraint;
|
|||||||
/**
|
/**
|
||||||
* @Annotation
|
* @Annotation
|
||||||
*
|
*
|
||||||
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
|
*
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
class False extends Constraint
|
class False extends Constraint
|
||||||
|
@ -16,6 +16,8 @@ use Symfony\Component\Validator\Constraint;
|
|||||||
/**
|
/**
|
||||||
* @Annotation
|
* @Annotation
|
||||||
*
|
*
|
||||||
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
|
*
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
class File extends Constraint
|
class File extends Constraint
|
||||||
|
@ -15,6 +15,7 @@ namespace Symfony\Component\Validator\Constraints;
|
|||||||
* Annotation for group sequences
|
* Annotation for group sequences
|
||||||
*
|
*
|
||||||
* @Annotation
|
* @Annotation
|
||||||
|
*
|
||||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
*
|
*
|
||||||
* @api
|
* @api
|
||||||
|
@ -18,6 +18,7 @@ use Symfony\Component\Validator\Constraint;
|
|||||||
* Validates that a value is a valid IP address
|
* Validates that a value is a valid IP address
|
||||||
*
|
*
|
||||||
* @Annotation
|
* @Annotation
|
||||||
|
*
|
||||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
* @author Joseph Bielawski <stloyd@gmail.com>
|
* @author Joseph Bielawski <stloyd@gmail.com>
|
||||||
*
|
*
|
||||||
|
@ -16,6 +16,8 @@ use Symfony\Component\Validator\Constraint;
|
|||||||
/**
|
/**
|
||||||
* @Annotation
|
* @Annotation
|
||||||
*
|
*
|
||||||
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
|
*
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
class Language extends Constraint
|
class Language extends Constraint
|
||||||
|
@ -17,6 +17,8 @@ use Symfony\Component\Validator\Exception\MissingOptionsException;
|
|||||||
/**
|
/**
|
||||||
* @Annotation
|
* @Annotation
|
||||||
*
|
*
|
||||||
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
|
*
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
class Length extends Constraint
|
class Length extends Constraint
|
||||||
|
@ -16,6 +16,8 @@ use Symfony\Component\Validator\Constraint;
|
|||||||
/**
|
/**
|
||||||
* @Annotation
|
* @Annotation
|
||||||
*
|
*
|
||||||
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
|
*
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
class Locale extends Constraint
|
class Locale extends Constraint
|
||||||
|
@ -16,6 +16,8 @@ use Symfony\Component\Validator\Constraint;
|
|||||||
/**
|
/**
|
||||||
* @Annotation
|
* @Annotation
|
||||||
*
|
*
|
||||||
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
|
*
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
class NotBlank extends Constraint
|
class NotBlank extends Constraint
|
||||||
|
@ -15,6 +15,8 @@ use Symfony\Component\Validator\Constraint;
|
|||||||
use Symfony\Component\Validator\ConstraintValidator;
|
use Symfony\Component\Validator\ConstraintValidator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
|
*
|
||||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
*
|
*
|
||||||
* @api
|
* @api
|
||||||
|
@ -16,6 +16,8 @@ use Symfony\Component\Validator\Constraint;
|
|||||||
/**
|
/**
|
||||||
* @Annotation
|
* @Annotation
|
||||||
*
|
*
|
||||||
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
|
*
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
class NotNull extends Constraint
|
class NotNull extends Constraint
|
||||||
|
@ -16,6 +16,8 @@ use Symfony\Component\Validator\Constraint;
|
|||||||
/**
|
/**
|
||||||
* @Annotation
|
* @Annotation
|
||||||
*
|
*
|
||||||
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
|
*
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
class Null extends Constraint
|
class Null extends Constraint
|
||||||
|
21
src/Symfony/Component/Validator/Constraints/Optional.php
Normal file
21
src/Symfony/Component/Validator/Constraints/Optional.php
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Symfony package.
|
||||||
|
*
|
||||||
|
* (c) Fabien Potencier <fabien@symfony.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Symfony\Component\Validator\Constraints;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Annotation
|
||||||
|
*
|
||||||
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
|
*/
|
||||||
|
class Optional extends Existence
|
||||||
|
{
|
||||||
|
}
|
@ -17,6 +17,8 @@ use Symfony\Component\Validator\Exception\MissingOptionsException;
|
|||||||
/**
|
/**
|
||||||
* @Annotation
|
* @Annotation
|
||||||
*
|
*
|
||||||
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
|
*
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
class Range extends Constraint
|
class Range extends Constraint
|
||||||
|
@ -16,6 +16,8 @@ use Symfony\Component\Validator\Constraint;
|
|||||||
/**
|
/**
|
||||||
* @Annotation
|
* @Annotation
|
||||||
*
|
*
|
||||||
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
|
*
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
class Regex extends Constraint
|
class Regex extends Constraint
|
||||||
|
21
src/Symfony/Component/Validator/Constraints/Required.php
Normal file
21
src/Symfony/Component/Validator/Constraints/Required.php
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Symfony package.
|
||||||
|
*
|
||||||
|
* (c) Fabien Potencier <fabien@symfony.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Symfony\Component\Validator\Constraints;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Annotation
|
||||||
|
*
|
||||||
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
|
*/
|
||||||
|
class Required extends Existence
|
||||||
|
{
|
||||||
|
}
|
@ -16,6 +16,8 @@ use Symfony\Component\Validator\Constraint;
|
|||||||
/**
|
/**
|
||||||
* @Annotation
|
* @Annotation
|
||||||
*
|
*
|
||||||
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
|
*
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
class Time extends Constraint
|
class Time extends Constraint
|
||||||
|
@ -16,6 +16,8 @@ use Symfony\Component\Validator\Constraint;
|
|||||||
/**
|
/**
|
||||||
* @Annotation
|
* @Annotation
|
||||||
*
|
*
|
||||||
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
|
*
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
class True extends Constraint
|
class True extends Constraint
|
||||||
|
@ -16,6 +16,8 @@ use Symfony\Component\Validator\Constraint;
|
|||||||
/**
|
/**
|
||||||
* @Annotation
|
* @Annotation
|
||||||
*
|
*
|
||||||
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
|
*
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
class Type extends Constraint
|
class Type extends Constraint
|
||||||
|
@ -16,6 +16,8 @@ use Symfony\Component\Validator\Constraint;
|
|||||||
/**
|
/**
|
||||||
* @Annotation
|
* @Annotation
|
||||||
*
|
*
|
||||||
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
|
*
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
class Url extends Constraint
|
class Url extends Constraint
|
||||||
|
@ -17,6 +17,8 @@ use Symfony\Component\Validator\Exception\ConstraintDefinitionException;
|
|||||||
/**
|
/**
|
||||||
* @Annotation
|
* @Annotation
|
||||||
*
|
*
|
||||||
|
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||||
|
*
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
class Valid extends Constraint
|
class Valid extends Constraint
|
||||||
|
@ -12,8 +12,8 @@
|
|||||||
namespace Symfony\Component\Validator\Tests\Constraints;
|
namespace Symfony\Component\Validator\Tests\Constraints;
|
||||||
|
|
||||||
use Symfony\Component\Validator\Constraints\Collection;
|
use Symfony\Component\Validator\Constraints\Collection;
|
||||||
use Symfony\Component\Validator\Constraints\Collection\Required;
|
use Symfony\Component\Validator\Constraints\Required;
|
||||||
use Symfony\Component\Validator\Constraints\Collection\Optional;
|
use Symfony\Component\Validator\Constraints\Optional;
|
||||||
use Symfony\Component\Validator\Constraints\Valid;
|
use Symfony\Component\Validator\Constraints\Valid;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -11,11 +11,10 @@
|
|||||||
|
|
||||||
namespace Symfony\Component\Validator\Tests\Constraints;
|
namespace Symfony\Component\Validator\Tests\Constraints;
|
||||||
|
|
||||||
use Symfony\Component\Validator\ExecutionContext;
|
|
||||||
use Symfony\Component\Validator\Constraints\Range;
|
use Symfony\Component\Validator\Constraints\Range;
|
||||||
use Symfony\Component\Validator\Constraints\NotNull;
|
use Symfony\Component\Validator\Constraints\NotNull;
|
||||||
use Symfony\Component\Validator\Constraints\Collection\Required;
|
use Symfony\Component\Validator\Constraints\Required;
|
||||||
use Symfony\Component\Validator\Constraints\Collection\Optional;
|
use Symfony\Component\Validator\Constraints\Optional;
|
||||||
use Symfony\Component\Validator\Constraints\Collection;
|
use Symfony\Component\Validator\Constraints\Collection;
|
||||||
use Symfony\Component\Validator\Constraints\CollectionValidator;
|
use Symfony\Component\Validator\Constraints\CollectionValidator;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user