We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 2a943a3 commit d285975Copy full SHA for d285975
src/serializers/fields.rs
@@ -205,7 +205,12 @@ impl TypeSerializer for GeneralFieldsSerializer {
205
}
206
207
208
- if td_extra.check.enabled() && self.required_fields != used_req_fields {
+ if td_extra.check.enabled()
209
+ // If any of these are true we can't count fields
210
+ && !(extra.exclude_defaults || extra.exclude_unset || extra.exclude_none)
211
+ // Check for missing fields, we can't have extra fields here
212
+ && self.required_fields > used_req_fields
213
+ {
214
return Err(PydanticSerializationUnexpectedValue::new_err(None));
215
216
// this is used to include `__pydantic_extra__` in serialization on models
0 commit comments