@@ -104,9 +104,10 @@ void main() {
104
104
}));
105
105
106
106
testWidgets (
107
- 'FormBuilderValidators.maxLength' ,
107
+ 'FormBuilderValidators.maxLength for String ' ,
108
108
(WidgetTester tester) => testValidations (tester, (context) {
109
- final validator = FormBuilderValidators .maxLength (context, 5 );
109
+ final validator =
110
+ FormBuilderValidators .maxLength <String >(context, 5 );
110
111
// Pass
111
112
expect (validator (null ), isNull);
112
113
expect (validator ('' ), isNull);
@@ -116,10 +117,12 @@ void main() {
116
117
expect (validator ('something long' ), isNotNull);
117
118
expect (validator ('123456' ), isNotNull);
118
119
}));
120
+
119
121
testWidgets (
120
- 'FormBuilderValidators.minLength' ,
122
+ 'FormBuilderValidators.minLength for String ' ,
121
123
(WidgetTester tester) => testValidations (tester, (context) {
122
- final validator = FormBuilderValidators .minLength (context, 5 );
124
+ final validator =
125
+ FormBuilderValidators .minLength <String >(context, 5 );
123
126
// Pass
124
127
expect (validator ('12345' ), isNull);
125
128
expect (validator ('123456' ), isNull);
@@ -129,11 +132,45 @@ void main() {
129
132
expect (validator ('' ), isNotNull);
130
133
expect (validator ('two' ), isNotNull);
131
134
// Advanced
132
- final validatorAllowEmpty =
133
- FormBuilderValidators .minLength (context, 5 , allowEmpty: true );
135
+ final validatorAllowEmpty = FormBuilderValidators .minLength <String >(
136
+ context, 5 ,
137
+ allowEmpty: true );
134
138
expect (validatorAllowEmpty (null ), isNull);
135
139
expect (validatorAllowEmpty ('' ), isNull);
136
140
}));
141
+ testWidgets (
142
+ 'FormBuilderValidators.maxLength for Iterable' ,
143
+ (WidgetTester tester) => testValidations (tester, (context) {
144
+ final validator =
145
+ FormBuilderValidators .maxLength <Iterable <String >>(context, 3 );
146
+ // Pass
147
+ expect (validator (null ), isNull);
148
+ expect (validator ([]), isNull);
149
+ expect (validator (['one' , 'two' ]), isNull);
150
+ expect (validator (['one' , 'two' , 'three' ]), isNull);
151
+ // Fail
152
+ expect (validator (['one' , 'two' , 'three' , 'four' ]), isNotNull);
153
+ }));
154
+
155
+ testWidgets (
156
+ 'FormBuilderValidators.minLength for Iterable' ,
157
+ (WidgetTester tester) => testValidations (tester, (context) {
158
+ final validator =
159
+ FormBuilderValidators .minLength <Iterable <String >>(context, 3 );
160
+ // Pass
161
+ expect (validator (['one' , 'two' , 'three' ]), isNull);
162
+ expect (validator (['one' , 'two' , 'three' , 'four' ]), isNull);
163
+ // Fail
164
+ expect (validator (null ), isNotNull);
165
+ expect (validator ([]), isNotNull);
166
+ expect (validator (['one' , 'two' ]), isNotNull);
167
+ // Advanced
168
+ final validatorAllowEmpty = FormBuilderValidators .minLength <Iterable <String >>(
169
+ context, 3 ,
170
+ allowEmpty: true );
171
+ expect (validatorAllowEmpty (null ), isNull);
172
+ expect (validatorAllowEmpty ([]), isNull);
173
+ }));
137
174
138
175
testWidgets (
139
176
'FormBuilderValidators.email' ,
0 commit comments