Generated with the help of an LLM.
ChatGPT helped draft this issue summary.
Problem/Motivation
Follow-up to #3627330: Validation constraints do not contribute to the JSON Schema, requested by mglaman during review of MR !18061.
Count constraints limit the number of list elements. These limits should contribute minItems and maxItems to the list's JSON Schema.
This depends on the constraint interface from #3627330: Validation constraints do not contribute to the JSON Schema and list-schema support from #3627328: ListNormalizer does not provide a JSON Schema for lists.
Steps to reproduce
- Use a checkout with list-schema support from #3627328: ListNormalizer does not provide a JSON Schema for lists.
- Create a list definition with a Count constraint specifying min: 2 and max: 5.
- Generate its JSON Schema and check whether those limits appear on the array schema.
Proposed resolution
Implement the interface established in #3627330: Validation constraints do not contribute to the JSON Schema on CountConstraint. Apply representable count limits to the array schema, preserving its item schema and existing restrictions.
Read constraints from the list definition. Unsupported options must not produce restrictions that reject values accepted by Drupal.
Remaining tasks
- Coordinate with the parent issue and #3627328: ListNormalizer does not provide a JSON Schema for lists.
- Implement keyword generation and list-schema integration.
- Test minimum, maximum, exact, and zero counts.
- Test required lists, overlapping restrictions, and nested lists.
User interface changes
None.
Introduced terminology
None.
API changes
CountConstraint would implement the interface established in #3627330: Validation constraints do not contribute to the JSON Schema.
Data model changes
None.
Release notes snippet
To be determined.
Issue fork drupal-3643476
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
wkr1shna commentedComment #4
mukesh-kumar3 commentedThe previously failing functional test job passed on retry without code changes.
Comment #5
wkr1shna commentedThanks for confirming!
Good to know the previously failing Functional JavaScript job passed on retry without any code changes.
The implementation is available in [MR !18104](https://git.drupalcode.org/project/drupal/-/merge_requests/18104), with the prerequisite dependency work included.
Since the two prerequisite contributions are still under review, would you recommend keeping this MR in Draft for now, or moving it out of Draft so the implementation can receive feedback in parallel?
I'm happy to follow whichever approach is preferred.
Comment #6
dries commented