public ActionResult ValidateEmailAddress(string emailString) { try { using (var uow = ObjectFactory.GetInstance<IUnitOfWork>()) { EmailAddressDO emailAddressDO = _emailAddress.ConvertFromString(emailString, uow); var ru = new RegexUtilities(); if (!(ru.IsValidEmailAddress(emailAddressDO.Address))) return Json("Invalid email format"); else return Json(true); } } catch (Exception ex) { return Json(ex.Message); } }
public void TestEmailUnderscore() { var ru = new RegexUtilities(); Assert.True(ru.IsValidEmailAddress("*****@*****.**")); }
public void TestEmailDomainWithPeriod() { var ru = new RegexUtilities(); Assert.True(ru.IsValidEmailAddress("*****@*****.**")); }
public void TestEmailNameWithDash() { var ru = new RegexUtilities(); Assert.True(ru.IsValidEmailAddress("*****@*****.**")); }
public void TestIllegalSurroundingCharactersInvalid() { var ru = new RegexUtilities(); Assert.False(ru.IsValidEmailAddress("'*****@*****.**'")); }
public ActionResult RunQuery(UserVM queryParams) { if (string.IsNullOrEmpty(queryParams.EmailAddress) && string.IsNullOrEmpty(queryParams.FirstName) && string.IsNullOrEmpty(queryParams.LastName)) { var jsonErrorResult = Json(_jsonPackager.Pack(new { Error = "Atleast one field is required" })); return jsonErrorResult; } if (queryParams.EmailAddress != null) { var ru = new RegexUtilities(); if (!(ru.IsValidEmailAddress(queryParams.EmailAddress))) { var jsonErrorResult = Json(_jsonPackager.Pack(new { Error = "Please provide valid email address" })); return jsonErrorResult; } } using (var uow = ObjectFactory.GetInstance<IUnitOfWork>()) { var query = uow.UserRepository.GetQuery(); if (!String.IsNullOrWhiteSpace(queryParams.FirstName)) query = query.Where(u => u.FirstName.Contains(queryParams.FirstName)); if (!String.IsNullOrWhiteSpace(queryParams.LastName)) query = query.Where(u => u.LastName.Contains(queryParams.LastName)); if (!String.IsNullOrWhiteSpace(queryParams.EmailAddress)) query = query.Where(u => u.EmailAddress.Address.Contains(queryParams.EmailAddress)); var matchedUsers = query.ToList(); var jsonResult = Json(_jsonPackager.Pack(matchedUsers)); jsonResult.MaxJsonLength = int.MaxValue; return jsonResult; } }
public static void ValidateEmailAddress(String emailAddress) { var ru = new RegexUtilities(); if (!ru.IsValidEmailAddress(emailAddress)) throw new ValidationException(new [] { new ValidationFailure("emailAddress", "Invalid email address: '" + emailAddress + "'")}); }