From 3249acde5658e421d09fa46578c84a97f1401bca Mon Sep 17 00:00:00 2001 From: caxxy <18451940+yxx4c@users.noreply.github.com> Date: Sun, 2 Mar 2025 21:05:06 +0300 Subject: [PATCH] fix(auth): update email validation regex to improve accuracy and support more valid email formats --- lib/features/auth/pages/forget_password_page.dart | 2 +- lib/features/auth/pages/signin_page.dart | 2 +- lib/features/auth/pages/signup_page.dart | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/features/auth/pages/forget_password_page.dart b/lib/features/auth/pages/forget_password_page.dart index ab80d2d..084e09e 100644 --- a/lib/features/auth/pages/forget_password_page.dart +++ b/lib/features/auth/pages/forget_password_page.dart @@ -54,7 +54,7 @@ class _ForgotPasswordPageState extends State { if (value?.isEmpty ?? true) { return 'Please enter your email'; } - if (!RegExp(r'^[\w-.]+@([\w-]+\.)+[\w-]{2,4}$').hasMatch(value!)) { + if (!RegExp(r'^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$').hasMatch(value!)) { return 'Please enter a valid email'; } return null; diff --git a/lib/features/auth/pages/signin_page.dart b/lib/features/auth/pages/signin_page.dart index f289a47..2b9cd58 100644 --- a/lib/features/auth/pages/signin_page.dart +++ b/lib/features/auth/pages/signin_page.dart @@ -278,7 +278,7 @@ class _SignInPageState extends State return 'Please enter your email'; } if (!RegExp( - r'^[\w-.]+@([\w-]+\.)+[\w-]{2,4}$') + r'^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$') .hasMatch(value!)) { return 'Please enter a valid email'; } diff --git a/lib/features/auth/pages/signup_page.dart b/lib/features/auth/pages/signup_page.dart index bee1ea1..159de16 100644 --- a/lib/features/auth/pages/signup_page.dart +++ b/lib/features/auth/pages/signup_page.dart @@ -320,7 +320,7 @@ class _SignUpPageState extends State return 'Please enter your email'; } if (!RegExp( - r'^[\w-.]+@([\w-]+\.)+[\w-]{2,4}$') + r'^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$') .hasMatch(value!)) { return 'Please enter a valid email'; }