Repository navigation
Expand file tree
/
Copy pathValidationExtensions.DictionaryRule.cs
More file actions
65 lines (60 loc) · 6.65 KB
/
Copy pathValidationExtensions.DictionaryRule.cs
File metadata and controls
65 lines (60 loc) · 6.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
namespace CoreEx.Validation;
public static partial class ValidationExtensions
{
/// <summary>
/// Chains a dictionary (<see cref="DictionaryRule{TEntity, TProperty, TKey, TItem}"/>) validation to the existing <paramref name="rule"/>.
/// </summary>
/// <typeparam name="TEntity">The entity <see cref="Type"/>.</typeparam>
/// <typeparam name="TKey">The key <see cref="Type"/>.</typeparam>
/// <typeparam name="TValue">The value <see cref="Type"/>.</typeparam>
/// <param name="rule">The <see cref="IPropertyRule{TEntity, TProperty}"/> being extended.</param>
/// <param name="with">Extends configuration <see cref="DictionaryRule{TEntity, TProperty, TKey, TValue}.With"/>.</param>
public static DictionaryRule<TEntity, IDictionary<TKey, TValue>, TKey, TValue> Dictionary<TEntity, TKey, TValue>(this IPropertyRule<TEntity, IDictionary<TKey, TValue>> rule, Func<DictionaryRule<TEntity, IDictionary<TKey, TValue>, TKey, TValue>.With, DictionaryRule<TEntity, IDictionary<TKey, TValue>, TKey, TValue>.With> with) where TEntity : class where TKey : notnull where TValue : notnull
=> (DictionaryRule<TEntity, IDictionary<TKey, TValue>, TKey, TValue>)Chain(rule, new DictionaryRule<TEntity, IDictionary<TKey, TValue>, TKey, TValue>(null, null, with));
/// <summary>
/// Chains a collection (<see cref="DictionaryRule{TEntity, TProperty, TKey, TItem}"/>) validation to the existing <paramref name="rule"/>.
/// </summary>
/// <typeparam name="TEntity">The entity <see cref="Type"/>.</typeparam>
/// <typeparam name="TKey">The key <see cref="Type"/>.</typeparam>
/// <typeparam name="TValue">The value <see cref="Type"/>.</typeparam>
/// <param name="rule">The <see cref="IPropertyRule{TEntity, TProperty}"/> being extended.</param>
/// <param name="maxCount">The maximum count.</param>
/// <param name="with">Extends configuration <see cref="DictionaryRule{TEntity, TProperty, TKey, TValue}.With"/>.</param>
public static DictionaryRule<TEntity, IDictionary<TKey, TValue>, TKey, TValue> Dictionary<TEntity, TKey, TValue>(this IPropertyRule<TEntity, IDictionary<TKey, TValue>> rule, int maxCount, Func<DictionaryRule<TEntity, IDictionary<TKey, TValue>, TKey, TValue>.With, DictionaryRule<TEntity, IDictionary<TKey, TValue>, TKey, TValue>.With>? with = null) where TEntity : class where TKey : notnull where TValue : notnull
=> (DictionaryRule<TEntity, IDictionary<TKey, TValue>, TKey, TValue>)Chain(rule, new DictionaryRule<TEntity, IDictionary<TKey, TValue>, TKey, TValue>(null, _ => maxCount, with));
/// <summary>
/// Chains a collection (<see cref="DictionaryRule{TEntity, TProperty, TKey, TItem}"/>) validation to the existing <paramref name="rule"/>.
/// </summary>
/// <typeparam name="TEntity">The entity <see cref="Type"/>.</typeparam>
/// <typeparam name="TKey">The key <see cref="Type"/>.</typeparam>
/// <typeparam name="TValue">The value <see cref="Type"/>.</typeparam>
/// <param name="rule">The <see cref="IPropertyRule{TEntity, TProperty}"/> being extended.</param>
/// <param name="maxCount">The maximum count.</param>
/// <param name="with">Extends configuration <see cref="DictionaryRule{TEntity, TProperty, TKey, TValue}.With"/>.</param>
public static DictionaryRule<TEntity, IDictionary<TKey, TValue>, TKey, TValue> Dictionary<TEntity, TKey, TValue>(this IPropertyRule<TEntity, IDictionary<TKey, TValue>> rule, Func<PropertyContext<TEntity, IDictionary<TKey, TValue>>, int?>? maxCount, Func<DictionaryRule<TEntity, IDictionary<TKey, TValue>, TKey, TValue>.With, DictionaryRule<TEntity, IDictionary<TKey, TValue>, TKey, TValue>.With>? with = null) where TEntity : class where TKey : notnull where TValue : notnull
=> (DictionaryRule<TEntity, IDictionary<TKey, TValue>, TKey, TValue>)Chain(rule, new DictionaryRule<TEntity, IDictionary<TKey, TValue>, TKey, TValue>(null, maxCount, with));
/// <summary>
/// Chains a collection (<see cref="DictionaryRule{TEntity, TProperty, TKey, TItem}"/>) validation to the existing <paramref name="rule"/>.
/// </summary>
/// <typeparam name="TEntity">The entity <see cref="Type"/>.</typeparam>
/// <typeparam name="TKey">The key <see cref="Type"/>.</typeparam>
/// <typeparam name="TValue">The value <see cref="Type"/>.</typeparam>
/// <param name="rule">The <see cref="IPropertyRule{TEntity, TProperty}"/> being extended.</param>
/// <param name="minCount">The minimum count.</param>
/// <param name="maxCount">The maximum count.</param>
/// <param name="with">Extends configuration <see cref="DictionaryRule{TEntity, TProperty, TKey, TValue}.With"/>.</param>
public static DictionaryRule<TEntity, IDictionary<TKey, TValue>, TKey, TValue> Dictionary<TEntity, TKey, TValue>(this IPropertyRule<TEntity, IDictionary<TKey, TValue>> rule, int minCount, int? maxCount, Func<DictionaryRule<TEntity, IDictionary<TKey, TValue>, TKey, TValue>.With, DictionaryRule<TEntity, IDictionary<TKey, TValue>, TKey, TValue>.With>? with = null) where TEntity : class where TKey : notnull where TValue : notnull
=> (DictionaryRule<TEntity, IDictionary<TKey, TValue>, TKey, TValue>)Chain(rule, new DictionaryRule<TEntity, IDictionary<TKey, TValue>, TKey, TValue>(_ => minCount, _ => maxCount, with));
/// <summary>
/// Chains a collection (<see cref="DictionaryRule{TEntity, TProperty, TKey, TItem}"/>) validation to the existing <paramref name="rule"/>.
/// </summary>
/// <typeparam name="TEntity">The entity <see cref="Type"/>.</typeparam>
/// <typeparam name="TKey">The key <see cref="Type"/>.</typeparam>
/// <typeparam name="TValue">The value <see cref="Type"/>.</typeparam>
/// <param name="rule">The <see cref="IPropertyRule{TEntity, TProperty}"/> being extended.</param>
/// <param name="minCount">The minimum count.</param>
/// <param name="maxCount">The maximum count.</param>
/// <param name="with">Extends configuration <see cref="DictionaryRule{TEntity, TProperty, TKey, TValue}.With"/>.</param>
public static DictionaryRule<TEntity, IDictionary<TKey, TValue>, TKey, TValue> Dictionary<TEntity, TKey, TValue>(this IPropertyRule<TEntity, IDictionary<TKey, TValue>> rule, Func<PropertyContext<TEntity, IDictionary<TKey, TValue>>, int>? minCount, Func<PropertyContext<TEntity, IDictionary<TKey, TValue>>, int?>? maxCount, Func<DictionaryRule<TEntity, IDictionary<TKey, TValue>, TKey, TValue>.With, DictionaryRule<TEntity, IDictionary<TKey, TValue>, TKey, TValue>.With>? with = null) where TEntity : class where TKey : notnull where TValue : notnull
=> (DictionaryRule<TEntity, IDictionary<TKey, TValue>, TKey, TValue>)Chain(rule, new DictionaryRule<TEntity, IDictionary<TKey, TValue>, TKey, TValue>(minCount, maxCount, with));
}