public static IPropertyRuleBuilder<T, TProperty> Count<T, TProperty>( this IPropertyRuleBuilder<T, TProperty> ruleBuilder, int count) where T : class where TProperty : IEnumerable { return ruleBuilder.Must((_, property) => property.Cast<object>().Count() == count); }
public static IPropertyRuleBuilder<T, TProperty> IsNotEmpty<T, TProperty>( this IPropertyRuleBuilder<T, TProperty> ruleBuilder) where T : class where TProperty : IEnumerable { return ruleBuilder.Must((_, property) => property.Cast<object>().Any()); }
public static IPropertyRuleBuilder<T, TProperty> IsNotNull<T, TProperty>( this IPropertyRuleBuilder<T, TProperty> ruleBuilder) where T : class where TProperty : class { return ruleBuilder.Must((_, property) => property != null); }
public static IPropertyRuleBuilder<T, TProperty> Contains<T, TProperty, TElement>( this IPropertyRuleBuilder<T, TProperty> ruleBuilder, TElement element) where T : class where TProperty : IEnumerable<TElement> { return ruleBuilder.Must((_, property) => property.Contains(element)); }
public static IPropertyRuleBuilder<T, string> IsNotEqual<T>( this IPropertyRuleBuilder<T, string> ruleBuilder, string compareValue, StringComparison stringComparison) where T : class { return ruleBuilder.Must((_, property) => !(property == null && compareValue == null || property?.ToString().Equals(compareValue, stringComparison) == true)); }
public static IPropertyRuleBuilder<T, TProperty> Contains<T, TProperty>( this IPropertyRuleBuilder<T, TProperty> ruleBuilder, object element) where T : class where TProperty : IEnumerable { return ruleBuilder.Must((_, property) => property .Cast<object>() .Any(x => Comparer.Default.Compare(x, element) == 0)); }
public static IPropertyRuleBuilder<T, IList<TElement>> Any<T, TElement>( this IPropertyRuleBuilder<T, IList<TElement>> ruleBuilder, Func<TElement, bool> predicate) where T : class { return ruleBuilder.Must((_, property) => property.Any(predicate)); }
public static IPropertyRuleBuilder<T, IEnumerable<TElement>> All<T, TElement>( this IPropertyRuleBuilder<T, IEnumerable<TElement>> ruleBuilder, Func<TElement, bool> predicate) where T : class { return ruleBuilder.Must((_, property) => property.All(predicate)); }
public static IPropertyRuleBuilder<T, IEnumerable<TElement>> Count<T, TElement>( this IPropertyRuleBuilder<T, IEnumerable<TElement>> ruleBuilder, int count) where T : class { return ruleBuilder.Must((_, property) => property.Count() == count); }
public static IPropertyRuleBuilder<T, IList<TElement>> Single<T, TElement>( this IPropertyRuleBuilder<T, IList<TElement>> ruleBuilder) where T : class { return ruleBuilder.Must((_, property) => property.IsSingle()); }
public static IPropertyRuleBuilder<T, string> Contains<T>( this IPropertyRuleBuilder<T, string> ruleBuilder, string text) where T : class { return ruleBuilder.Must((_, property) => property.Contains(text)); }
public static IPropertyRuleBuilder<T, TProperty> MustNot<T, TProperty>( this IPropertyRuleBuilder<T, TProperty> ruleBuilder, Func<T, TProperty, bool> validate) where T : class { return ruleBuilder.Must((instance, property) => !validate(instance, property)); }