Distinguish null from empty string for UUID deserialization
See original GitHub issueFor UUID deserialization, empty string is mapped to null
by FromStringDeserializer. So something like {"parent_uuid": null}
can’t be distinguished from {"parent_uuid": ""}
. From the view of a strict API, the latter is an error.
It would be good to add some feature like “STRICT_STRING_VALUE”, that FromStringDeserializer does not trim or shortcut empty strings so that UUID deserializer could report the error.
This may be an opposite feature of #768 ACCEPT_EMPTY_STRING_AS_NULL_OBJECT.
Issue Analytics
- State:
- Created 5 years ago
- Comments:8 (6 by maintainers)
Top Results From Across the Web
Automaticaly convert empty strings to null in Java using JsonB ...
I encountered this problem on migration from Jackson to Jsonb where empty string value in request produces deserialization exception since it ...
Read more >Uuid Library - 1.73.0
Distributed computing may use UUIDs to identify a remote procedure call. Transactions and classes involved in serialization may be identified by UUIDs.
Read more >Using Optional and Nullable Properties in API Requests
Learn how optional and nullable properties can be used flexibly in combinations in each parameter of your API requests made from a SDK....
Read more >The Serializer Component (Symfony Docs)
The Serializer component allows you to serialize and deserialize these objects using a "discriminator class mapping". The discriminator is the field (in the ......
Read more >How to Serialize Data With Django REST Framework
Django REST offers serialization and deserialization of data and above that it offers data ... avatar = CloudinaryField('image', blank=True, null=True).
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
So, implemented using new “CoercionConfigs” system; test
CoerceMiscScalarsTest
has full verification forUUID
as well as other types. Default behavior in 2.12 NOT changed.To make coercion from empty String fail only for UUID, you can use:
or to change handling of most similar scalar types:
or, even, if you really want, prevent it by most types (unless overridden by more-specific setting:
Alternatively you can use
CoercionAction.AsNull
to allow coercion tonull
, or,CoercionAction.AsEmpty
to get “all-zeroes” UUID constructed.hi, new contributor 😃 can I try this one?