aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations/Connect/Validator.cs
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2016-11-04 14:56:47 -0400
committerLuke Pulverenti <luke.pulverenti@gmail.com>2016-11-04 14:56:47 -0400
commit72aaecb27930e04aa356febf35db2372bc417166 (patch)
treec72bb0ed40bd257b93d4b11f315bbbe24e23920d /Emby.Server.Implementations/Connect/Validator.cs
parenta7b11c8ee952ca43fe949ab4f1b6577e94ce6bba (diff)
move classes to new server project
Diffstat (limited to 'Emby.Server.Implementations/Connect/Validator.cs')
-rw-r--r--Emby.Server.Implementations/Connect/Validator.cs29
1 files changed, 29 insertions, 0 deletions
diff --git a/Emby.Server.Implementations/Connect/Validator.cs b/Emby.Server.Implementations/Connect/Validator.cs
new file mode 100644
index 000000000..5c94fa71c
--- /dev/null
+++ b/Emby.Server.Implementations/Connect/Validator.cs
@@ -0,0 +1,29 @@
+using System.Text.RegularExpressions;
+
+namespace Emby.Server.Implementations.Connect
+{
+ public static class Validator
+ {
+ static readonly Regex ValidEmailRegex = CreateValidEmailRegex();
+
+ /// <summary>
+ /// Taken from http://haacked.com/archive/2007/08/21/i-knew-how-to-validate-an-email-address-until-i.aspx
+ /// </summary>
+ /// <returns></returns>
+ private static Regex CreateValidEmailRegex()
+ {
+ const string validEmailPattern = @"^(?!\.)(""([^""\r\\]|\\[""\r\\])*""|"
+ + @"([-a-z0-9!#$%&'*+/=?^_`{|}~]|(?<!\.)\.)*)(?<!\.)"
+ + @"@[a-z0-9][\w\.-]*[a-z0-9]\.[a-z][a-z\.]*[a-z]$";
+
+ return new Regex(validEmailPattern, RegexOptions.IgnoreCase);
+ }
+
+ internal static bool EmailIsValid(string emailAddress)
+ {
+ bool isValid = ValidEmailRegex.IsMatch(emailAddress);
+
+ return isValid;
+ }
+ }
+}