Skip to content
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

schema fails to deserialize fields that are optional #67

Closed
eliwe opened this issue Feb 21, 2019 · 1 comment
Closed

schema fails to deserialize fields that are optional #67

eliwe opened this issue Feb 21, 2019 · 1 comment

Comments

@eliwe
Copy link

eliwe commented Feb 21, 2019

HI,

schema().loads failed to load Optional fields correctly. It raises:
marshmallow.exceptions.ValidationError: {'b': ['Field may not be null.']}

Example code:

from typing import Optional
from dataclasses import dataclass
from dataclasses_json import dataclass_json

@dataclass_json
@dataclass
class A:
    a: int
    b: Optional[int]

print(A.from_json('{"a": 4, "b": 5}'))
print(A.from_json('{"a": 4, "b": null}'))
print(A.schema().loads('{"a": 4, "b": 5}'))
print(A.schema().loads('{"a": 4, "b": null}'))

The last line raises ValidationError.
I am using version 0.2.1.

Thanks.

This was referenced Feb 21, 2019
@lidatong
Copy link
Owner

Thanks for reporting this. Fixed in #66

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants