Show / Hide Table of Contents

Class ValidationResult<TValidated>

A strongly-typed validation result.

Inheritance
System.Object
ValidationResult
ValidationResult<TValidated>
Implements
IQueryableValidationResult<TValidated>
IQueryableValidationResult
System.Collections.Generic.IEnumerable<ValidationRuleResult>
System.Collections.IEnumerable
Inherited Members
ValidationResult.Passed
ValidationResult.RuleResults
ValidationResult.Manifest
ValidationResult.ValidationTime
ValidationResult.AsResultFor<T>()
ValidationResult.IQueryableValidationResult.ManifestValue
ValidationResult.IEnumerable<ValidationRuleResult>.GetEnumerator()
ValidationResult.IEnumerable.GetEnumerator()
ValidationResult.ToString()
ValidationResult.ToString(IEnumerable<RuleOutcome>)
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
Assembly: CSF.Validation.dll
Syntax
public class ValidationResult<TValidated> : ValidationResult, IQueryableValidationResult<TValidated>, IQueryableValidationResult, IEnumerable<ValidationRuleResult>, IEnumerable
Type Parameters
Name Description
TValidated

Constructors

| Improve this Doc View Source

ValidationResult(IEnumerable<ValidationRuleResult>, ValidationManifest, Nullable<TimeSpan>)

Initialises a new generic instance of ValidationResult<TValidated>.

Declaration
public 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.ArgumentException

If manifest is for a type that is not compatible with TValidated.

System.ArgumentNullException

If either parameter is null.

Methods

| Improve this Doc View Source

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

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

System.ArgumentException

If the ManifestValue has no child values with the same name as the memberExpression.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

ToSerializableResult()

Gets a representation of the current result as a serializable validation result.

Declaration
public override SerializableValidationResult ToSerializableResult()
Returns
Type Description
SerializableValidationResult

A copy of the current validation result, in an easily-serializable format.

Overrides
ValidationResult.ToSerializableResult()
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.

| Improve this Doc View Source

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.

Implements

IQueryableValidationResult<TValidated>
IQueryableValidationResult
System.Collections.Generic.IEnumerable<T>
System.Collections.IEnumerable
  • Improve this Doc
  • View Source
In This Article
Back to top Generated by DocFX