![]() |
VOOZH | about |
dotnet add package ZeroAlloc.Validation.Options --version 1.5.3
NuGet\Install-Package ZeroAlloc.Validation.Options -Version 1.5.3
<PackageReference Include="ZeroAlloc.Validation.Options" Version="1.5.3" />
<PackageVersion Include="ZeroAlloc.Validation.Options" Version="1.5.3" />Directory.Packages.props
<PackageReference Include="ZeroAlloc.Validation.Options" />Project file
paket add ZeroAlloc.Validation.Options --version 1.5.3
#r "nuget: ZeroAlloc.Validation.Options, 1.5.3"
#:package ZeroAlloc.Validation.Options@1.5.3
#addin nuget:?package=ZeroAlloc.Validation.Options&version=1.5.3Install as a Cake Addin
#tool nuget:?package=ZeroAlloc.Validation.Options&version=1.5.3Install as a Cake Tool
👁 NuGet
👁 Build
👁 AOT
👁 GitHub Sponsors
Source-generated, attribute-based validation for .NET that allocates nothing on the valid path. The source generator emits a strongly-typed validator class at build time — no reflection at runtime. When all rules pass, the entire validation cycle produces zero heap allocations.
dotnet add package ZeroAlloc.Validation
using ZeroAlloc.Validation;
[Validate]
public class CreateOrderRequest
{
[NotEmpty][MaxLength(50)] public string Reference { get; set; } = "";
[GreaterThan(0)] public decimal Amount { get; set; }
[NotEmpty][EmailAddress] public string Email { get; set; } = "";
}
// The source generator emits CreateOrderRequestValidator at build time
var request = new CreateOrderRequest
{
Reference = "ORD-2026-001",
Amount = 99.99m,
Email = "customer@example.com"
};
var validator = new CreateOrderRequestValidator();
var result = validator.Validate(request);
if (!result.IsValid)
foreach (ref readonly var f in result.Failures)
Console.WriteLine($"{f.PropertyName}: {f.ErrorMessage}");
| Scenario | ZeroAlloc.Validation | FluentValidation | Speedup | Allocation (valid) |
|---|---|---|---|---|
| Flat model | 6.7 ns | 327 ns | ~49× | 0 B |
| Nested model | 10.1 ns | 619 ns | ~61× | 0 B |
| Collection (3×) | 14.3 ns | 2,043 ns | ~143× | 0 B |
See Performance for full benchmark results.
| Package | Purpose |
|---|---|
ZeroAlloc.Validation |
Core library — attributes, source generator, ValidationResult |
ZeroAlloc.Validation.AspNetCore |
Auto-validates request models; returns HTTP 422 on failure |
ZeroAlloc.Validation.Inject |
Emits AddZeroAllocValidators() — bulk DI registration in one call |
ZeroAlloc.Validation.Options |
Emits ValidateWithZeroAlloc() — plugs validators into Microsoft.Extensions.Options |
ZeroAlloc.Validation.Testing |
Fluent assertions for unit-testing validators |
AddZeroAllocValidators())Microsoft.Extensions.Options integration (ValidateWithZeroAlloc())Error, Warning, Info)When / Unless / [SkipWhen])[StopOnFirstFailure][Must] predicates or [CustomValidation] methodsZeroAlloc.Validation.Testing| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 net8.0 is compatible. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 is compatible. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 is compatible. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
This package is not used by any NuGet packages.
This package is not used by any popular GitHub repositories.