This library implements DHL Express /address-validate API for address validation.
If you like or are using this project please give it a star. Thanks!
Here's a complete README.md file tailored for the DHLExpressAddressValidationProvider class, ready for you to copy and paste:
This component provides DHL Express address validation support within the EasyKeys.Shipping infrastructure. It uses the DHL Express API (v2) to validate destination addresses and propose corrections where applicable.
The core implementation is provided by the DHLExpressAddressValidationProvider class. It implements both:
IDHLExpressAddressValidationProvider– DHL-specific abstractionIAddressValidationProvider– shared interface used across providers
The validation relies on DHL’s /address-validate API endpoint and includes logging, error handling, and stopwatch-based performance diagnostics.
- ✅ Integration with DHL Express Address Validation API
- ✅ City + postal code resolution
- ✅ Graceful error handling and logging
- ✅ Stopwatch-based performance logging
- ✅ Implements generic
IAddressValidationProviderfor abstraction
services.AddDHLExpressAddressValidationProvider();var validated = await addressValidator.ValidateAddressAsync(new ValidateAddress
{
OriginalAddress = new Address(
streetLine: "123 Main St",
streetLine2: "",
city: "Los Angeles",
stateOrProvince: "CA",
postalCode: "90001",
countryCode: "US")
});After execution, validated.ProposedAddress may contain corrections such as a standardized postal code.
No configuration is required beyond DHL API client setup.
Ensure DHLExpressApi is registered and configured properly, including ClientId, ClientSecret, and BaseUrl.
- Error Logging: All API exceptions are logged with details and added to
request.InternalErrors. - Performance Tracking: Uses
ValueStopwatchto log execution duration in milliseconds. - Minimal Abstraction: Only required behavior is implemented. Further abstraction will be introduced as needed.
- If the API returns warnings or no address info, the original address is retained.
- If a valid address is found, the
ProposedAddressis populated using the DHL response.
- 📚 DHL Express Address-Validate API
- 🧩
EasyKeys.Shipping.Abstractions– shared address and validation models - 📦
DHLExpressApi– core client for OpenAPI-generated Express operations