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> {
116116 }
117117
118118 if (! allowSpecialChar &&
119- RegExp (r'[!@#<>?":_`~;[\]\\|=+)(*&^%0-9 -]' ).hasMatch (valueCandidate)) {
119+ RegExp (r'[!@#<>?":_`~;[\]\\|=+)(*&^%-]' ).hasMatch (valueCandidate)) {
120120 return errorText != FormBuilderLocalizations .current.usernameErrorText
121121 ? errorText
122122 : FormBuilderLocalizations
Original file line number Diff line number Diff line change @@ -388,5 +388,21 @@ void main() {
388388 // Assert
389389 expect (result, FormBuilderLocalizations .current.usernameErrorText);
390390 });
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+ });
391407 });
392408}
You can’t perform that action at this time.
0 commit comments