Validonce.AspNetCore
0.2.0
See the version list below for details.
dotnet add package Validonce.AspNetCore --version 0.2.0
NuGet\Install-Package Validonce.AspNetCore -Version 0.2.0
<PackageReference Include="Validonce.AspNetCore" Version="0.2.0" />
<PackageVersion Include="Validonce.AspNetCore" Version="0.2.0" />
<PackageReference Include="Validonce.AspNetCore" />
paket add Validonce.AspNetCore --version 0.2.0
#r "nuget: Validonce.AspNetCore, 0.2.0"
#:package Validonce.AspNetCore@0.2.0
#addin nuget:?package=Validonce.AspNetCore&version=0.2.0
#tool nuget:?package=Validonce.AspNetCore&version=0.2.0
Validonce.AspNetCore
Cross-field validation for ASP.NET Core, written once in FluentValidation. Requests that break a rule get an
RFC 7807 response with status 422. The same rules are published in your OpenAPI document as x-validonce, so
clients can evaluate them too.
Install
dotnet add package Validonce.AspNetCore
It brings Validonce.FluentValidation and Validonce, and needs the ASP.NET Core shared framework (net10.0).
Example
using Validonce;
using Validonce.AspNetCore;
using Validonce.FluentValidation;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddValidonce(); // singleton IValidator<T> for every ValidonceValidator<T>
builder.Services.AddOpenApi(o => o.AddValidonceSchemaTransformer()); // adds x-validonce to schemas
var app = builder.Build();
app.MapOpenApi();
app.MapPost("/signups", (Signup s) => Results.Ok()).WithValidonce(); // endpoint filter
app.Run();
public sealed record Signup(string? Plan, string? Company, DateOnly? Start, DateOnly? End);
public sealed class SignupValidator : ValidonceValidator<Signup>
{
public SignupValidator()
{
RequiredWhen(x => x.Company, If.Eq(x => x.Plan, "pro")).WithMessageKey("rules.company_required");
Compare(x => x.End, CompareOp.Ge, x => x.Start).WithMessageKey("rules.end_after_start");
}
}
Controllers (MVC)
builder.Services.AddValidonce();
builder.Services.AddControllers();
builder.Services.AddValidonceMvc(); // validates action arguments, same response
The 422 body
{
"title": "One or more validation errors occurred.",
"status": 422,
"errors": { "Company": ["rules.company_required"] },
"validonce": [
{ "path": ["company"], "ruleId": "Signup.required_when.company",
"key": "rules.company_required", "params": {} }
]
}
validonce is the same issue list the client evaluators produce. Set options.ValidationStatusCode in
AddValidonce(o => o.ValidationStatusCode = 400) to change the status.
The rule format is described at https://github.com/metatoy/validonce/blob/main/docs/rule-format-v1.md. Source and issues: https://github.com/metatoy/validonce.
Copyright 2026 Metatoy LLC. Licensed under the Apache License, Version 2.0.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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
- Microsoft.AspNetCore.OpenApi (>= 10.0.15)
- Validonce.FluentValidation (>= 0.2.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.