Skip to content

Commit a9e2199

Browse files
committed
re-add accidentally removed changelog examples
1 parent 5252284 commit a9e2199

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

CHANGELOG.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,55 @@ CHANGELOG
66

77
* Add the `filenameCharset` and `filenameCountUnit` options to the `File` constraint
88
* Deprecate defining custom constraints not supporting named arguments
9+
10+
Before:
11+
12+
```php
13+
use Symfony\Component\Validator\Constraint;
14+
15+
class CustomConstraint extends Constraint
16+
{
17+
public function __construct(array $options)
18+
{
19+
// ...
20+
}
21+
}
22+
```
23+
24+
After:
25+
26+
```php
27+
use Symfony\Component\Validator\Attribute\HasNamedArguments;
28+
use Symfony\Component\Validator\Constraint;
29+
30+
class CustomConstraint extends Constraint
31+
{
32+
#[HasNamedArguments]
33+
public function __construct($option1, $option2, $groups, $payload)
34+
{
35+
// ...
36+
}
37+
}
38+
```
939
* Deprecate passing an array of options to the constructors of the constraint classes, pass each option as a dedicated argument instead
40+
41+
Before:
42+
43+
```php
44+
new NotNull([
45+
'groups' => ['foo', 'bar'],
46+
'message' => 'a custom constraint violation message',
47+
])
48+
```
49+
50+
After:
51+
52+
```php
53+
new NotNull(
54+
groups: ['foo', 'bar'],
55+
message: 'a custom constraint violation message',
56+
)
57+
```
1058
* Add support for ratio checks for SVG files to the `Image` constraint
1159
* Add support for the `otherwise` option in the `When` constraint
1260
* Add support for multiple fields containing nested constraints in `Composite` constraints

0 commit comments

Comments
 (0)