RKSoftware.Packages.ApiRequestValidation 8.0.1-alpha

This is a prerelease version of RKSoftware.Packages.ApiRequestValidation.
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package RKSoftware.Packages.ApiRequestValidation --version 8.0.1-alpha                
NuGet\Install-Package RKSoftware.Packages.ApiRequestValidation -Version 8.0.1-alpha                
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="RKSoftware.Packages.ApiRequestValidation" Version="8.0.1-alpha" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add RKSoftware.Packages.ApiRequestValidation --version 8.0.1-alpha                
#r "nuget: RKSoftware.Packages.ApiRequestValidation, 8.0.1-alpha"                
#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.
// Install RKSoftware.Packages.ApiRequestValidation as a Cake Addin
#addin nuget:?package=RKSoftware.Packages.ApiRequestValidation&version=8.0.1-alpha&prerelease

// Install RKSoftware.Packages.ApiRequestValidation as a Cake Tool
#tool nuget:?package=RKSoftware.Packages.ApiRequestValidation&version=8.0.1-alpha&prerelease                

Automatic validation for API request parameters (.NET)

Repository contains functionality for validation API requests.

Package Current version and Downloads
RKSoftware.Packages.ApiRequestValidation NuGet Badge

About

This package contains ActionExecutingContext extensions for validation URL parameters together with Body, Form and Query model validation.

  • If an id in URL posts/{id}/pages is empty, an endpoint returns Not Found response.
  • If a model next to [FromBody], [FromForm] or [FromQuery] is not valid, an endpoint returns Bad Request response with ValidationProblemDetails model. It uses FluentValidation (https://github.com/FluentValidation/FluentValidation) for validating models.

How To Use


builder.Services.AddScoped<IValidator<BodyModel>, BodyModelValidator>();

or register all created validators from the same assembly

builder.Services.AddValidatorsFromAssemblyContaining<BodyModelValidator>();
  • The package contains ApiRequestValidation attribute, which can be set on a controller or its method.
[ApiRequestValidation]
public class MyController : Controller
{
}

or


public class MyController : Controller
{

    [ApiRequestValidation]
	[HttpPost("posts/{id}/pages")]   
    public async Task<IActionResult> Create(string id, [FromBody] BodyModel body, [FromQuery] QueryModel query)
    {
        ...
    }

}
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. 
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
8.0.1-preview.1 1,093 4/24/2024
8.0.1-beta.1 58 4/24/2024
8.0.1-beta 158 4/24/2024
8.0.1-alpha 576 2/10/2024
1.0.3 2,451 11/30/2022
1.0.2 311 11/30/2022
1.0.1 338 11/30/2022
1.0.0 312 11/30/2022