Class ValidationResult
A model for the results of a validation process.
Implements
Inherited Members
Namespace: CSF.Validation
Assembly: CSF.Validation.Abstractions.dll
Syntax
public abstract class ValidationResult : IQueryableValidationResult, IEnumerable<ValidationRuleResult>, IEnumerable
Constructors
| Improve this Doc View SourceValidationResult(IEnumerable<ValidationRuleResult>, ValidationManifest, Nullable<TimeSpan>)
Initialises a new instance of ValidationResult.
Declaration
protected ValidationResult(IEnumerable<ValidationRuleResult> ruleResults, ValidationManifest manifest, TimeSpan? validationTime = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEnumerable<ValidationRuleResult> | ruleResults | The rule results. |
| ValidationManifest | manifest | The validation manifest |
| System.Nullable<System.TimeSpan> | validationTime | The time it has taken to perform validation. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | If either of the first two parameters is null. |
Properties
| Improve this Doc View SourceManifest
Declaration
public ValidationManifest Manifest { get; }
Property Value
| Type | Description |
|---|---|
| ValidationManifest |
Passed
Gets a value that indicates whether or not the current instance represents passing validation.
Declaration
public bool Passed { get; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
RuleResults
Gets a collection of the results of individual validation rules, making up the current validation result.
Declaration
public IReadOnlyCollection<ValidationRuleResult> RuleResults { get; }
Property Value
| Type | Description |
|---|---|
| System.Collections.Generic.IReadOnlyCollection<ValidationRuleResult> |
ValidationTime
Gets a value indicating how long the validation process took.
Declaration
public TimeSpan? ValidationTime { get; }
Property Value
| Type | Description |
|---|---|
| System.Nullable<System.TimeSpan> |
Remarks
This value will only be populated if InstrumentRuleExecution is set to true. Otherwise it will be null.
When EnableRuleParallelization is true the sum of the times reported within each InstrumentationData will likely not total the amount reported by this property. That is because many of the reported times for each of the rules will have run concurrently with other rules. On the other hand, this time does correspond to real "wall clock" time to perform validation.
Methods
| Improve this Doc View SourceAsResultFor<T>()
Gets a representation of the current queryable result as a strongly-typed queryable result.
Declaration
public IQueryableValidationResult<T> AsResultFor<T>()
Returns
| Type | Description |
|---|---|
| IQueryableValidationResult<T> | The same conceptual queryable result, cast to a specified type. |
Type Parameters
| Name | Description |
|---|---|
| T | The validated-type for the queryable result. |
Exceptions
| Type | Condition |
|---|---|
| System.InvalidCastException | If the |
ToSerializableResult()
Gets a representation of the current result as a serializable validation result.
Declaration
public abstract SerializableValidationResult ToSerializableResult()
Returns
| Type | Description |
|---|---|
| SerializableValidationResult | A copy of the current validation result, in an easily-serializable format. |
Remarks
Whilst the validation result types represented by IQueryableValidationResult & IQueryableValidationResult<TValidated> are powerful and include querying/matching functionality, they are cumbersome to serialize and/or transmit via network APIs such as JSON or XML. The SerializableValidationResult trades the powerful functionality for a simplified, flattened object model which is easy to serialize, and convert to other formats such as JSON, XML or data to be persisted in a relational database.
ToString()
Gets a string representation of the current instance.
Declaration
public override string ToString()
Returns
| Type | Description |
|---|---|
| System.String | A string representation. |
Overrides
ToString(IEnumerable<RuleOutcome>)
Gets a string representation of the current instance, possibly skipping some rule results with irrelevant outcomes.
Declaration
public string ToString(IEnumerable<RuleOutcome> omittedOutcomes)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEnumerable<RuleOutcome> | omittedOutcomes | An optional collection of rule outcomes to omit when displaying rule results. |
Returns
| Type | Description |
|---|---|
| System.String | A string representation. |
Explicit Interface Implementations
| Improve this Doc View SourceIQueryableValidationResult.ManifestValue
Declaration
ManifestItem IQueryableValidationResult.ManifestValue { get; }
Returns
| Type | Description |
|---|---|
| ManifestItem |
IEnumerable<ValidationRuleResult>.GetEnumerator()
Declaration
IEnumerator<ValidationRuleResult> IEnumerable<ValidationRuleResult>.GetEnumerator()
Returns
| Type | Description |
|---|---|
| System.Collections.Generic.IEnumerator<ValidationRuleResult> |
IEnumerable.GetEnumerator()
Declaration
IEnumerator IEnumerable.GetEnumerator()
Returns
| Type | Description |
|---|---|
| System.Collections.IEnumerator |