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