[#93] Added minimum and maximum selection limits to multi-value fields.#119
[#93] Added minimum and maximum selection limits to multi-value fields.#119AlexSkrypnyk wants to merge 5 commits into
Conversation
|
Warning Review limit reachedYou’ve reached a temporary PR review limit under our Fair Usage Limits Policy. Next review available in: 22 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (22)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
|
🚀 Deployed on https://6a6205ff231754657f37f166--tui-docs.netlify.app |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #119 +/- ##
==========================================
+ Coverage 98.21% 98.24% +0.03%
==========================================
Files 100 102 +2
Lines 3358 3418 +60
==========================================
+ Hits 3298 3358 +60
Misses 60 60 ☔ View full report in Codecov by Harness. |
Closes #93
Summary
Multi-value fields -
->multiple()on select and search, and the file picker - can now declare a minimum and/or maximum number of allowed selections via two new builder methods,->minSelections(int)and->maxSelections(int), assembled into a newSelectionBoundsvalue object stored onField. The limit is enforced at accept time in the interactive TUI (an out-of-range selection is rejected inline with an error naming the bound, e.g. "Select at least 2 items.") and identically in headless collection (Engine) and answer-set validation (SchemaValidator), and the active limit is surfaced as a persistent hint line in the widget view before it is reached. The bounds also appear in the machine-readable schemas so external tooling and agents can see them ahead of time.Changes
Model and builder
src/Model/SelectionBounds.php, a readonly value object holding an optional inclusivemin/max, withcontains(int $count),violation(mixed $value)anddescribe()(the human phrase, e.g. "between 2 and 4 items", "at least 2 items", "exactly 3 items", pluralized throughTranslator::formatPlural()).SelectionBounds::contains()treats a negative count as always out of range.src/Model/Field.phpgained a?SelectionBounds $selectionBoundsconstructor parameter; the constructor now throws aFormExceptionwhen bounds are declared on a field that is notmultiple.Field::boundsViolation()now also checksselectionBounds->violation(), alongside the existing number and date bounds, so every enforcement surface that already calls it picks up selection-count checking for free.src/Builder/FieldBuilder.phpgainedminSelections(int)andmaxSelections(int), and abuildSelectionBounds()step that throws when limits are declared on a non-multiple field or when the declared minimum exceeds the maximum.Interactive widgets
src/Widget/Capability/SelectionBoundedTrait.php, shared bySelectWidget,SearchWidgetandFilePickerWidget: it overridesaccept()to reject an out-of-range selection with an inline"Select @constraint."error, and renders the active bound as a dim hint line above the option list.src/Widget/WidgetFactory.phpnow passes$field->selectionBoundsthrough to all three widget constructors.Schema surfaces
src/Schema/AgentHelp.phpemitsminItems/maxItemsin the generated JSON Schema for a bounded field.src/Schema/SchemaGenerator.phpemitsmin_selections/max_selectionsalongside the existing number bounds.Translations
translations/en.phpgained the new bound phrases and the"Select @constraint."error string.translations/uk.phpgained the same phrases using the catalog's plural-form mechanism (singular/few/many forms for "item(s)").Tests
tests/phpunit/Unit/Model/SelectionBoundsTest.php(new) coverscontains(),violation(),describe()and the constructor guards, including a negative selection count.tests/phpunit/Unit/Builder/FormTest.phpandBuiltModelTest.phpcover builder assembly and the non-multiple/min-above-max/min-below-one rejections.tests/phpunit/Unit/Engine/EngineNonInteractiveTest.phpadds headless within-bounds, below-minimum, and above-maximum coverage.tests/phpunit/Unit/Schema/SchemaValidatorTest.php,AgentHelpTest.phpandSchemaGeneratorTest.phpcover the answer-set validator and both schema surfaces.tests/phpunit/Unit/Widget/SelectWidgetTest.php,SearchWidgetTest.phpandFilePickerWidgetTest.phpcover the inline rejection, the accepted-within-bounds path, and the hint line for each widget.Before / After