示例#1
0
 public static IValidationPropertyRuleBuilder <T, TProperty> GreaterThanOrEqual <T, TProperty>(this IValidationPropertyRuleBuilder <T, TProperty> instance, TProperty value)
     where TProperty : IComparable
 {
     return(instance.Must(x => x.CompareTo(value) != -1, $"greater than or equal {value}"));
 }
示例#2
0
 public static IValidationPropertyRuleBuilder <T, string> Matches <T>(this IValidationPropertyRuleBuilder <T, string> instance, string pattern)
 {
     return(instance.Must(x => Regex.Match(x, pattern).Success, $"matches {pattern} regex pattern"));
 }
示例#3
0
 // IComparable
 public static IValidationPropertyRuleBuilder <T, TProperty> LessThan <T, TProperty>(this IValidationPropertyRuleBuilder <T, TProperty> instance, TProperty value)
     where TProperty : IComparable
 {
     return(instance.Must(x => x.CompareTo(value) == -1, $"less than {value}"));
 }
示例#4
0
 public static IValidationPropertyRuleBuilder <T, string> MaximumLength <T>(this IValidationPropertyRuleBuilder <T, string> instance, int maximumLength)
 {
     return(instance.Must(x => x.Length <= maximumLength, $"shorter than {maximumLength} characters"));
 }
示例#5
0
 public static IValidationPropertyRuleBuilder <T, string> MinimumLength <T>(this IValidationPropertyRuleBuilder <T, string> instance, int minimumLength)
 {
     return(instance.Must(x => x.Length >= minimumLength, $"longer than {minimumLength} characters"));
 }
示例#6
0
 public static IValidationPropertyRuleBuilder <T, string> Empty <T>(this IValidationPropertyRuleBuilder <T, string> instance)
 {
     return(instance.Must(x => x.Length == 0, "empty"));
 }
示例#7
0
 public static IValidationPropertyRuleBuilder <T, TProperty> Equal <T, TProperty>(this IValidationPropertyRuleBuilder <T, TProperty> instance, TProperty value)
 {
     return(instance.Must(x => x.Equals(value), $"equal to {value}"));
 }
示例#8
0
 public static IValidationPropertyRuleBuilder <T, TProperty> Null <T, TProperty>(this IValidationPropertyRuleBuilder <T, TProperty> instance)
 {
     return(instance.Must(x => x == null, "null"));
 }