Skip to content

Test that a required array with validated inline items rejects value - #174

Merged
cubahno merged 1 commit into
mainfrom
ig/add-req-arr-test
Oct 14, 2026
Merged

cubahno merged 1 commit into
mainfrom
ig/add-req-arr-test

Conversation

@cubahno

@cubahno cubahno commented Oct 14, 2026

Copy link
Copy Markdown
Collaborator

A required array with inline items that carry a constraint, such as a pattern, accepted {} and {"inline":null}, while the same array with $ref items was rejected.
A struct's Validate() skipped the array's own required tag whenever it checked the items, and minItems skips nil, so nothing caught an absent array.

The required check is emitted again since #172, which checks the array's own tags before its items. This PR adds the end-to-end regression test for the report, so it doesn't come back.

What changes
examples/requests/array-item-counts gets a required codes body property with minItems: 1 and items bound by a pattern, the shape from the issue.
gen_test.go sends the body with codes missing, null, [] and a non-matching item, and expects a 400 without the service being called. A valid body still passes.
No generator change.

Fixes #171

@cubahno
cubahno marked this pull request as ready for review October 14, 2026 10:23
@cubahno
cubahno merged commit 0f34b58 into main Oct 14, 2026
3 checks passed
@cubahno
cubahno deleted the ig/add-req-arr-test branch October 14, 2026 10:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Required array with inline items accepts missing or null value

1 participant