Table of Contents

Class AbstractAddressValidationService<TRequest, TApiResponse>

Namespace
Visus.AddressValidation.Services
Assembly
Visus.AddressValidation.dll

Abstract base class for implementing an IAddressValidationService<TRequest>.

public abstract class AbstractAddressValidationService<TRequest, TApiResponse> : IAddressValidationService<TRequest> where TRequest : AbstractAddressValidationRequest where TApiResponse : class

Type Parameters

TRequest

The type of the validation request. Must derive from AbstractAddressValidationRequest.

TApiResponse

The type of API response the provider returns. An IApiResponseMapper<TResponse> maps it to an IAddressValidationResponse.

Inheritance
AbstractAddressValidationService<TRequest, TApiResponse>
Implements
Inherited Members

Constructors

AbstractAddressValidationService(IApiRequestAdapter<TRequest, TApiResponse>, IApiResponseMapper<TApiResponse>, IValidator<TRequest>, IValidator<TApiResponse>)

protected AbstractAddressValidationService(IApiRequestAdapter<TRequest, TApiResponse> requestAdapter, IApiResponseMapper<TApiResponse> responseMapper, IValidator<TRequest> requestValidator, IValidator<TApiResponse> responseValidator)

Parameters

requestAdapter IApiRequestAdapter<TRequest, TApiResponse>

An IApiRequestAdapter<TRequest, TApiResponse> that sends TRequest instances to the provider and returns the TApiResponse.

responseMapper IApiResponseMapper<TApiResponse>

An IApiResponseMapper<TResponse> that maps TApiResponse instances to an IAddressValidationResponse.

requestValidator IValidator<TRequest>

An IValidator<T> that validates TRequest instances before the service sends them to the provider.

responseValidator IValidator<TApiResponse>

An IValidator<T> that validates TApiResponse instances the provider returns.

Exceptions

ArgumentNullException

Thrown when requestAdapter, responseMapper, requestValidator, or responseValidator is null.

InvalidImplementationException

Thrown when requestValidator does not derive from AbstractAddressValidationRequestValidator<T>, or when responseValidator does not derive from AbstractValidator<T>.

Methods

ValidateAsync(TRequest, CancellationToken)

Validates the request instance asynchronously.

public Task<IAddressValidationResponse?> ValidateAsync(TRequest request, CancellationToken cancellationToken = default)

Parameters

request TRequest

The TRequest instance to validate.

cancellationToken CancellationToken

A token that cancels the operation.

Returns

Task<IAddressValidationResponse>

The validation result as an IAddressValidationResponse.

Remarks

The returned IAddressValidationResponse may be null if the provider returns no response. If the request or response fails validation, this method returns an EmptyAddressValidationResponse instead.