From d176245e8268da636605c15ea83b1c281af9cbfd Mon Sep 17 00:00:00 2001 From: vikash singh <46121493+vik4114@users.noreply.github.com> Date: Thu, 21 Apr 2022 18:36:27 +0530 Subject: [PATCH] Limited username to 20 characters --- packages/smooth_app/lib/helpers/user_management_helper.dart | 3 +++ .../smooth_app/lib/pages/user_management/sign_up_page.dart | 4 ++++ 2 files changed, 7 insertions(+) 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; }, ),