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

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>

src/Symfony/Component/Validator/Constraints/Count.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 Count extends Constraint

src/Symfony/Component/Validator/Constraints/Country.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 Country extends Constraint

src/Symfony/Component/Validator/Constraints/Date.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 Date extends Constraint

src/Symfony/Component/Validator/Constraints/DateTime.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 DateTime extends Constraint

src/Symfony/Component/Validator/Constraints/Email.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 Email extends Constraint
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Validator\Constraints;
13+
14+
use Symfony\Component\Validator\Constraint;
15+
16+
/**
17+
* @author Bernhard Schussek <bschussek@gmail.com>
18+
*/
19+
abstract class Existence extends Constraint
20+
{
21+
public $constraints = array();
22+
23+
public function getDefaultOption()
24+
{
25+
return 'constraints';
26+
}
27+
}

src/Symfony/Component/Validator/Constraints/False.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 False extends Constraint

src/Symfony/Component/Validator/Constraints/File.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 File extends Constraint

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
* Annotation for group sequences
1616
*
1717
* @Annotation
18+
*
1819
* @author Bernhard Schussek <bschussek@gmail.com>
1920
*
2021
* @api

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
* Validates that a value is a valid IP address
1919
*
2020
* @Annotation
21+
*
2122
* @author Bernhard Schussek <bschussek@gmail.com>
2223
* @author Joseph Bielawski <stloyd@gmail.com>
2324
*

src/Symfony/Component/Validator/Constraints/Language.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 Language extends Constraint

src/Symfony/Component/Validator/Constraints/Length.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 Length extends Constraint

src/Symfony/Component/Validator/Constraints/Locale.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 Locale extends Constraint

src/Symfony/Component/Validator/Constraints/NotBlank.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 NotBlank extends Constraint

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
use Symfony\Component\Validator\ConstraintValidator;
1616

1717
/**
18+
* @author Bernhard Schussek <bschussek@gmail.com>
19+
*
1820
* @author Bernhard Schussek <bschussek@gmail.com>
1921
*
2022
* @api

src/Symfony/Component/Validator/Constraints/NotNull.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 NotNull extends Constraint

src/Symfony/Component/Validator/Constraints/Null.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 Null extends Constraint
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Validator\Constraints;
13+
14+
/**
15+
* @Annotation
16+
*
17+
* @author Bernhard Schussek <bschussek@gmail.com>
18+
*/
19+
class Optional extends Existence
20+
{
21+
}

src/Symfony/Component/Validator/Constraints/Range.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 Range extends Constraint

src/Symfony/Component/Validator/Constraints/Regex.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 Regex extends Constraint
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Validator\Constraints;
13+
14+
/**
15+
* @Annotation
16+
*
17+
* @author Bernhard Schussek <bschussek@gmail.com>
18+
*/
19+
class Required extends Existence
20+
{
21+
}

0 commit comments

Comments
 (0)
0