feat: Initial commit of EmailValidation class

This commit is contained in:
Laura Gomez
2019-07-30 12:17:13 -04:00
committed by Chris Cameron
parent 7b44867f34
commit 6eda848410
2 changed files with 15 additions and 0 deletions

View File

@@ -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);
}
}
}