Interface IBatchAddressValidationService<TRequest>
- Namespace
- Visus.AddressValidation.Services
- Assembly
- Visus.AddressValidation.dll
Opt-in abstraction for an IAddressValidationService<TRequest> whose underlying provider API natively supports validating multiple addresses in a single call.
public interface IBatchAddressValidationService<in TRequest> where TRequest : AbstractAddressValidationRequest
Type Parameters
TRequestThe type of the validation request. Must derive from AbstractAddressValidationRequest.
Methods
ValidateManyAsync(IReadOnlyList<TRequest>, CancellationToken)
Validates the specified requests asynchronously as a single batch call.
Task<IReadOnlyList<IAddressValidationResponse?>> ValidateManyAsync(IReadOnlyList<in TRequest> requests, CancellationToken cancellationToken = default)
Parameters
requestsIReadOnlyList<TRequest>The addresses to validate, in the order results should be returned in.
cancellationTokenCancellationTokenA cancellation token that can be used to cancel the work.
Returns
- Task<IReadOnlyList<IAddressValidationResponse>>
A task producing a list of IAddressValidationResponse (or null), positionally aligned with
requests.
Remarks
The returned list always has the same length and the same order as requests. An entry
is an EmptyAddressValidationResponse when the corresponding request failed local
validation, or when the provider could not resolve that specific address. An entry is
null only when the entire underlying API call for the batch produced no response at
all (mirroring the "no response" semantics of ValidateAsync(TRequest, CancellationToken));
this can only ever apply to positions that held a locally-valid request.
Exceptions
- ArgumentNullException
Thrown when
requestsis null.- ArgumentException
Thrown synchronously when
requestscontains more items than the provider's maximum supported batch size.- InvalidImplementationException
Thrown when the registered batch response validator returns a different number of results than the number of items sent to the provider.