Class RuleResult
A model for information about the result of running a single validation rule.
Inherited Members
Namespace: CSF.Validation.Rules
Assembly: CSF.Validation.Abstractions.dll
Syntax
public class RuleResult
Remarks
Validation rules are typically classes which implement either IRule<TValidated> or IRule<TValue, TParent>.
This class deals only with the possible information which could be returned by executing a validation rule. It does not contain any other contextual information which would be 'backfilled' by the validation framework. Instances of this class may be 'converted up' to instances of ValidationRuleResult for the purpose of returning final results.
Constructors
| Improve this Doc View SourceRuleResult(RuleOutcome, IDictionary<String, Object>, Exception)
Initializes a new instance of the RuleResult class.
Declaration
public RuleResult(RuleOutcome outcome, IDictionary<string, object> data = null, Exception exception = null)
Parameters
Type | Name | Description |
---|---|---|
RuleOutcome | outcome | The outcome of validation. |
System.Collections.Generic.IDictionary<System.String, System.Object> | data | An optional collection of arbitrary key/value data which is provided by the validation rule logic. |
System.Exception | exception | An optional exception which caused the validation process to error. This parameter must be null
if the |
Exceptions
Type | Condition |
---|---|
System.ArgumentException | If the |
RuleResult(RuleResult)
Initializes a new instance of the RuleResult class. This is essentially a copy-constructor.
Declaration
protected RuleResult(RuleResult result)
Parameters
Type | Name | Description |
---|---|---|
RuleResult | result | A rule result instance to copy. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | If the |
Properties
| Improve this Doc View SourceData
Gets a key/value collection of arbitrary data which has been made available by the validation rule.
Declaration
public IReadOnlyDictionary<string, object> Data { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.IReadOnlyDictionary<System.String, System.Object> |
Exception
If the Outcome is Errored then this property may provide access to the exception which caused this error. For all other outcomes this property will be null.
Declaration
public Exception Exception { get; }
Property Value
Type | Description |
---|---|
System.Exception |
IsPass
Gets a value that indicates whether or not the current result instance represents passing validation or not. This property returns true if Outcome equals Passed. This property returns false for any other outcome.
Declaration
public bool IsPass { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Outcome
Gets the outcome of the validation rule.
Declaration
public RuleOutcome Outcome { get; }
Property Value
Type | Description |
---|---|
RuleOutcome |
RuleTimeoutDataKey
A special value that indicates that the result represents a rule which have timed-out when executing.
Declaration
public static string RuleTimeoutDataKey { get; }
Property Value
Type | Description |
---|---|
System.String |
Remarks
When a result contains a data item with this key, the value is the System.TimeSpan timeout which was set.
The string key is "Validation rule timeout
".
See Also
Methods
| Improve this Doc View SourceToString()
Gets a string representation of the current instance.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
System.String | A string representation of the current object. |