Immediate.Validations
0.10.0
See the version list below for details.
dotnet add package Immediate.Validations --version 0.10.0
NuGet\Install-Package Immediate.Validations -Version 0.10.0
<PackageReference Include="Immediate.Validations" Version="0.10.0" />
paket add Immediate.Validations --version 0.10.0
#r "nuget: Immediate.Validations, 0.10.0"
// Install Immediate.Validations as a Cake Addin #addin nuget:?package=Immediate.Validations&version=0.10.0 // Install Immediate.Validations as a Cake Tool #tool nuget:?package=Immediate.Validations&version=0.10.0
Immediate.Validations
Immediate.Validations is a source generator validating
Immediate.Handlers
handler parameters.
Installing Immediate.Validations
You can install Immediate.Validations with NuGet:
Install-Package Immediate.Validations
Or via the .NET Core command line interface:
dotnet add package Immediate.Validations
Either command, from Package Manager Console or .NET Core CLI, will download and install Immediate.Validations.
Using Immediate.Validations
Add Immediate.Validations to the Immediate.Handlers behaviors pipeline by including it in the list of default Behaviors for the assembly:
using Immediate.Validations.Shared;
[assembly: Behaviors(
typeof(ValidationBehavior<,>)
)]
Creating Validation Classes
Indicate that a class should be validated by adding the [Validate]
attribute and IValidationTarget<>
interface:
[Validate]
public record Query : IValidationTarget<Query>;
When Nullable Reference Types is enabled, any non-nullable reference types are automatically checked for null
. Other
validations are available like so:
[Validate]
public record Query : IValidationTarget<Query>
{
[GreaterThan(0)]
public required int Id { get; init; }
}
Results
The result of doing the above is that when a parameter fails one or more validations, a ValidationException
is thrown,
which can be handled via ProblemDetails or any other infrastructure mechanism.
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. |
-
net8.0
- Immediate.Handlers (>= 1.4.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.