-
-
Notifications
You must be signed in to change notification settings - Fork 637
Open
Description
I saw already comments how to workaround this issue:
#229 (comment)
#229 (comment)
But still I would like to marshmallow to be consistent with itself.
Basically you have a schema with allow_none=False and after dumping it you cannot load it back (without manually fixing the output that is not correct according to schema).
import marshmallow
class TransferSchema(marshmallow.Schema):
id = marshmallow.fields.Int(allow_none=False)
str = marshmallow.fields.Str(allow_none=False)
x = TransferSchema()
dumped = x.dump({
'id': None,
'str': None,
})
print(dumped)
loaded = x.load(dumped)
print(loaded)
error:
marshmallow.exceptions.ValidationError: {'id': ['Field may not be null.'], 'str': ['Field may not be null.']}
I think allow_none should be respected for both on serialize and deserialize.
Metadata
Metadata
Assignees
Labels
No labels