New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make deserialization of `None` consistent across fields #111

Closed
sloria opened this Issue Dec 22, 2014 · 1 comment

Comments

Projects
None yet
1 participant
@sloria
Member

sloria commented Dec 22, 2014

Currently, number and string (Str, Int, Float, etc.) handle None differently from time-related fields (DateTime, Date, etc.).

Number and string fields deserialize the the field's default value, whereas the time-related fields raise an error.

from marshmallow import fields

fields.Int().deserialize(None)  # 0
fields.Str().deserialize(None)  # ''
fields.DateTime().deserialize(None)  # UnmarshallingError

Possible solution

Once #76 is implemented, passing allow_none=True to a field will make it deserialize None to the field's default. If allow_none=False, an error is raised when deserialzing None.

@sloria sloria added this to the 2.0-a milestone Dec 22, 2014

@sloria

This comment has been minimized.

Member

sloria commented Jan 17, 2015

Resolved by a1308a3

@sloria sloria closed this Jan 17, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment