Add using System.Collections.Generic;
for following method to work.
public static class EmailValidator
{
const string EmailEx = @"^([w.-]+)@([w-]+)((.(w){2,3})+)$";
private static ErrorDetail IsEmail(string input)
{
return !Regex.IsMatch(input, EmailEx)
? new ErrorDetail { Message = "Not a valid Email" }
: null;
}
public static Func<string, ErrorDetail> ValidationMethod(string emailID)
{
return IsEmail;
}
public static Dictionary<string, ErrorDetail> AreEmailValid(string[] arrEmail)
{
Dictionary<string, ErrorDetail> invalidEmailDict = new Dictionary<string, ErrorDetail>();
ErrorDetail errorDetail;
foreach (string str in arrEmail)
{
errorDetail = IsEmail(str);
if (errorDetail != null)
{
invalidEmailDict.Add(str,errorDetail);
}
}
return invalidEmailDict;
}
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…