diff --git a/packages/smooth_app/lib/helpers/user_management_helper.dart b/packages/smooth_app/lib/helpers/user_management_helper.dart index c95aee58618..3c3f44cb8f9 100644 --- a/packages/smooth_app/lib/helpers/user_management_helper.dart +++ b/packages/smooth_app/lib/helpers/user_management_helper.dart @@ -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; } diff --git a/packages/smooth_app/lib/pages/user_management/sign_up_page.dart b/packages/smooth_app/lib/pages/user_management/sign_up_page.dart index 681a4e68dc3..b295c059bd2 100644 --- a/packages/smooth_app/lib/pages/user_management/sign_up_page.dart +++ b/packages/smooth_app/lib/pages/user_management/sign_up_page.dart @@ -117,6 +117,10 @@ class _SignUpPageState extends State { _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; }, ),