python-betterproto
python-betterproto copied to clipboard
feat: fix dump one of fields
Summary
Hey 👋 I generated code with pydantic validation. A nested class failed the validation. For some reason, the object is validated twice once with the initialized object and once with empty fields.
@model_validator(mode="after")
def check_oneof(cls, values):
return cls._validate_field_groups(values)
Switching the order of the condition made it possible to avoid the second 'extra' validation.
Checklist
- [x] If code changes were made then they have been tested.
- [ ] I have updated the documentation to reflect the changes.
- [x] This PR fixes an issue.
- [ ] This PR adds something new (e.g. new method or parameters).
- [ ] This change has an associated test.
- [ ] This PR is a breaking change (e.g. methods or parameters removed/renamed)
- [ ] This PR is not a code change (e.g. documentation, README, ...)
Hi there, what does this fix? Please can you add a regression test
Hi @Gobot1234, just added description to the PR