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

Null Booleans Deserialize to False #213

Closed
cmanallen opened this Issue May 8, 2015 · 1 comment

Comments

Projects
None yet
2 participants
@cmanallen

cmanallen commented May 8, 2015

I have a boolean field that is required only if some other field is filled in (I cannot specify required=True on the dependent field). So I've written a schema validator to check: if first_field is True then second_field is required.

This dependent boolean field is not something that can default to true or false. If a user does not fill in the boolean field, I would like Marshmallow to throw a validation error. However, because null booleans automatically deserialize to False, I cannot check if the boolean came in as None or False.

Is there a way to prevent this behavior?

sloria added a commit that referenced this issue May 9, 2015

Boolean field serializes None to None
For consistency with other fields
Add regression test against all fields
Closes issue #213
@sloria

This comment has been minimized.

Member

sloria commented May 9, 2015

Thanks for reporting, @cmanallen . This is indeed a bug; all fields should serialize None to None. I've made the change in 077e071, and the patch will be released in 2.0.0b3

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