public static bool isPostalCode(Control control) { if (FormValidators.hasText(control)) { return(Validators.isPostalCode(control.Text)); } return(false); }
public static bool isMobilePhoneOrNull(Control control) { if (FormValidators.hasText(control)) { return(Validators.isMobilePhone(control.Text)); } return(true); }
public static bool isPhoneWithExtensionOrNull(Control control) { if (FormValidators.hasText(control)) { return(Validators.isPhoneWithExtension(control.Text)); } return(true); }
public static bool isParticularPhone(Control control) { if (FormValidators.hasText(control)) { return(Validators.isParticularPhone(control.Text)); } return(false); }
public static bool isCurrency(Control control) { if (FormValidators.hasText(control)) { return(Validators.isCurrency(control.Text)); } return(false); }
/// <summary> /// Return an error message if any control is invalid /// </summary> /// <param name="validators"></param> /// <returns>string</returns> public static ControlErrorProvider validForm(ToValidate[] validators) { string errorMessage = null; Control control = null; foreach (ToValidate validator in validators) { errorMessage = FormValidators.validControl(validator.Control, validator.ControlValidators, validator.ErrorMessages); control = validator.Control; if (!(errorMessage == null)) { break; } } return(errorMessage == null ? null : new ControlErrorProvider(errorMessage, control)); }
public static bool isEmail(Control control) { if (FormValidators.hasText(control)) { try { MailAddress m = new MailAddress(control.Text); return(true); } catch (FormatException) { return(false); } } return(false); }
public static List <ControlErrorProvider> validFormTest(ToValidate[] validators) { List <ControlErrorProvider> errors = new List <ControlErrorProvider>(); string errorMessage = null; Control control = null; bool hasErrors = false; foreach (ToValidate validator in validators) { errorMessage = FormValidators.validControl(validator.Control, validator.ControlValidators, validator.ErrorMessages); if (errorMessage != null) { hasErrors = true; } control = validator.Control; errors.Add(new ControlErrorProvider(errorMessage, control)); } return(!hasErrors ? null : errors); }