File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -116,7 +116,7 @@ class UsernameValidator extends BaseValidator<String> {
116
116
}
117
117
118
118
if (! allowSpecialChar &&
119
- RegExp (r'[!@#<>?":_`~;[\]\\|=+)(*&^%0-9 -]' ).hasMatch (valueCandidate)) {
119
+ RegExp (r'[!@#<>?":_`~;[\]\\|=+)(*&^%-]' ).hasMatch (valueCandidate)) {
120
120
return errorText != FormBuilderLocalizations .current.usernameErrorText
121
121
? errorText
122
122
: FormBuilderLocalizations
Original file line number Diff line number Diff line change @@ -388,5 +388,21 @@ void main() {
388
388
// Assert
389
389
expect (result, FormBuilderLocalizations .current.usernameErrorText);
390
390
});
391
+ test ('should return null if the username meets all customized requirements' ,
392
+ () {
393
+ // Arrange
394
+ const UsernameValidator validator = UsernameValidator (
395
+ minLength: 4 ,
396
+ maxLength: 15 ,
397
+ allowNumbers: true ,
398
+ );
399
+ const String validUsername = 'abc1' ;
400
+
401
+ // Act
402
+ final String ? result = validator.validate (validUsername);
403
+
404
+ // Assert
405
+ expect (result, isNull);
406
+ });
391
407
});
392
408
}
You can’t perform that action at this time.
0 commit comments