dataclasses-json
dataclasses-json copied to clipboard
Setting default value when optional field's dependency is set
Hi,
I love this library so much!
This is my snippet:
@dataclass_json
@dataclass
class Material():
alphaMode: Optional[str]
alphaCutoff: Optional[float] = 0.5
What I'm trying to do is only use the optional value of alphaCutoff if alphaMode is set. I'm recreating the dependencies rule from json schemas. Is there a way to specify this relationship?
@matt035343 could this be an interesting brain teaser for you? :)