Skip to content

Commit

Permalink
Limited username to 20 characters
Browse files Browse the repository at this point in the history
  • Loading branch information
vik4114 committed Apr 21, 2022
1 parent f671807 commit d176245
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/smooth_app/lib/helpers/user_management_helper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ class UserManagementHelper {
static bool isUsernameValid(final String username) =>
username.isNotEmpty && _userRegex.hasMatch(username);

static bool isUsernameLengthValid(final String username) =>
username.length <= 20;

static bool isPasswordValid(final String password) => password.length >= 6;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@ class _SignUpPageState extends State<SignUpPage> {
_userController.trimmedText)) {
return appLocalizations.sign_up_page_username_description;
}
if (!UserManagementHelper.isUsernameLengthValid(
_userController.trimmedText)) {
return 'Username must be less than 20 characters'; // TODO(vik4114): localization
}
return null;
},
),
Expand Down

0 comments on commit d176245

Please sign in to comment.