Conversation
…370) ## Summary `maxProperties`/`minProperties` were parsed then discarded (`_ignored` in `parser.dart`), dropping a real constraint on **map-shaped** schemas (`type: object` + `additionalProperties`, no fixed `properties`) — 49 sites in discord, 3 in github. For a `Map<String, T>` the entry count is dynamic, so these are the map analog of an array's `maxItems`/`minItems`, which we already validate. Threads both bounds through every layer (`SchemaMap` → `ResolvedMap` → `RenderMap`), mirroring the existing `maxItems`/`minItems` path, and emits a combined `validate(minProperties: ..., maxProperties: ...)` call on the map field. A new `ValidateMap` extension in the shipped `api_exception.dart` enforces it via `Map.length`, matching `ValidateArray`. On a fixed-property object the property count is static, so the constraint carries no runtime meaning — it stays dropped-and-detail- logged there (resolver owns the semantics). Generated output (optional map → `?.`, required map → `.`): ```dart Lobby({required this.requiredMeta, this.metadata}) { metadata?.validate(minProperties: 1, maxProperties: 25); requiredMeta.validate(maxProperties: 5); } ``` ## Validation - Unit tests: parser (map carries the bounds; fixed-property object drops+logs them), render (`RenderMap.validationCall` combines/omits bounds). - End-to-end repro: analyze-clean, correct `?.`/`.` receiver. - Regenerated the rotation: discord (29 files) and github (8 files) now emit `validate(maxProperties: N)` on map fields; github, discord, and backstage third_party packages stay analyze-clean; the `minProperties: 1` model's round-trip test passes (the single-entry map example satisfies the bound).
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #371 +/- ##
==========================================
- Coverage 96.67% 96.53% -0.14%
==========================================
Files 25 25
Lines 5957 5981 +24
==========================================
+ Hits 5759 5774 +15
- Misses 198 207 +9 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
maxProperties/minPropertieswere parsed then discarded(
_ignoredinparser.dart), dropping a real constraint onmap-shaped schemas (
type: object+additionalProperties, nofixed
properties) — a-vregen tallies 49 sites in discord and 3 ingithub. For a
Map<String, T>the entry count is dynamic, so these arethe map analog of an array's
maxItems/minItems, which we alreadyvalidate.
This threads both bounds through every layer
(
SchemaMap→ResolvedMap→RenderMap), mirroring the existingmaxItems/minItemspath, and emits a combinedvalidate(minProperties: ..., maxProperties: ...)call on the mapfield. A new
ValidateMapextension in the shippedapi_exception.dartenforces it via
Map.length, matchingValidateArray.On a fixed-property object the property count is static, so the
constraint carries no runtime meaning — it stays dropped-and-detail-
logged there (the resolver owns the semantics).
Generated output (optional map →
?., required map →.):Closes #370.
Validation
a fixed-property object drops + detail-logs them), render
(
RenderMap.validationCallcombines both bounds, omits the absentone, is null when unconstrained).
?./.receiver peroptional/required.
emit
validate(maxProperties: N)on map fields; github, discord, andbackstage third_party packages stay analyze-clean; the
minProperties: 1model's generated round-trip test passes (thesingle-entry map example satisfies the bound).