@@ -11,35 +11,7 @@ namespace LambdaConverters
11
11
/// </summary>
12
12
public static class Validator
13
13
{
14
- abstract class Rule : LambdaConverters . Rule
15
- {
16
- protected Rule (
17
- RuleErrorStrategy errorStrategy ,
18
- object defaultInputTypeValue ,
19
- [ NotNull ] Type inputType ,
20
- bool isRuleFunctionAvailable )
21
- : base (
22
- errorStrategy ,
23
- defaultInputTypeValue ,
24
- inputType ,
25
- isRuleFunctionAvailable ) { }
26
-
27
- protected abstract ValidationResult ValidateInternal ( object value , CultureInfo cultureInfo ) ;
28
-
29
- public override ValidationResult Validate ( object value , CultureInfo cultureInfo )
30
- {
31
- if ( ! IsRuleFunctionAvailable )
32
- {
33
- EventSource . Log . MissingRuleFunction ( "ruleFunction" , ErrorStrategy . ToString ( ) ) ;
34
-
35
- return GetErrorValue ( default ( ValidationResult ) ) ;
36
- }
37
-
38
- return ValidateInternal ( value , cultureInfo ) ;
39
- }
40
- }
41
-
42
- sealed class Rule < I > : Rule
14
+ sealed class Rule < I > : LambdaConverters . Rule
43
15
{
44
16
readonly Func < ValidationRuleArgs < I > , ValidationResult > ruleFunction ;
45
17
@@ -51,7 +23,7 @@ internal Rule(
51
23
this . ruleFunction = ruleFunction ;
52
24
}
53
25
54
- protected override ValidationResult ValidateInternal ( object item , CultureInfo cultureInfo )
26
+ ValidationResult ValidateInternal ( object item , CultureInfo cultureInfo )
55
27
{
56
28
I inputValue ;
57
29
try
@@ -69,13 +41,25 @@ protected override ValidationResult ValidateInternal(object item, CultureInfo cu
69
41
70
42
return ruleFunction ( new ValidationRuleArgs < I > ( inputValue , cultureInfo ) ) ;
71
43
}
44
+
45
+ public override ValidationResult Validate ( object value , CultureInfo cultureInfo )
46
+ {
47
+ if ( ! IsRuleFunctionAvailable )
48
+ {
49
+ EventSource . Log . MissingRuleFunction ( "ruleFunction" , ErrorStrategy . ToString ( ) ) ;
50
+
51
+ return GetErrorValue ( default ( ValidationResult ) ) ;
52
+ }
53
+
54
+ return ValidateInternal ( value , cultureInfo ) ;
55
+ }
72
56
}
73
57
74
58
/// <summary>
75
59
/// Initializes a new instance of the <see cref="ValidationRule" /> class.
76
60
/// </summary>
77
61
/// <typeparam name="I">The value type.</typeparam>
78
- /// <param name="ruleFunction">The <see cref="ValidationRule. Validate" /> method.</param>
62
+ /// <param name="ruleFunction">The Validate method.</param>
79
63
/// <param name="errorStrategy">The error strategy.</param>
80
64
/// <returns>An <see cref="ValidationRule" /> object.</returns>
81
65
/// <exception cref="ArgumentOutOfRangeException">
0 commit comments