MinApiLib.Validation
11.0.0
dotnet add package MinApiLib.Validation --version 11.0.0
NuGet\Install-Package MinApiLib.Validation -Version 11.0.0
<PackageReference Include="MinApiLib.Validation" Version="11.0.0" />
<PackageVersion Include="MinApiLib.Validation" Version="11.0.0" />
<PackageReference Include="MinApiLib.Validation" />
paket add MinApiLib.Validation --version 11.0.0
#r "nuget: MinApiLib.Validation, 11.0.0"
#:package MinApiLib.Validation@11.0.0
#addin nuget:?package=MinApiLib.Validation&version=11.0.0
#tool nuget:?package=MinApiLib.Validation&version=11.0.0
MinApiLib.Validation
Deprecated. Use MinApiLib.FluentValidation instead. This package no longer receives fixes, and its types are marked
[Obsolete].
Known problems
The filter validates data annotations only on a request member named Body. It skips validation without any error if the member has another name, or if the body is received directly as a handler parameter. It doesn't check query, route or header values.
Migrating
Replace the package:
dotnet remove package MinApiLib.Validation
dotnet add package MinApiLib.FluentValidation
Update the usings, and register the validators:
// global using MinApiLib.Validation;
global using FluentValidation;
global using MinApiLib.FluentValidation;
// ...
builder.Services.AddValidatorsFromAssembly();
Move each annotation to a validator for the request. WithValidation() stays the same in the endpoint.
// Before
public record struct Request([FromBody] RequestBody Body);
public class RequestBody
{
[Required, StringLength(150, MinimumLength = 3)]
public string Name { get; set; }
}
// After
public record struct Request([FromBody] RequestBody Body);
public class RequestBody
{
public string Name { get; set; }
}
public class RequestValidator : AbstractValidator<Request>
{
public RequestValidator()
{
RuleFor(x => x.Body.Name).NotEmpty().Length(3, 150);
}
}
The 400 response keeps the same shape, with the errors per property, but the keys include the path of the property, such as Body.Name. An endpoint that calls WithValidation() needs a validator: without one, its requests aren't validated, and a warning is logged.
| Product | Versions 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 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 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. net11.0 is compatible. |
-
net10.0
- MiniValidation (>= 0.10.0)
-
net11.0
- MiniValidation (>= 0.10.0)
-
net8.0
- MiniValidation (>= 0.10.0)
-
net9.0
- MiniValidation (>= 0.10.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.