diff --git a/packages/smooth_app/lib/helpers/user_management_helper.dart b/packages/smooth_app/lib/helpers/user_management_helper.dart index 3c3f44cb8f9..95828ebf0ff 100644 --- a/packages/smooth_app/lib/helpers/user_management_helper.dart +++ b/packages/smooth_app/lib/helpers/user_management_helper.dart @@ -1,4 +1,5 @@ import 'package:flutter/widgets.dart'; +import 'package:openfoodfacts/openfoodfacts.dart'; class UserManagementHelper { UserManagementHelper._(); @@ -21,7 +22,7 @@ class UserManagementHelper { username.isNotEmpty && _userRegex.hasMatch(username); static bool isUsernameLengthValid(final String username) => - username.length <= 20; + username.length <= OpenFoodAPIClient.USER_NAME_MAX_LENGTH; 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 b295c059bd2..2dff92dd88c 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 @@ -119,7 +119,8 @@ class _SignUpPageState extends State { } if (!UserManagementHelper.isUsernameLengthValid( _userController.trimmedText)) { - return 'Username must be less than 20 characters'; // TODO(vik4114): localization + const int maxLength = OpenFoodAPIClient.USER_NAME_MAX_LENGTH; + return 'Username must be less than $maxLength characters'; // TODO(vik4114): localization and translation } return null; },