File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed
packages/form_builder_validators Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -156,9 +156,11 @@ class FormBuilderValidators {
156
156
return (T ? valueCandidate) {
157
157
assert (valueCandidate is String ||
158
158
valueCandidate is Iterable ||
159
+ valueCandidate is int ||
159
160
valueCandidate == null );
160
161
var valueLength = 0 ;
161
162
163
+ if (valueCandidate is int ) valueLength = valueCandidate.toString ().length;
162
164
if (valueCandidate is String ) valueLength = valueCandidate.length;
163
165
if (valueCandidate is Iterable ) valueLength = valueCandidate.length;
164
166
Original file line number Diff line number Diff line change @@ -192,6 +192,22 @@ void main() {
192
192
expect (validator ("4444" ), isNotNull);
193
193
}));
194
194
195
+ testWidgets (
196
+ 'FormBuilderValidators.lengthEqual for int' ,
197
+ (WidgetTester tester) => testValidations (tester, (context) {
198
+ final validator = FormBuilderValidators .lengthEqual <int >(3 );
199
+
200
+ // Pass
201
+ expect (validator (333 ), isNull);
202
+
203
+ // Fail
204
+ expect (validator (null ), isNotNull);
205
+ expect (validator (0 ), isNotNull);
206
+ expect (validator (1 ), isNotNull);
207
+ expect (validator (22 ), isNotNull);
208
+ expect (validator (4444 ), isNotNull);
209
+ }));
210
+
195
211
testWidgets (
196
212
'FormBuilderValidators.email' ,
197
213
(WidgetTester tester) => testValidations (tester, (context) {
You can’t perform that action at this time.
0 commit comments