/// <summary> /// Check if the string is an email. /// </summary> /// <param name="e"></param> public static void IsEmail(ValidatorEventArgs e) => e.Status = IsEmail(e.Value as string) ? ValidationStatus.Success : ValidationStatus.Error;
/// <summary> /// Empty validator. /// </summary> /// <param name="e"></param> public static void None(ValidatorEventArgs e) => e.Status = ValidationStatus.None;
/// <summary> /// Checks if the selection based input has a valid value selected. Valid values are /// anything except for <c>null</c>, <c>string.Empty</c>, or <c>0</c>. /// </summary> /// <param name="e"></param> public static void IsSelected(ValidatorEventArgs e) { var value = e.Value?.ToString(); e.Status = string.IsNullOrEmpty(value) || value == "0" ? ValidationStatus.Error : ValidationStatus.Success; }
/// <summary> /// Check if the string contains only letters, numbers and underscore. /// </summary> /// <param name="e"></param> public static void IsAlphanumericWithUnderscore(ValidatorEventArgs e) => e.Status = IsAlphanumericWithUnderscore(e.Value as string) ? ValidationStatus.Success : ValidationStatus.Error;
/// <summary> /// Checks if the boolean based input is checked. /// </summary> /// <param name="e"></param> public static void IsChecked(ValidatorEventArgs e) { Converters.TryChangeType <bool>(e.Value, out var result); e.Status = result ? ValidationStatus.Success : ValidationStatus.Error; }