VOOZH about

URL: https://www.nuget.org/packages/ZeroAlloc.Validation/

⇱ NuGet Gallery | ZeroAlloc.Validation 1.5.3




👁 Image
ZeroAlloc.Validation 1.5.3

dotnet add package ZeroAlloc.Validation --version 1.5.3
 
 
NuGet\Install-Package ZeroAlloc.Validation -Version 1.5.3
 
 
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ZeroAlloc.Validation" Version="1.5.3" />
 
 
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ZeroAlloc.Validation" Version="1.5.3" />
 
Directory.Packages.props
<PackageReference Include="ZeroAlloc.Validation" />
 
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add ZeroAlloc.Validation --version 1.5.3
 
 
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: ZeroAlloc.Validation, 1.5.3"
 
 
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package ZeroAlloc.Validation@1.5.3
 
 
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=ZeroAlloc.Validation&version=1.5.3
 
Install as a Cake Addin
#tool nuget:?package=ZeroAlloc.Validation&version=1.5.3
 
Install as a Cake Tool
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

ZeroAlloc.Validation

👁 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.

Install

dotnet add package ZeroAlloc.Validation

30-Second Example

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}");

Performance

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.

Packages

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

Features

  • Zero heap allocation on the valid path
  • 25+ built-in validation attributes
  • Nested object and collection validation
  • ASP.NET Core auto-validation (HTTP 422 on failure)
  • Zero-friction DI registration (AddZeroAllocValidators())
  • Source-generated Microsoft.Extensions.Options integration (ValidateWithZeroAlloc())
  • Per-rule severity (Error, Warning, Info)
  • Conditional rules (When / Unless / [SkipWhen])
  • Short-circuit with [StopOnFirstFailure]
  • Custom rules via [Must] predicates or [CustomValidation] methods
  • Testing helpers via ZeroAlloc.Validation.Testing

Documentation

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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (5)

Showing the top 5 NuGet packages that depend on ZeroAlloc.Validation:

Package Downloads
ZeroAlloc.Mediator.Validation

Pipeline behavior that validates IRequest<T> via ZeroAlloc.Validation before dispatch. Validation failures surface as Result<T, ValidationError> — no exceptions on the hot path.

AI.Sentinel

Security monitoring middleware for IChatClient — prompt injection, hallucination, and operational anomaly detection with an intervention engine.

ZeroAlloc.Validation.AspNetCore

ASP.NET Core integration for ZeroAlloc.Validation. Source-generated action filter validates request models at compile time with zero runtime overhead.

ZeroAlloc.Validation.Testing

Testing helpers for ZeroAlloc.Validation. Provides assertion utilities to verify validation results in unit tests.

ZeroAlloc.Validation.Options

Source-generated options validation for ZeroAlloc.Validation. Plugs compile-time validators into Microsoft.Extensions.Options with zero reflection.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.5.3 1,623 5/28/2026
1.5.2 153 5/28/2026
1.5.1 230 5/27/2026
1.5.0 168 5/27/2026
1.4.1 296 5/27/2026
1.4.0 178 5/27/2026
1.3.0 582 5/13/2026
1.2.0 173 5/13/2026
1.1.2 160 5/13/2026
1.1.1 159 5/12/2026
1.1.0 174 5/1/2026
1.0.1 141 4/29/2026
1.0.0 157 4/28/2026
0.2.4 2,537 4/20/2026
0.2.3 2,461 3/22/2026
0.2.2 144 3/20/2026
0.2.1 145 3/18/2026
0.2.0 141 3/18/2026
0.1.2 143 3/17/2026
0.1.1 135 3/17/2026