Soenneker.Validators.ZipCode.Exists
11.0.2690
Prefix Reserved
See the version list below for details.
dotnet add package Soenneker.Validators.ZipCode.Exists --version 11.0.2690
NuGet\Install-Package Soenneker.Validators.ZipCode.Exists -Version 11.0.2690
<PackageReference Include="Soenneker.Validators.ZipCode.Exists" Version="11.0.2690" />
<PackageVersion Include="Soenneker.Validators.ZipCode.Exists" Version="11.0.2690" />
<PackageReference Include="Soenneker.Validators.ZipCode.Exists" />
paket add Soenneker.Validators.ZipCode.Exists --version 11.0.2690
#r "nuget: Soenneker.Validators.ZipCode.Exists, 11.0.2690"
#:package Soenneker.Validators.ZipCode.Exists@11.0.2690
#addin nuget:?package=Soenneker.Validators.ZipCode.Exists&version=11.0.2690
#tool nuget:?package=Soenneker.Validators.ZipCode.Exists&version=11.0.2690
Soenneker.Validators.ZipCode.Exists
Validates US ZIP codes against the data snapshot packaged with the library.
Installation
dotnet add package Soenneker.Validators.ZipCode.Exists
Registration
Register the validator as a singleton when the application can share one in-memory ZIP-code set:
using Microsoft.Extensions.DependencyInjection;
using Soenneker.Validators.ZipCode.Exists.Registrars;
services.AddZipCodeExistsValidatorAsSingleton();
A scoped registration is also available:
services.AddZipCodeExistsValidatorAsScoped();
Each scoped instance loads and owns its own cached set. Prefer the singleton registration unless scopes need independent validator instances.
Usage
using Soenneker.Validators.ZipCode.Exists.Abstract;
public sealed class AddressService
{
private readonly IZipCodeExistsValidator _zipCodeValidator;
public AddressService(IZipCodeExistsValidator zipCodeValidator)
{
_zipCodeValidator = zipCodeValidator;
}
public ValueTask<bool> IsKnownZipCode(string zipCode, CancellationToken cancellationToken = default)
{
return _zipCodeValidator.Validate(zipCode, cancellationToken);
}
}
await validator.Validate("00611"); // true when present in the packaged data
await validator.Validate("00611-5353"); // checks "00611"
await validator.Validate("12345"); // false when absent from the packaged data
Behavior
- Null, empty, and whitespace-only values return
false. - Values longer than five characters are truncated to their first five characters. This permits ZIP+4 input, but the suffix is not validated.
- Values of five characters or fewer are matched exactly against the packaged data.
- The data is loaded lazily on the first validation call and cached for the validator's lifetime.
- A
trueresult means the five-digit value appears in the package's data snapshot. It does not verify that an address exists or that mail can currently be delivered there. - Dispose the validator only when you own it directly. Instances resolved from dependency injection are disposed by the container.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net11.0 is compatible. |
-
net11.0
- Soenneker.Data.ZipCode (>= 4.0.1130)
- Soenneker.Extensions.ValueTask (>= 4.0.133)
- Soenneker.Utils.File (>= 4.0.2320)
- Soenneker.Utils.Paths.Resources (>= 4.0.297)
- Soenneker.Validators.Validator (>= 4.0.753)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 11.0.2703 | 0 | 10/27/2026 |
| 11.0.2702 | 45 | 10/27/2026 |
| 11.0.2701 | 43 | 10/27/2026 |
| 11.0.2700 | 49 | 10/26/2026 |
| 11.0.2696 | 55 | 10/26/2026 |
| 11.0.2695 | 58 | 10/26/2026 |
| 11.0.2693 | 58 | 10/26/2026 |
| 11.0.2691 | 51 | 10/26/2026 |
| 11.0.2690 | 57 | 10/26/2026 |
| 4.0.2689 | 69 | 10/25/2026 |
| 4.0.2688 | 133 | 10/20/2026 |
| 4.0.2687 | 146 | 10/15/2026 |
| 4.0.2686 | 84 | 10/15/2026 |
| 4.0.2685 | 89 | 10/15/2026 |
| 4.0.2684 | 89 | 10/14/2026 |
| 4.0.2683 | 87 | 10/14/2026 |
| 4.0.2681 | 93 | 10/14/2026 |
| 4.0.2680 | 84 | 10/14/2026 |
| 4.0.2677 | 89 | 10/14/2026 |
| 4.0.2668 | 84 | 10/13/2026 |
Merge remote-tracking branch 'origin/main'
# Conflicts:
# test/Soenneker.Validators.ZipCode.Exists.Tests/Soenneker.Validators.ZipCode.Exists.Tests.csproj