File tree Expand file tree Collapse file tree 1 file changed +2
-9
lines changed Expand file tree Collapse file tree 1 file changed +2
-9
lines changed Original file line number Diff line number Diff line change @@ -76,10 +76,8 @@ class FormBuilderValidators {
76
76
String errorText,
77
77
}) {
78
78
return (valueCandidate) {
79
- if (allowEmpty && (valueCandidate == null || valueCandidate? .length == 0 ))
80
- return errorText ??
81
- "Value must have a length greater than or equal to $minLength " ;
82
- if (valueCandidate != null && valueCandidate.length < minLength) {
79
+ final valueLength = valueCandidate? .length ?? 0 ;
80
+ if (valueLength < minLength && (! allowEmpty || valueLength > 0 )) {
83
81
return errorText ??
84
82
"Value must have a length greater than or equal to $minLength " ;
85
83
}
@@ -92,13 +90,8 @@ class FormBuilderValidators {
92
90
static FormFieldValidator maxLength (
93
91
num maxLength, {
94
92
String errorText,
95
- bool allowEmpty = false ,
96
93
}) {
97
94
return (valueCandidate) {
98
- if (allowEmpty && (valueCandidate == null || valueCandidate? .length == 0 ))
99
- return errorText ??
100
- "Value must have a length greater than or equal to $minLength " ;
101
-
102
95
if (valueCandidate != null && valueCandidate.length > maxLength) {
103
96
return errorText ??
104
97
"Value must have a length less than or equal to $maxLength " ;
You can’t perform that action at this time.
0 commit comments