-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
Closed
Labels
RFCRFC = Request For Comments (proposals about features that you want to be discussed)RFC = Request For Comments (proposals about features that you want to be discussed)Serializer
Description
Description
ATM, if the client send a malformated date (or something else) in a field mapped as DateTime
, an exception occurs.
Symfony\Component\Serializer\Exception\NotNormalizableValueException:
DateTimeImmutable::__construct(): Failed to parse time string (2018-08-0111111) at position 14 (1): Unexpected character
at vendor/symfony/symfony/src/Symfony/Component/Serializer/Normalizer/DateTimeNormalizer.php:116
at Symfony\Component\Serializer\Normalizer\DateTimeNormalizer->denormalize('2018-08-0111111', 'DateTimeImmutable', 'json', array('cache_key' => '6de9eb2685609b8387658584987a05b0'))
(vendor/symfony/symfony/src/Symfony/Component/Serializer/Serializer.php:182)
at Symfony\Component\Serializer\Serializer->denormalize('2018-08-0111111', 'DateTimeImmutable', 'json', array('cache_key' => '6de9eb2685609b8387658584987a05b0'))
# ...
By default this Exception is not catched and leads to a 500
Even If we put some validation, the validation comes after ... So this is not related
Example
IMHO, it would be better to not throw an exception, then the validator (if exist) will add a violation on the property
Maybe this idea could be extended to others normalizer
ping @dunglas
damienalexandre, yceruto, BoShurik, errogaht, ymarillet and 9 more
Metadata
Metadata
Assignees
Labels
RFCRFC = Request For Comments (proposals about features that you want to be discussed)RFC = Request For Comments (proposals about features that you want to be discussed)Serializer