From 6b944301cc6690a6c15ce8b8532b765cf630d82a Mon Sep 17 00:00:00 2001 From: Mathis Date: Tue, 14 May 2024 23:34:49 +0200 Subject: [PATCH] feat: Update regex for email and username validation Updated the regex in 'isEmail' and 'isUsername' validators to adjust valid string length. It now allows for a shorter username and a longer domain in email addresses. --- src/utils/valiators.util.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/utils/valiators.util.ts b/src/utils/valiators.util.ts index 4ecba55..8f2f9a8 100644 --- a/src/utils/valiators.util.ts +++ b/src/utils/valiators.util.ts @@ -1,12 +1,13 @@ const Validators = { isEmail: (value: string) => { - const emailRegex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/; + const emailRegex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,32}$/; return emailRegex.test(value) }, isUsername: (value: string) => { - const usernameRegex = /^[a-zA-Z0-9._]{3,16}$/; + const usernameRegex = /^[a-zA-Z0-9._]{3,14}$/; return usernameRegex.test(value); }, + //displayName isPassword: (value: string) => { const passwordRegex = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$/;