Class MessageEnrichingValidatorDecorator<TValidated>
A decorator service which wraps a IValidator<TValidated> and extends it to be usable as either a IValidator<TValidated> or IValidator.
Inheritance
Inherited Members
Namespace: CSF.Validation
Assembly: CSF.Validation.dll
Syntax
public class MessageEnrichingValidatorDecorator<TValidated> : IValidator<TValidated>, IValidator
Type Parameters
Name | Description |
---|---|
TValidated | The type of the object which is validated. |
Constructors
| Improve this Doc View SourceMessageEnrichingValidatorDecorator(IValidator<TValidated>, IAddsFailureMessagesToResult, IGetsResolvedValidationOptions)
Initialises a new instance of MessageEnrichingValidatorDecorator<TValidated>.
Declaration
public MessageEnrichingValidatorDecorator(IValidator<TValidated> validator, IAddsFailureMessagesToResult failureMessageEnricher, IGetsResolvedValidationOptions optionsResolver)
Parameters
Type | Name | Description |
---|---|---|
IValidator<TValidated> | validator | A validator instance. |
IAdds |
failureMessageEnricher | A service which adds failure messages to validation results. |
IGets |
optionsResolver | An options resolving service. |
Exceptions
Type | Condition |
---|---|
System. |
If any parameter is null. |
Properties
| Improve this Doc View SourceValidatedType
Gets the type of object that this validator is intended to validate.
Declaration
public Type ValidatedType { get; }
Property Value
Type | Description |
---|---|
System. |
Remarks
The first parameter to Validate
Methods
| Improve this Doc View SourceValidateAsync(TValidated, ValidationOptions, CancellationToken)
Validate the specified object instance asynchronously and get a validation result.
Declaration
public async Task<IQueryableValidationResult<TValidated>> ValidateAsync(TValidated validatedObject, ValidationOptions options = null, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
TValidated | validatedObject | The object to be validated. |
Validation |
options | An optional object containing configuration options related to the validation process. |
System. |
cancellationToken | An optional object which enables premature cancellation of the validation process. |
Returns
Type | Description |
---|---|
System. |
A task containing the result of the validation process. |
Exceptions
Type | Condition |
---|---|
Validation |
If the validation process fails or errors and the Rule |
Explicit Interface Implementations
| Improve this Doc View SourceIValidator.ValidateAsync(Object, ValidationOptions, CancellationToken)
Declaration
async Task<ValidationResult> IValidator.ValidateAsync(object validatedObject, ValidationOptions options, CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
System. |
validatedObject | |
Validation |
options | |
System. |
cancellationToken |
Returns
Type | Description |
---|---|
System. |