diff --git a/src/Serializer/AbstractConstraintViolationListNormalizer.php b/src/Serializer/AbstractConstraintViolationListNormalizer.php index 35907174547..b602c7de4b8 100644 --- a/src/Serializer/AbstractConstraintViolationListNormalizer.php +++ b/src/Serializer/AbstractConstraintViolationListNormalizer.php @@ -80,6 +80,10 @@ protected function getMessagesAndViolations(ConstraintViolationListInterface $co $violationData['hint'] = $hint; } + if ($cause = $violation->getCause() ?? false) { + $violationData['cause'] = $cause; + } + $constraint = $violation instanceof ConstraintViolation ? $violation->getConstraint() : null; if ( [] !== $this->serializePayloadFields