public static void ValidateEmail(this ValidationManager validationManager, TextSource textSource, string errorMessage = null) { //The validation actually won't go further only if Upstream is set as source but payload is not avaialable. That means we can't yet validate if (!textSource.CanGetValue(validationManager.Payload) && !textSource.ValueSourceIsNotSet) { return; } var value = textSource.CanGetValue(validationManager.Payload) ? textSource.GetValue(validationManager.Payload) : string.Empty; if (!RegexUtilities.IsValidEmailAddress(value)) { validationManager.SetError(errorMessage ?? "Not a valid e-mail address", textSource); } }
public static bool ValidateTextSourceNotEmpty(this ValidationManager validationManager, TextSource control, string errorMessage) { if (control != null && control.CanGetValue(validationManager.Payload) && string.IsNullOrWhiteSpace(control.GetValue(validationManager.Payload))) { validationManager.SetError(errorMessage, control); return(false); } return(true); }