eQuantic.Validation.AspNetCore
2.2.0
dotnet add package eQuantic.Validation.AspNetCore --version 2.2.0
NuGet\Install-Package eQuantic.Validation.AspNetCore -Version 2.2.0
<PackageReference Include="eQuantic.Validation.AspNetCore" Version="2.2.0" />
<PackageVersion Include="eQuantic.Validation.AspNetCore" Version="2.2.0" />
<PackageReference Include="eQuantic.Validation.AspNetCore" />
paket add eQuantic.Validation.AspNetCore --version 2.2.0
#r "nuget: eQuantic.Validation.AspNetCore, 2.2.0"
#:package eQuantic.Validation.AspNetCore@2.2.0
#addin nuget:?package=eQuantic.Validation.AspNetCore&version=2.2.0
#tool nuget:?package=eQuantic.Validation.AspNetCore&version=2.2.0
eQuantic.Validation.AspNetCore
ASP.NET Core integration for eQuantic.Validation, supporting Minimal APIs and MVC in .NET 8 and .NET 10.
dotnet add package eQuantic.Validation.AspNetCore
Quick Start
- Register validators in your
Program.cs(AddValidatorregisters the validation dispatcher automatically; the names avoid colliding with .NET 10's built-inAddValidation):
builder.Services.AddValidator<CreateOrder, CreateOrderValidator>();
- For Minimal APIs, apply the endpoint filter. Rules run sequentially by default; parallel execution is opt-in and requires concurrency-safe rule dependencies:
app.MapPost("/orders", (CreateOrder command) => Results.Ok())
.RequireValidation("create");
app.MapPost("/quotes", handler)
.RequireValidation(ValidationExecutionMode.Parallel);
- For MVC Controllers, enable the global validation action filter:
builder.Services.AddControllers().AddValidationFilter();
- Enable OpenAPI 3.1 schema transformations and per-request localization (combine with
UseRequestLocalizationsoAccept-Languagedrives the culture):
builder.Services.AddValidationLocalization<ValidationResources>();
builder.Services.AddOpenApi(options =>
{
options.AddValidationTransformer();
});
Failed validation requests automatically return HTTP 400 with RFC 7807 / RFC 9457 ValidationProblemDetails. The errors dictionary maintains ASP.NET Core client compatibility, while extensions.issues provides structured code, path, and severity (emitted as JSON nodes, safe for source-generated serialization and Native AOT):
{
"title": "One or more validation errors occurred.",
"status": 400,
"errors": { "Email": ["Email must be a valid email address."] },
"issues": [
{ "path": "Email", "code": "customer.email.invalid", "message": "Email must be a valid email address.", "severity": "Error" }
]
}
Warnings on successful responses
Valid requests with Severity.Warning failures respond 200 with a Validation-Warnings
header (path:code pairs). The full failures are available to the handler:
app.MapPut("/profile", (UpdateProfile request, HttpContext http) =>
{
var warnings = ValidationWarnings.GetWarnings(http);
return Results.Ok(new { saved = true, warnings });
}).RequireValidation();
Async rule deduplication
The filters create one validation context per request with async-rule deduplication enabled:
the same MustAsync for the same instance and value (composed validators, duplicated collection
elements, revalidation) performs its I/O once per request. No configuration needed.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- eQuantic.Validation (>= 2.2.0)
- eQuantic.Validation.Abstractions (>= 2.2.0)
- Microsoft.AspNetCore.OpenApi (>= 10.0.11)
- Microsoft.OpenApi (>= 2.7.5)
-
net8.0
- eQuantic.Validation (>= 2.2.0)
- eQuantic.Validation.Abstractions (>= 2.2.0)
- Microsoft.AspNetCore.OpenApi (>= 8.0.11)
- Microsoft.OpenApi (>= 1.6.22)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Initial ASP.NET Core integration with scoped validators and RFC 7807-compatible responses.