Closed
Description
Description
Q | A |
---|---|
Branch? | 6.3 |
Bug Fix? | no |
New Feature? | yes |
Deprecations? | no |
Tickets | PR 43004 |
Feature: [Serializer] DiscrminatorMap: Improved error message
At the moment we get a Serializer Exception when a value is not in the discrminatorMap.
Symfony\Component\Serializer\Normalizer\AbstractObjectNormalizer.php Line: 813
{
"message": "Serializer exception: The type \"type\" is not a valid value."
}
This was merged after this issue was implemented: PR 43004
The new feature would contain extra information about the allowed values and/or a custom error message.
Example
Proposal
- Additional information about the allowed values:
Symfony\Component\Serializer\Normalizer\AbstractObjectNormalizer.php Line: 813
$allowedValues = implode(', ', array_keys($mapping->getTypesMapping()))
throw NotNormalizableValueException::createForUnexpectedDataType(sprintf('The type "%s" is not a valid value, allowed values: %s.', $type, $allowedValues), $type, ['string'], isset($context['deserialization_path']) ? $context['deserialization_path'].'.'.$mapping->getTypeProperty() : $mapping->getTypeProperty(), true);
- A custom error message
I can make a PR if this is found useful.
Metadata
Metadata
Assignees
Labels
DX = Developer eXperience (anything that improves the experience of using Symfony)DX = Developer eXperience (anything that improves the experience of using Symfony)