Z.ExtensionMethods
Z.ExtensionMethods copied to clipboard
.IsValidEmail() reporting incorrect results
String extension method .IsValidEmail() is incorrectly reporting e-mails such as
as invalid. This is a valid RFC e-mail address, and one recommended by Google to alias existing inboxes.
Hello @jasenf ,
Do you have a proposal to the Regex we should use? Last time I made a research about it, pretty much all regex has some flaw and it seems there is no consensus about which Regex to use.
Best Regards,
Jonathan
Performance Libraries
context.BulkInsert(list, options => options.BatchSize = 1000);
Entity Framework Extensions • Entity Framework Classic • Bulk Operations • Dapper Plus
Runtime Evaluation
Eval.Execute("x + y", new {x = 1, y = 2}); // return 3
C# Eval Function • SQL Eval Function
I think it's fine as-is if you just allow the + sign.
We will try to review it soon by using the syntax from here: https://en.wikipedia.org/wiki/Email_address
It will not be perfect but we will change the regex to at least contains printable characters (which contains the plus sign)
If you really want to make it validate email addresses, RegularExpressions probably isn't the way to go. The simplest way to cover everything would probably be to just try creating a new MailAddress object and catch if an exception is thrown OR re-implement the code that does the email address validation from the .NET framework (https://github.com/microsoft/referencesource/blob/master/System/net/System/Net/mail/MailAddressParser.cs)