8000 [Validator] Moved constraints Optional and Required to the Constraint… · symfony/symfony@a868048 · GitHub
[go: up one dir, main page]

Skip to content

Commit a868048

Browse files
committed
[Validator] Moved constraints Optional and Required to the Constraints\ namespace
1 parent 9b6d30c commit a868048

38 files changed

+185
-24
lines changed

UPGRADE-3.0.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,3 +113,37 @@ UPGRADE FROM 2.x to 3.0
113113
```
114114
Yaml::parse(file_get_contents($fileName));
115115
```
116+
117+
### Validator
118+
119+
* The constraints `Optional` and `Required` were moved to the
120+
`Symfony\Component\Validator\Constraints\` namespace. You should adapt
121+
the path wherever you used them.
122+
123+
Before:
124+
125+
```
126+
use Symfony\Component\Validator\Constraints as Assert;
127+
128+
/**
129+
* @Assert\Collection({
130+
* "foo" = @Assert\Collection\Required(),
131+
* "bar" = @Assert\Collection\Optional(),
132+
* })
133+
*/
134+
private $property;
135+
```
136+
137+
After:
138+
139+
```
140+
use Symfony\Component\Validator\Constraints as Assert;
141+
142+
/**
143+
* @Assert\Collection({
144+
* "foo" = @Assert\Required(),
145+
* "bar" = @Assert\Optional(),
146+
* })
147+
*/
148+
private $property;
149+
```

src/Symfony/Component/Validator/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
CHANGELOG
22
=========
33

4+
2.3.0
5+
-----
6+
7+
* copied the constraints `Optional` and `Required` to the
8+
`Symfony\Component\Validator\Constraints\` namespace and deprecated the original
9+
classes.
10+
411
2.2.0
512
-----
613

src/Symfony/Component/Validator/Constraints/All.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
/**
1818
* @Annotation
1919
*
20+
* @author Bernhard Schussek <bschussek@gmail.com>
21+
*
2022
* @api
2123
*/
2224
class All extends Constraint

src/Symfony/Component/Validator/Constraints/Blank.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
/**
1717
* @Annotation
1818
*
19+
* @author Bernhard Schussek <bschussek@gmail.com>
20+
*
1921
* @api
2022
*/
2123
class Blank extends Constraint

src/Symfony/Component/Validator/Constraints/Callback.php

< 10000 /div>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
/**
1717
* @Annotation
1818
*
19+
* @author Bernhard Schussek <bschussek@gmail.com>
20+
*
1921
* @api
2022
*/
2123
class Callback extends Constraint

src/Symfony/Component/Validator/Constraints/Choice.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
/**
1717
* @Annotation
1818
*
19+
* @author Bernhard Schussek <bschussek@gmail.com>
20+
*
1921
* @api
2022
*/
2123
class Choice extends Constraint

src/Symfony/Component/Validator/Constraints/Collection.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,15 @@
1212
namespace Symfony\Component\Validator\Constraints;
1313

1414
use Symfony\Component\Validator\Constraint;
15-
use Symfony\Component\Validator\Constraints\Collection\Required;
16-
use Symfony\Component\Validator\Constraints\Collection\Optional;
15+
use Symfony\Component\Validator\Constraints\Required;
16+
use Symfony\Component\Validator\Constraints\Optional;
1717
use Symfony\Component\Validator\Exception\ConstraintDefinitionException;
1818

1919
/**
2020
* @Annotation
2121
*
22+
* @author Bernhard Schussek <bschussek@gmail.com>
23+
*
2224
* @api
2325
*/
2426
class Collection extends Constraint

src/Symfony/Component/Validator/Constraints/Collection/Optional.php

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,16 @@
1111

1212
namespace Symfony\Component\Validator\Constraints\Collection;
1313

14-
use Symfony\Component\Validator\Constraint;
14+
use Symfony\Component\Validator\Constraints\Optional as BaseOptional;
1515

1616
/**
1717
* @Annotation
18+
*
19+
* @author Bernhard Schussek <bschussek@gmail.com>
20+
*
21+
* @deprecated Deprecated in 2.3, to be removed in 3.0. Use
22+
* {@link \Symfony\Component\Validator\Constraints\Optional} instead.
1823
*/
19-
class Optional extends Constraint
24+
class Optional extends BaseOptional
2025
{
21-
public $constraints = array();
22-
23-
public function getDefaultOption()
24-
{
25-
return 'constraints';
26-
}
2726
}

src/Symfony/Component/Validator/Constraints/Collection/Required.php

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,16 @@
1111

1212
namespace Symfony\Component\Validator\Constraints\Collection;
1313

14-
use Symfony\Component\Validator\Constraint;
14+
use Symfony\Component\Validator\Constraints\Required as BaseRequired;
1515

1616
/**
1717
* @Annotation
18+
*
19+
* @author Bernhard Schussek <bschussek@gmail.com>
20+
*
21+
* @deprecated Deprecated in 2.3, to be removed in 3.0. Use
22+
* {@link \Symfony\Component\Validator\Constraints\Required} instead.
1823
*/
19-
class Required extends Constraint
24+
class Required extends BaseRequired
2025
{
21-
public $constraints = array();
22-
23-
public function getDefaultOption()
24-
{
25-
return 'constraints';
26-
}
2726
}

src/Symfony/Component/Validator/Constraints/CollectionValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
use Symfony\Component\Validator\Constraint;
1515
use Symfony\Component\Validator\ConstraintValidator;
1616
use Symfony\Component\Validator\Exception\UnexpectedTypeException;
17-
use Symfony\Component\Validator\Constraints\Collection\Optional;
17+
use Symfony\Component\Validator\Constraints\Optional;
1818

1919
/**
2020
* @author Bernhard Schussek <bschussek@gmail.com>

0 commit comments

Comments
 (0)
0