Vali-Validation.AspNetCore 1.0.3

dotnet add package Vali-Validation.AspNetCore --version 1.0.3
                    
NuGet\Install-Package Vali-Validation.AspNetCore -Version 1.0.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="Vali-Validation.AspNetCore" Version="1.0.3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Vali-Validation.AspNetCore" Version="1.0.3" />
                    
Directory.Packages.props
<PackageReference Include="Vali-Validation.AspNetCore" />
                    
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 Vali-Validation.AspNetCore --version 1.0.3
                    
#r "nuget: Vali-Validation.AspNetCore, 1.0.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 Vali-Validation.AspNetCore@1.0.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=Vali-Validation.AspNetCore&version=1.0.3
                    
Install as a Cake Addin
#tool nuget:?package=Vali-Validation.AspNetCore&version=1.0.3
                    
Install as a Cake Tool

Vali-Validation.AspNetCore

ASP.NET Core integration for Vali-Validation. Provides middleware, endpoint filters, and action filter attributes for automatic HTTP request validation.

Installation

dotnet add package Vali-Validation.AspNetCore

Features

  • ValiValidationMiddleware — catches ValidationException and returns an RFC 7807 problem+json HTTP 400 response.
  • ValiValidationFilter<T> — Minimal API IEndpointFilter that validates a request DTO before the endpoint executes.
  • ValiValidateAttribute — MVC IAsyncActionFilter attribute for automatic controller action validation.

ValiValidationMiddleware

Catches any ValidationException thrown anywhere in the pipeline and returns a structured 400 response.

// Program.cs
app.UseValiValidationExceptionHandler(); // place before routing/controllers

Optional DI helper for ProblemDetails:

builder.Services.AddValiValidationProblemDetails();

ValiValidationFilter<T> — Minimal API

Validates a bound argument of type T before the endpoint executes. If no IValidator<T> is registered, the filter is a no-op.

// Using the fluent extension (recommended)
app.MapPost("/users", (CreateUserDto dto) => Results.Ok())
   .WithValiValidation<CreateUserDto>();

// Or explicitly
app.MapPost("/users", (CreateUserDto dto) => Results.Ok())
   .AddEndpointFilter<ValiValidationFilter<CreateUserDto>>();

Validators must be registered in DI:

builder.Services.AddScoped<IValidator<CreateUserDto>, CreateUserDtoValidator>();
// or using the bulk-registration helper from Vali-Validation:
builder.Services.AddValidationsFromAssembly(typeof(CreateUserDtoValidator).Assembly);

ValiValidateAttribute — MVC Controllers

Apply to a controller or a single action to validate all incoming arguments automatically.

[ApiController]
[ValiValidate]
public class UsersController : ControllerBase
{
    [HttpPost]
    public IActionResult Create(CreateUserDto dto) => Ok();
}

Or per action:

[HttpPost]
[ValiValidate]
public IActionResult Create(CreateUserDto dto) => Ok();

Validation Error Response Format (RFC 7807)

When validation fails, the response is HTTP 400 with Content-Type: application/problem+json:

{
  "type": "https://tools.ietf.org/html/rfc7807",
  "title": "One or more validation errors occurred.",
  "status": 400,
  "errors": {
    "Name": ["'Name' must not be empty."],
    "Email": ["'Email' is not a valid email address."],
    "Age": ["'Age' must be greater than 0."]
  }
}

Donations

If Vali-Validation is useful to you, consider supporting its development:


License

Apache License 2.0

Contributions

Issues and pull requests are welcome on GitHub.

Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  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 is compatible.  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 was computed.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.3 99 4/14/2026
1.0.2 97 4/13/2026
1.0.1 103 3/18/2026
1.0.0 105 3/16/2026

v1.0.0 — Initial release.
     - ValiValidationMiddleware catches ValidationException, returns RFC 7807 problem+json.
     - ValiValidationFilter<T> (IEndpointFilter) for Minimal API endpoint validation.
     - ValiValidateAttribute (IAsyncActionFilter) for MVC controller action validation.
     - UseValiValidationExceptionHandler() middleware registration.
     - WithValiValidation<T>() fluent extension for Minimal API routes.
     - AddValiValidationProblemDetails() DI helper.