Skip to content

feat(dropdown): support minLength/maxLength/pattern on single-select drop-down - #1936

Open
rismehta wants to merge 1 commit into
devfrom
feat/dropdown-string-length-constraints
Open

feat(dropdown): support minLength/maxLength/pattern on single-select drop-down#1936
rismehta wants to merge 1 commit into
devfrom
feat/dropdown-string-length-constraints

Conversation

@rismehta

Copy link
Copy Markdown
Collaborator

Problem

A string-typed drop-down — e.g. a searchable drop-down with enforceEnum disabled where free text is allowed — can legitimately carry minLength/maxLength/pattern constraints. The runtime (af2-web-runtime Field.ts) already honors these for any type === 'string' field regardless of fieldType, but DropDownImpl exposed no getters, so authored constraints were silently dropped on export.

Changes

  • Model: DropDown now extends StringConstraint. DropDownImpl exposes getMinLength/getMaxLength/getPattern, gated to single-select only — returned null for multi-select, mirroring the runtime which strips string constraints for array types. getFormat returns null (drop-down has no authorable format).
  • Schema (schema/0.15.2/adaptive-form.schema.json): split drop-down out of the shared SelectionField definition into a dedicated DropDownField whose allow-list permits minLength/maxLength/pattern. checkbox-group keeps its original constraint-free allow-list.
  • Tests: constraints exported for single-select, dropped for multi-select, getPattern default, and a JSON export fixture.

Verification

mvn -pl bundles/af-core clean test -Dtest=DropDownImplTest,CheckBoxGroupImplTest → 96 tests pass, spotbugs green.

Note

This updates the vendored test schema snapshot only. The canonical/published Adaptive Forms JSON schema needs the matching DropDownField change separately to keep authored forms valid in real deployments.

🤖 Generated with Claude Code

…drop-down

A string-typed drop-down (e.g. a searchable drop-down with enforceEnum
disabled, allowing free text) can legitimately carry string-length and
pattern constraints. The runtime already honors these for string-typed
fields regardless of fieldType, but DropDownImpl exposed no getters, so
authored minLength/maxLength/pattern were silently dropped on export.

- DropDown now extends StringConstraint; DropDownImpl exposes
  getMinLength/getMaxLength/getPattern, gated to single-select only
  (returned null for multi-select, mirroring the runtime which strips
  string constraints for array types). getFormat returns null since
  drop-down has no authorable format.
- Update the 0.15.2 adaptive-form schema: split drop-down out of
  SelectionField into a dedicated DropDownField definition whose
  allow-list permits minLength/maxLength/pattern; checkbox-group keeps
  its original (constraint-free) allow-list.
- Add tests: constraints exported for single-select, dropped for
  multi-select, plus JSON export fixture.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@adobe-bot

Copy link
Copy Markdown

Accessibility Violations Found

Id Impact
aria-required-attr critical
empty-heading minor
label-title-only serious
target-size serious

@adobe-bot

Copy link
Copy Markdown

Accessibility Violations Found

Id Impact
aria-required-attr critical
empty-heading minor
label-title-only serious
page-has-heading-one moderate
target-size serious

@codecov

codecov Bot commented Jul 27, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

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