-
Notifications
You must be signed in to change notification settings - Fork 0
/
ValidationError.cs
79 lines (66 loc) · 2.89 KB
/
ValidationError.cs
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
using System;
using ValidationFramework.Reflection;
namespace ValidationFramework
{
/// <summary>
/// The results of any <see cref="ValidationFramework.Rule.Validate"/> operation.
/// </summary>
/// <remarks>An instance is only created if the <see cref="ValidationFramework.Rule.Validate"/> operation fails.</remarks>
///// <example>
///// <code source="Examples\ExampleLibraryCSharp\Reflection\GetReflectionInfoFromValidationResult.cs" title="This example shows how to get a Type or a MethodBase from a ValidationResult." lang="cs"/>
///// <code source="Examples\ExampleLibraryVB\Reflection\GetReflectionInfoFromValidationResult.vb" title="This example shows how to get a Type or a MethodBase from a ValidationResult." lang="vbnet"/>
///// </example>
public class ValidationError
{
#region Constructors
/// <remarks>
/// null is an invalid value for both <paramref name="rule"/> and <paramref name="errorMessage"/>.
/// Due to performance concerns <see cref="ArgumentNullException"/> will no be thrown.
/// So just don't pass in null or an empty string.
/// </remarks>
/// <param name="rule">The <see cref="Rule"/> that this <see cref="ValidationError"/> has been generated from.</param>
/// <param name="errorMessage">The error message.</param>
/// <param name="attemptedValue">The invalid member's value</param>
/// <param name="infoDescriptor">The <see cref="InfoDescriptor"/> that this <see cref="ValidationError"/> has been generated from.</param>
public ValidationError(Rule rule, string errorMessage, object attemptedValue, InfoDescriptor infoDescriptor)
{
//Dont guard these. the performance hit is not worth the minor help it gives developers.
Rule = rule;
ErrorMessage = errorMessage;
AttemptedValue = attemptedValue;
InfoDescriptor = infoDescriptor;
}
#endregion
#region Properties
/// <summary>
/// Gets the error message for the <see cref="ValidationError"/>.
/// </summary>
public string ErrorMessage
{
get;
private set;
}
/// <summary>
/// Gets the <see cref="Rule"/> that this <see cref="ValidationError"/> has been generated from.
/// </summary>
/// <seealso cref="ValidationFramework.Rule.Validate"/>
public Rule Rule
{
get;
private set;
}
/// <summary>
/// Gets the invalid member's value
/// </summary>
public object AttemptedValue
{
get;
private set;
}
/// <summary>
/// Gets the <see cref="InfoDescriptor"/> that this <see cref="ValidationError"/> was generated for.
/// </summary>
public InfoDescriptor InfoDescriptor { get; private set; }
#endregion
}
}