[Serializer] Normalize constraint violation parameters
This commit is contained in:
parent
3895acd175
commit
32c90ebc8e
@ -1,6 +1,11 @@
|
|||||||
CHANGELOG
|
CHANGELOG
|
||||||
=========
|
=========
|
||||||
|
|
||||||
|
4.3.0
|
||||||
|
-----
|
||||||
|
|
||||||
|
* added the list of constraint violations' parameters in `ConstraintViolationListNormalizer`
|
||||||
|
|
||||||
4.2.0
|
4.2.0
|
||||||
-----
|
-----
|
||||||
|
|
||||||
|
@ -49,6 +49,7 @@ class ConstraintViolationListNormalizer implements NormalizerInterface, Cacheabl
|
|||||||
$violationEntry = [
|
$violationEntry = [
|
||||||
'propertyPath' => $propertyPath,
|
'propertyPath' => $propertyPath,
|
||||||
'title' => $violation->getMessage(),
|
'title' => $violation->getMessage(),
|
||||||
|
'parameters' => $violation->getParameters(),
|
||||||
];
|
];
|
||||||
if (null !== $code = $violation->getCode()) {
|
if (null !== $code = $violation->getCode()) {
|
||||||
$violationEntry['type'] = sprintf('urn:uuid:%s', $code);
|
$violationEntry['type'] = sprintf('urn:uuid:%s', $code);
|
||||||
|
@ -38,7 +38,7 @@ class ConstraintViolationListNormalizerTest extends TestCase
|
|||||||
public function testNormalize()
|
public function testNormalize()
|
||||||
{
|
{
|
||||||
$list = new ConstraintViolationList([
|
$list = new ConstraintViolationList([
|
||||||
new ConstraintViolation('a', 'b', [], 'c', 'd', 'e', null, 'f'),
|
new ConstraintViolation('a', 'b', ['value' => 'foo'], 'c', 'd', 'e', null, 'f'),
|
||||||
new ConstraintViolation('1', '2', [], '3', '4', '5', null, '6'),
|
new ConstraintViolation('1', '2', [], '3', '4', '5', null, '6'),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@ -52,11 +52,15 @@ class ConstraintViolationListNormalizerTest extends TestCase
|
|||||||
'propertyPath' => 'd',
|
'propertyPath' => 'd',
|
||||||
'title' => 'a',
|
'title' => 'a',
|
||||||
'type' => 'urn:uuid:f',
|
'type' => 'urn:uuid:f',
|
||||||
|
'parameters' => [
|
||||||
|
'value' => 'foo',
|
||||||
|
],
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'propertyPath' => '4',
|
'propertyPath' => '4',
|
||||||
'title' => '1',
|
'title' => '1',
|
||||||
'type' => 'urn:uuid:6',
|
'type' => 'urn:uuid:6',
|
||||||
|
'parameters' => [],
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
Reference in New Issue
Block a user