We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 6eae9fe commit d76957dCopy full SHA for d76957d
lib/src/form_builder_validators.dart
@@ -150,6 +150,7 @@ class FormBuilderValidators {
150
/// equal to the provided length. Works with String, iterable and int types
151
static FormFieldValidator<T> equalLength<T>(
152
int length, {
153
+ bool allowEmpty = false,
154
String? errorText,
155
}) {
156
assert(length > 0);
@@ -164,7 +165,7 @@ class FormBuilderValidators {
164
165
if (valueCandidate is String) valueLength = valueCandidate.length;
166
if (valueCandidate is Iterable) valueLength = valueCandidate.length;
167
- return valueLength != length
168
+ return valueLength != length && (!allowEmpty || valueLength > 0)
169
? errorText ??
170
FormBuilderLocalizations.current.equalLengthErrorText(length)
171
: null;
0 commit comments