Skip to content

Commit 67c6dc7

Browse files
committed
Add custom error test
1 parent cc9bf78 commit 67c6dc7

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

test/form_builder_validators_test.dart

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ Future<void> testValidations(
3333
}
3434

3535
void main() {
36+
const customErrorMessage = 'Custom error message';
37+
3638
testWidgets(
3739
'FormBuilderValidators.required',
3840
(WidgetTester tester) => testValidations(tester, (context) {
@@ -1220,6 +1222,15 @@ void main() {
12201222
// Fail
12211223
expect(validator('123'), isNotNull);
12221224
expect(validator(''), isNotNull);
1225+
1226+
final validatorWithError = FormBuilderValidators.defaultValue<String>(
1227+
'default',
1228+
FormBuilderValidators.alphabetical(errorText: customErrorMessage),
1229+
);
1230+
// Pass
1231+
expect(validatorWithError('123'), customErrorMessage);
1232+
// Fail
1233+
expect(validatorWithError('123'), isNotNull);
12231234
}),
12241235
);
12251236
}

0 commit comments

Comments
 (0)