RzR.Validation.Attributes.AspNetCore 3.0.0.6710

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

RzR.Validation.Attributes.AspNetCore

ASP.NET Core integration for RzR.Validation.Attributes. It runs the DataAnnotations validation attributes automatically during request handling and turns failures into RFC 7807 problem responses.

Minimal APIs don't run DataAnnotations on bound parameters by themselves, and in MVC you end up writing the same ModelState-to-response glue in every action. This package covers both.

Install

dotnet add package RzR.Validation.Attributes.AspNetCore

It pulls in the core RzR.Validation.Attributes package. Targets net8.0 and references the ASP.NET Core shared framework.

Register

In Program.cs:

using RzR.Validation.Attributes.AspNetCore;

builder.Services.AddRzRValidation();

Everything is configurable through RzRValidationOptions:

using RzR.Validation.Attributes.AspNetCore;
using RzR.Validation.Attributes.AspNetCore.Options;

builder.Services.AddRzRValidation(options =>
{
    options.InvalidStatusCode = StatusCodes.Status422UnprocessableEntity; // default: 400
    options.ProblemTitle = "Validation failed";
    options.ProblemTypeUri = "https://example.com/errors/validation";
    options.MemberNameTransformer = name => char.ToLowerInvariant(name[0]) + name.Substring(1);
});

Minimal API

Decorate the model with the core attributes, then attach the filter to the endpoint:

using RzR.Validation.Attributes.Attributes.Require;
using RzR.Validation.Attributes.Attributes.Identity;
using RzR.Validation.Attributes.Attributes.Greater;
using RzR.Validation.Attributes.AspNetCore.Minimal;

public class CreateAccount
{
    [ValRequiredNotEmpty]
	
	public string Username { get; set; }
    [ValEmail]            
	public string Email { get; set; }
    
	[ValGreaterThan(0)]
	public decimal Balance { get; set; }
}

app.MapPost("/accounts", (CreateAccount account) => Results.Ok())
   .WithValidation<CreateAccount>();

Apply it to a whole route group instead of one endpoint:

var api = app.MapGroup("/api").WithValidation<CreateAccount>();

When the bound CreateAccount fails validation, the filter short-circuits before your handler runs and returns a problem response. A valid request passes straight through. The filter validates the first bound argument of type T.

MVC

MVC model binding already runs DataAnnotations and populates ModelState; here the filter's job is to standardize the failure response. Put [ValidateModel] on a controller or action:

using RzR.Validation.Attributes.AspNetCore.Mvc;

[ApiController]
[Route("accounts")]
public class AccountsController : ControllerBase
{
    [HttpPost]
    [ValidateModel]
    public IActionResult Create(CreateAccount account) => Ok();
}

Or register it for every action:

using RzR.Validation.Attributes.AspNetCore.Mvc;

builder.Services.AddControllers(options => options.Filters.Add<RzRValidateModelFilter>());

Response shape

Failures come back as application/problem+json (RFC 7807), keyed by member name:

{
  "type": "https://tools.ietf.org/html/rfc7231#section-6.5.1",
  "title": "One or more validation errors occurred.",
  "status": 400,
  "errors": {
    "Email": ["The Email field must be a valid email address."],
    "Balance": ["The Balance field must be greater than 0."]
  }
}

Set the status with InvalidStatusCode, and reshape the keys (for example to camelCase) with MemberNameTransformer.

Notes

  • Your models carry the rules — the core RzR.Validation.Attributes Val* attributes. This package triggers them; it doesn't define validation itself.
  • On .NET 10+, the platform can run DataAnnotations on Minimal API parameters natively via AddValidation() / [ValidatableType]. Use whichever suits the project, but don't enable both on the same endpoint or you'll get duplicate errors.
Product 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 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
3.0.0.6710 107 7/18/2026