Skip to content

Fix Length constraints for object-valued Marshmallow fields - #1083

Open
xiehuanyi wants to merge 1 commit into
marshmallow-code:devfrom
xiehuanyi:fix-object-length-constraints
Open

xiehuanyi wants to merge 1 commit into
marshmallow-code:devfrom
xiehuanyi:fix-object-length-constraints

Conversation

@xiehuanyi

Copy link
Copy Markdown

Length validators on Dict fields currently generate minLength/maxLength, and object-valued Nested fields generate minItems/maxItems. These keywords do not constrain the number of properties in an object, so the generated specification loses the Marshmallow length bounds.

Use minProperties/maxProperties for dictionaries and nested schemas that produce a single object. Determine nested cardinality from the resolved schema's many setting, including when it is inherited from a schema instance. Extend regression coverage for exact lengths, arrays, inherited many=True, and scalar Pluck fields, and add a changelog entry.

Validation:

  • Six target regression cases fail before the fix.
  • The full test suite passes: 648 passed, 6 skipped, with both the locked dependencies and the lowest supported Marshmallow 4.0.0.
  • Applicable pre-commit checks pass, including Ruff, formatting, and mypy.
  • A generated dictionary schema with length exactly one rejects empty and two-property objects under OpenAPI 2.0, 3.0, and 3.1.

Developed with OpenAI Codex using gpt-6.1-sol (xhigh); the patch and regression behavior were checked locally and independently reviewed before publication.

Copilot AI balanced review requested due to automatic review settings October 12, 2026 08:38

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants