Skip to content

Installation ​

Install AlmightyShogun.AspNet.RequestValidation in the ASP.NET Core application that validates incoming requests. The package targets net10.0.

sh
dotnet add package AlmightyShogun.AspNet.RequestValidation

Dependencies ​

Framework references ​

  • Microsoft.AspNetCore.App — the ASP.NET Core shared framework.

Project references ​

  • AlmightyShogun.AspNet.Core — provides the shared error response shape.
  • AlmightyShogun.AspNet.Localization — provides message resolution.

Startup Registration ​

AddAspNetValidation registers the rule cache, filters, and exception handler. UseAspNetValidation adds the middleware, and has overloads for minimal API endpoints and route groups.

WARNING

AddMessageLocalization and AddHttpErrorResponseWriter must also be called. Without them, validation messages resolve to their raw keys such as validation.required.

csharp
using AlmightyShogun.AspNet.Core;
using AlmightyShogun.AspNet.Localization;
using AlmightyShogun.AspNet.RequestValidation;

builder.Services
    .AddMessageLocalization(builder.Configuration)
    .AddHttpErrorResponseWriter()
    .AddExceptionHandling()
    .AddAspNetValidation();

WebApplication app = builder.Build();

app.UseHttpErrorResponses();
app.UseAspNetValidation();

All packages are released under the MIT License.