Show / Hide Table of Contents

Class RuleResult

A model for information about the result of running a single validation rule.

Inheritance
System.Object
RuleResult
ValidationRuleResult
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
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 Source

RuleResult(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 outcome is not Errored.

Exceptions
Type Condition
System.ArgumentException

If the outcome is not Errored but the exception is not null.

| Improve this Doc View Source

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 result is null.

Properties

| Improve this Doc View Source

Data

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>
| Improve this Doc View Source

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
| Improve this Doc View Source

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
| Improve this Doc View Source

Outcome

Gets the outcome of the validation rule.

Declaration
public RuleOutcome Outcome { get; }
Property Value
Type Description
RuleOutcome
| Improve this Doc View Source

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
IHasRuleTimeout

Methods

| Improve this Doc View Source

ToString()

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.

Overrides
System.Object.ToString()
  • Improve this Doc
  • View Source
In This Article
Back to top Generated by DocFX