Skip to content

Commit 23074e9

Browse files
committed
feature #18037 Add BackedEnumNormalizer::ALLOW_INVALID_VALUES context option (alamirault)
This PR was merged into the 6.3 branch. Discussion ---------- Add `BackedEnumNormalizer::ALLOW_INVALID_VALUES` context option Fix #18000 Add doc for `BackedEnumNormalizer::ALLOW_INVALID_VALUES` context option Commits ------- f6d4b6c Document BackedEnumNormalizer::ALLOW_INVALID_VALUES context option
2 parents 01afda2 + f6d4b6c commit 23074e9

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

components/serializer.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -851,6 +851,13 @@ The Serializer component provides several built-in normalizers:
851851
:class:`Symfony\\Component\\Serializer\\Normalizer\\BackedEnumNormalizer`
852852
This normalizer converts a \BackedEnum objects into strings or integers.
853853

854+
By default, it throw an exception when data is not belong to a backed enumeration. If you
855+
want ``null`` instead, you can set the ``BackedEnumNormalizer::ALLOW_INVALID_VALUES`` option.
856+
857+
.. versionadded:: 6.3
858+
859+
The ``BackedEnumNormalizer::ALLOW_INVALID_VALUES`` context option was introduced in Symfony 6.3.
860+
854861
:class:`Symfony\\Component\\Serializer\\Normalizer\\FormErrorNormalizer`
855862
This normalizer works with classes that implement
856863
:class:`Symfony\\Component\\Form\\FormInterface`.

0 commit comments

Comments
 (0)