8000 [Serializer] Normalize constraint violation parameters · symfony/symfony@32c90eb · GitHub
[go: up one dir, main page]

Skip to content

Commit 32c90eb

Browse files
committed
[Serializer] Normalize constraint violation parameters
1 parent 3895acd commit 32c90eb

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

src/Symfony/Component/Serializer/CHANGELOG.md

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

4+
4.3.0
5+
-----
6+
7+
* added the list of constraint violations' parameters in `ConstraintViolationListNormalizer`
8+
49
4.2.0
510
-----
611

src/Symfony/Component/Serializer/Normalizer/ConstraintViolationListNormalizer.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ public function normalize($object, $format = null, array $context = [])
4949
$violationEntry = [
5050
'propertyPath' => $propertyPath,
5151
'title' => $violation->getMessage(),
52+
'parameters' => $violation->getParameters(),
5253
];
5354
if (null !== $code = $violation->getCode()) {
5455
$violationEntry['type'] = sprintf('urn:uuid:%s', $code);

src/Symfony/Component/Serializer/Tests/Normalizer/ConstraintViolationListNormalizerTest.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function testSupportsNormalization()
3838
public function testNormalize()
3939
{
4040
$list = new ConstraintViolationList([
41-
new ConstraintViolation('a', 'b', [], 'c', 'd', 'e', null, 'f'),
41+
new ConstraintViolation('a', 'b', ['value' => 'foo'], 'c', 'd', 'e', null, 'f'),
4242
new ConstraintViolation('1', '2', [], '3', '4', '5', null, '6'),
4343
]);
4444

@@ -52,11 +52,15 @@ public function testNormalize()
5252
'propertyPath' => 'd',
5353
'title' => 'a',
5454
'type' => 'urn:uuid:f',
55+
'parameters' => [
56+
'value' => 'foo',
57+
],
5558
],
5659
[
5760
'propertyPath' => '4',
5861
'title' => '1',
5962
'type' => 'urn:uuid:6',
63+
'parameters' => [],
6064
],
6165
],
6266
];

0 commit comments

Comments
 (0)
0