Exemple #1
0
 /// <summary>
 ///   Checks if value is not match regex
 /// </summary>
 public static IValidationCondition <string> IsNotMatch(
     this IValidationCondition <string> condition,
     string regex,
     RegexOptions options = RegexOptions.None)
 {
     return(condition.IsNot(value => Regex.IsMatch(value, regex, options)));
 }
Exemple #2
0
 /// <summary>
 ///   Checks value is not in range (min: inclusive, max: exclusive)
 /// </summary>
 public static IValidationCondition <TValue> IsNotInRange <TValue>(
     this IValidationCondition <TValue> condition,
     TValue min,
     TValue max)
     where TValue : IComparable <TValue>
 {
     return(condition.IsNot(value => value.CompareTo(min) >= 0 && value.CompareTo(max) < 0));
 }
 /// <summary>
 ///   Checks if value is not valid
 /// </summary>
 public static IValidationCondition <TValue> IsNot <TValue>(
     this IValidationCondition <TValue> condition,
     Func <TValue, bool> predicate)
 {
     return(condition.IsNot(() => predicate(condition.Value)));
 }
 /// <summary>
 ///   Checks values has a value
 /// </summary>
 public static IValidationCondition <TValue> IsNotIn <TValue>(
     this IValidationCondition <TValue> condition,
     params TValue[] values)
 {
     return(condition.IsNot(value => values.Contains(condition.Value)));
 }
 /// <summary>
 ///   Checks values has a value
 /// </summary>
 public static IValidationCondition <TValue> IsNotIn <TValue>(
     this IValidationCondition <TValue> condition,
     IEnumerable <TValue> values)
 {
     return(condition.IsNot(value => values.Contains(condition.Value)));
 }
Exemple #6
0
 /// <summary>
 ///   Checks value is false
 /// </summary>
 public static IValidationCondition <bool> IsFalse(
     this IValidationCondition <bool> condition)
 {
     return(condition.IsNot(value => value));
 }
Exemple #7
0
 /// <summary>
 ///   Checks collection is not contains
 /// </summary>
 public static IValidationCondition <ICollection <TElement> > IsNotContains <TElement>(
     this IValidationCondition <ICollection <TElement> > condition,
     TElement element)
 {
     return(condition.IsNot(value => value?.Contains(element) ?? false));
 }
Exemple #8
0
 /// <summary>
 ///   Checks collection has count not
 /// </summary>
 public static IValidationCondition <ICollection <TElement> > HasCountNot <TElement>(
     this IValidationCondition <ICollection <TElement> > condition,
     int count)
 {
     return(condition.IsNot(value => value?.Count == count));
 }
Exemple #9
0
 /// <summary>
 ///   Checks if value is not valid email string
 /// </summary>
 public static IValidationCondition <string> IsNotEmail(
     this IValidationCondition <string> condition)
 {
     return(condition.IsNot(value => EmailAddress.IsValid(value)));
 }
Exemple #10
0
 public static IValidationCondition <string> IsNotNullOrWhitespace(
     this IValidationCondition <string> condition)
 {
     return(condition.IsNot(string.IsNullOrWhiteSpace));
 }
Exemple #11
0
 /// <summary>
 ///   Checks if value is not whitespace
 /// </summary>
 public static IValidationCondition <string> IsNotWhitespace(
     this IValidationCondition <string> condition)
 {
     return(condition.IsNot(value => value?.All(x => char.IsWhiteSpace(x)) ?? false));
 }
Exemple #12
0
 public static IValidationCondition <string> IsNotEmpty(
     this IValidationCondition <string> condition,
     StringComparison stringComparison = StringComparison.InvariantCulture)
 {
     return(condition.IsNot(value => value.Equals(string.Empty, stringComparison)));
 }
Exemple #13
0
 /// <summary>
 ///   Checks if value is not valid url string
 /// </summary>
 public static IValidationCondition <string> IsNotUrl(
     this IValidationCondition <string> condition,
     UriKind kind = UriKind.Absolute)
 {
     return(condition.IsNot(value => Uri.TryCreate(condition.Value, kind, out _)));
 }
Exemple #14
0
 /// <summary>
 ///   Checks not all elements suites for predicate
 /// </summary>
 public static IValidationCondition <IEnumerable <TElement> > IsNotAll <TElement>(
     this IValidationCondition <IEnumerable <TElement> > condition,
     Func <TElement, bool> predicate)
 {
     return(condition.IsNot(value => value?.All(predicate) ?? false));
 }
Exemple #15
0
 /// <summary>
 ///   Checks enumerable has no elements
 /// </summary>
 public static IValidationCondition <IEnumerable <TElement> > IsNotAny <TElement>(
     this IValidationCondition <IEnumerable <TElement> > condition)
 {
     return(condition.IsNot(value => value?.Any() ?? false));
 }
Exemple #16
0
 /// <summary>
 ///   Checks DateTime kind not
 /// </summary>
 public static IValidationCondition <DateTime> IsNotDateTimeKind(
     this IValidationCondition <DateTime> validationCondition,
     DateTimeKind dateTimeKind)
 {
     return(validationCondition.IsNot(value => value.Kind == dateTimeKind));
 }