Class SubsetOfValidationResults<TValidated>
An implementation of IQueryableValidationResult<TValidated> which represents a subset of a larger validation result. This is usually due to some form of filtering of the original result.
Inheritance
Implements
Inherited Members
Namespace: CSF.Validation
Assembly: CSF.Validation.dll
Syntax
public class SubsetOfValidationResults<TValidated> : IQueryableValidationResult<TValidated>, IQueryableValidationResult, IEnumerable<ValidationRuleResult>, IEnumerable
Type Parameters
| Name | Description |
|---|---|
| TValidated |
Constructors
| Improve this Doc View SourceSubsetOfValidationResults(IEnumerable<ValidationRuleResult>, ManifestItem, Nullable<TimeSpan>)
Initialises a new instance of SubsetOfValidationResults<TValidated>.
Declaration
public SubsetOfValidationResults(IEnumerable<ValidationRuleResult> ruleResults, ManifestItem manifestValue, TimeSpan? validationTime)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEnumerable<ValidationRuleResult> | ruleResults | The rule results. |
| ManifestItem | manifestValue | The manifest value. |
| System.Nullable<System.TimeSpan> | validationTime | The time it has taken to perform validation. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | If any parameter is null. |
Properties
| Improve this Doc View SourceManifestValue
Gets a reference to the manifest value which forms the logical root of the results in the current instance.
Declaration
public ManifestItem ManifestValue { get; }
Property Value
| Type | Description |
|---|---|
| ManifestItem |
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 SourceForMatchingMemberItem<TItem>(Expression<Func<TValidated, IEnumerable<TItem>>>, TItem)
Gets a subset of the current validation result, including only results applicable to a collection item that matches the specified item.
Declaration
public IQueryableValidationResult<TItem> ForMatchingMemberItem<TItem>(Expression<Func<TValidated, IEnumerable<TItem>>> memberExpression, TItem item)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Linq.Expressions.Expression<System.Func<TValidated, System.Collections.Generic.IEnumerable<TItem>>> | memberExpression | A expression indicating a member of the validated object, which returns a collection of values. |
| TItem | item | The item (of the collection) for which a result is to be filtered |
Returns
| Type | Description |
|---|---|
| IQueryableValidationResult<TItem> | A queryable result, filtered for results applicable to the specified item of a collection, and its descendents. |
Type Parameters
| Name | Description |
|---|---|
| TItem |
ForMember<TItem>(Expression<Func<TValidated, TItem>>)
Gets a subset of the current validation result, including only results applicable to the specified member and descendent members.
Declaration
public IQueryableValidationResult<TItem> ForMember<TItem>(Expression<Func<TValidated, TItem>> memberExpression)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Linq.Expressions.Expression<System.Func<TValidated, TItem>> | memberExpression | A expression indicating a member of the validated object, which returns a value. |
Returns
| Type | Description |
|---|---|
| IQueryableValidationResult<TItem> | A queryable result, filtered for results applicable to the specified member and its descendents. |
Type Parameters
| Name | Description |
|---|---|
| TItem | The type of the member item. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | If the |
| System.ArgumentException | If the ManifestValue has no child values with the same name as the |
ForOnlyThisValue()
Gets a subset of the current validation result, including rule results only for the current value. Any rule results for descendent values are excluded.
Declaration
public IQueryableValidationResult<TValidated> ForOnlyThisValue()
Returns
| Type | Description |
|---|---|
| IQueryableValidationResult<TValidated> | A queryable result, filtered for only rules directly associated with the current value. |
PolymorphicAs<TDerived>()
'Casts' the current validation result for an object of type TDerived, enabling access to
rules and values added as part of polymorphic validation.
Declaration
public IQueryableValidationResult<TDerived> PolymorphicAs<TDerived>()
where TDerived : TValidated
Returns
| Type | Description |
|---|---|
| IQueryableValidationResult<TDerived> | A queryable result, enabling access to members and rules for the derived type.. |
Type Parameters
| Name | Description |
|---|---|
| TDerived | A derived validated type. |
ToSerializableResult()
Gets a representation of the current result as a serializable validation result.
Declaration
public 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.
WithoutSuccesses()
Gets a subset of the current validation result, excluding any results which relate to a success.
Declaration
public IQueryableValidationResult<TValidated> WithoutSuccesses()
Returns
| Type | Description |
|---|---|
| IQueryableValidationResult<TValidated> | A queryable result, filtered for only rule results that do not indicate success. |
Explicit Interface Implementations
| Improve this Doc View SourceIQueryableValidationResult.AsResultFor<T>()
Declaration
IQueryableValidationResult<T> IQueryableValidationResult.AsResultFor<T>()
Returns
| Type | Description |
|---|---|
| IQueryableValidationResult<T> |
Type Parameters
| Name | Description |
|---|---|
| T |
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 |