Class AbstractAddressValidationRequestValidator<T>
- Namespace
- Visus.AddressValidation.Validation
- Assembly
- Visus.AddressValidation.dll
Base Validator for AbstractAddressValidationRequest instances.
public abstract class AbstractAddressValidationRequestValidator<T> : AbstractValidator<T>, IValidator<T> where T : AbstractAddressValidationRequest
Type Parameters
T
- Inheritance
-
AbstractAddressValidationRequestValidator<T>
- Implements
-
IValidator<T>
- Inherited Members
Properties
ProviderName
Gets the display name of the address validation provider.
protected abstract string ProviderName { get; }
Property Value
SupportedCountries
Gets the countries supported by the address validation provider.
protected abstract FrozenSet<CountryCode> SupportedCountries { get; }
Property Value
Methods
PreValidateAsync(T, ISet<ValidationState>, CancellationToken)
Checks that instance specifies a non-null country code supported by
ProviderName. Validation is skipped if the country is missing or unsupported.
protected override ValueTask<bool> PreValidateAsync(T instance, ISet<ValidationState> results, CancellationToken cancellationToken = default)
Parameters
instanceTThe request instance to pre-validate.
resultsISet<ValidationState>The set of ValidationState objects for the current instance.
cancellationTokenCancellationTokenA cancellation token that can be used to cancel the work.
Returns
- ValueTask<bool>
true when the country is present and supported; otherwise false, and an error is added to
results.
ValidateAsync(T, ISet<ValidationState>, CancellationToken)
Validates the address fields of instance, checking that address lines, city/town,
state/province, and postal code are present and within the expected constraints for the given country.
protected override ValueTask ValidateAsync(T instance, ISet<ValidationState> results, CancellationToken cancellationToken = default)
Parameters
instanceTThe request instance to validate.
resultsISet<ValidationState>The set of ValidationState objects for the current instance.
cancellationTokenCancellationTokenA cancellation token that can be used to cancel the work.
Returns
- ValueTask
A task that represents the asynchronous validation operation.