Skip to content

fix: use a count error text for Iterable and Map values in length validators#164

Open
Yusufihsangorgel wants to merge 3 commits into
flutter-form-builder-ecosystem:mainfrom
Yusufihsangorgel:fix/iterable-length-error-text
Open

fix: use a count error text for Iterable and Map values in length validators#164
Yusufihsangorgel wants to merge 3 commits into
flutter-form-builder-ecosystem:mainfrom
Yusufihsangorgel:fix/iterable-length-error-text

Conversation

@Yusufihsangorgel

Copy link
Copy Markdown

Closes #81

MaxLengthValidator and MinLengthValidator accept String, Iterable and Map values, but the default error text always talks about length in the string sense, which reads wrong for collections in languages like Japanese where the message says characters (文字).

Changes, following the direction suggested in the issue:

  • New maxCountErrorText / minCountErrorText messages. English in the template arb, Japanese with the wording proposed in the issue; other locales fall back to English through gen_l10n until translated, and land in the untranslated-messages report.
  • The two validators pick the count message when the invalid value is an Iterable or a Map and no custom errorText was given. Strings keep the existing length message, and a custom errorText still wins for every type.
  • TranslatedValidator gained a hasCustomErrorText getter so subclasses can tell whether the message was user-provided.
  • The null and empty cases go through the null check before the value type is known, so they keep the generic length message.

Existing List tests were updated to the new default message, and new tests cover the count text for lists, the unchanged string text, and the custom-text override. flutter test passes (988) and flutter analyze reports no new issues.

Left CHANGELOG and version to the release flow, as in previous PRs; happy to add an entry if you prefer.

@Yusufihsangorgel

Copy link
Copy Markdown
Author

Heads up: the build job was failing during the changelog link check before the tests ran, on a pre-existing empty link in the 8.4.0 section ([@ipcjs]()). Fixed that line in 957f444 so CI can exercise this PR.

@codecov

codecov Bot commented Jul 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.21%. Comparing base (986934a) to head (67f09af).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #164   +/-   ##
=======================================
  Coverage   99.20%   99.21%           
=======================================
  Files          95       95           
  Lines        1012     1019    +7     
=======================================
+ Hits         1004     1011    +7     
  Misses          8        8           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

[FormBuilderValidators.maxLength & .minLength]: If the value to be verified is not a String but an Iterable, errorText is incorrect.

1 participant