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
{{ message }}
This repository has been archived by the owner on Aug 19, 2023. It is now read-only.
I'm testing it to replace marshmallow and validate our events/commands format before processing it within our message bus.
If I create dataclass objects directly (instead of deserializing from json or dict), they could hold attributes of wrong type ... and I don't see a simple way to execute the validation directly from the dataclass. The only way I found is to do:
Looking at the code .. I see that we can pass validate=True within to_dict() parameters (default False).
So, it avoids deserialization in my trick above.
So temporary, in my default Command class, I include this to make the validation more obvious.
First, thanks for this library!
I'm testing it to replace marshmallow and validate our events/commands format before processing it within our message bus.
If I create dataclass objects directly (instead of deserializing from json or dict), they could hold attributes of wrong type ... and I don't see a simple way to execute the validation directly from the dataclass. The only way I found is to do:
is there another way, or a public validate method somehow?
example:
@DataClass
class CreateUserCommand(JsonSchemaMixin):
id: int
name: str
I can instantiate wrong dataclass like:
myuser = CreateUserCommand(id='wrong', name=12)
I tried with no success: CreateUserCommand.from_object(myuser)
public validate method would make sense, or validation performed straight at the dataclass initialization, no?
The text was updated successfully, but these errors were encountered: