From 30c8ff1612f8265f6f9612fd9b73807fd63c309a Mon Sep 17 00:00:00 2001 From: Shravya Ramesh <37447613+shravyaramesh@users.noreply.github.com> Date: Wed, 4 Nov 2020 10:57:37 -0800 Subject: changed username from min 6 to min 3 chars (#105) Co-authored-by: Ashm Walia <40498934+ashmgarv@users.noreply.github.com> --- src/constants/regex.ts | 4 ++-- src/screens/onboarding/Login.tsx | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/constants/regex.ts b/src/constants/regex.ts index 3bebe304..ac38a3b7 100644 --- a/src/constants/regex.ts +++ b/src/constants/regex.ts @@ -15,10 +15,10 @@ export const passwordRegex: RegExp = /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[^a-zA /** * The username regex has the following constraints - * - min. 6 chars, max. 30 chars ({6,30}) + * - min. 3 chars, max. 30 chars ({6,30}) * - match only alphanumerics, underscores, and periods */ -export const usernameRegex: RegExp = /^[a-zA-Z0-9_.]{6,30}$/; +export const usernameRegex: RegExp = /^[a-zA-Z0-9_.]{3,30}$/; /** * The name regex has the following constraints diff --git a/src/screens/onboarding/Login.tsx b/src/screens/onboarding/Login.tsx index 1e2510fb..26b45315 100644 --- a/src/screens/onboarding/Login.tsx +++ b/src/screens/onboarding/Login.tsx @@ -57,8 +57,9 @@ const Login: React.FC = ({navigation}: LoginProps) => { * Updates the state of username. Also verifies the input of the username field by ensuring proper length and appropriate characters. */ const handleUsernameUpdate = (val: string) => { + val = val.trim(); - let validLength: boolean = val.length >= 6; + let validLength: boolean = val.length >= 3; let validChars: boolean = usernameRegex.test(val); if (validLength && validChars) { -- cgit v1.2.3-70-g09d2