From 6eda84841067c32b40e5ba4108664eeeb9f96de2 Mon Sep 17 00:00:00 2001 From: Laura Gomez Date: Tue, 30 Jul 2019 12:17:13 -0400 Subject: [PATCH] feat: Initial commit of EmailValidation class --- ICD.Common.Utils/Email/EmailValidation.cs | 14 ++++++++++++++ .../ICD.Common.Utils_SimplSharp.csproj | 1 + 2 files changed, 15 insertions(+) create mode 100644 ICD.Common.Utils/Email/EmailValidation.cs diff --git a/ICD.Common.Utils/Email/EmailValidation.cs b/ICD.Common.Utils/Email/EmailValidation.cs new file mode 100644 index 0000000..51cd25c --- /dev/null +++ b/ICD.Common.Utils/Email/EmailValidation.cs @@ -0,0 +1,14 @@ +using System.Text.RegularExpressions; + +namespace ICD.Common.Utils.Email +{ + public static class EmailValidation + { + private const string EMAIL_REGEX = @"(?:[a-z0-9!#$%&'*+\/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+\/=?^_`{|}~-]+)*|""(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*"")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9]))\.){3}(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9])|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])"; + + public static bool IsValidEmailAddress(string emailAddress) + { + return emailAddress != null && Regex.IsMatch(emailAddress, EMAIL_REGEX); + } + } +} \ No newline at end of file diff --git a/ICD.Common.Utils/ICD.Common.Utils_SimplSharp.csproj b/ICD.Common.Utils/ICD.Common.Utils_SimplSharp.csproj index 1ba061a..0614074 100644 --- a/ICD.Common.Utils/ICD.Common.Utils_SimplSharp.csproj +++ b/ICD.Common.Utils/ICD.Common.Utils_SimplSharp.csproj @@ -89,6 +89,7 @@ +