You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The current behavior of decoding Union types with from_dict is if none of the types in the Union matches, then the field becomes a dict. To me, I would have expected it to raise ValidationError, and the dict is a surprise to the users of the field
Possible solution
Raise ValidationError if nothing in the Union matches.
Alternatives
For now, I have added to the object
def __post_init__(self) -> None:
if isinstance(self.params, dict):
raise Exception("params is missing some fields")
Context
No response
The text was updated successfully, but these errors were encountered:
Description
The current behavior of decoding Union types with
from_dict
is if none of the types in the Union matches, then the field becomes a dict. To me, I would have expected it to raiseValidationError
, and the dict is a surprise to the users of the fieldPossible solution
Raise ValidationError if nothing in the Union matches.
Alternatives
For now, I have added to the object
Context
No response
The text was updated successfully, but these errors were encountered: