Class ValidationResult<TValidated>
A strongly-typed validation result.
Implements
Inherited Members
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 SourceValidationResult(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 |
System.ArgumentNullException | If either parameter is null. |
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 override SerializableValidationResult ToSerializableResult()
Returns
Type | Description |
---|---|
SerializableValidationResult | A copy of the current validation result, in an easily-serializable format. |
Overrides
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. |