WebApiSkeleton.Contracts.Validation
1.1.1
dotnet add package WebApiSkeleton.Contracts.Validation --version 1.1.1
NuGet\Install-Package WebApiSkeleton.Contracts.Validation -Version 1.1.1
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="WebApiSkeleton.Contracts.Validation" Version="1.1.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="WebApiSkeleton.Contracts.Validation" Version="1.1.1" />
<PackageReference Include="WebApiSkeleton.Contracts.Validation" />
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 WebApiSkeleton.Contracts.Validation --version 1.1.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: WebApiSkeleton.Contracts.Validation, 1.1.1"
#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 WebApiSkeleton.Contracts.Validation@1.1.1
#: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=WebApiSkeleton.Contracts.Validation&version=1.1.1
#tool nuget:?package=WebApiSkeleton.Contracts.Validation&version=1.1.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
WebApiSkeleton.Contracts.Validation
WebApiSkeleton.Contracts.Validation contains MediatR PipelineBehavior
implementation to validate incoming requests that
implement IValidatableRequest
using FluentValidation
Usage
Steps to add contract validation:
- Create validators that are inherited from
AbstractValidator<T>for needed requests - Use
AddContractValidatorsFromAssembly(orAddValidatorsFromAssemblyfromFluentValidation) to add validators to DI - Add validation behaviors for requests in DI
- One way is to call
AddValidationPipelineBehaviorsFromAssemblythat will automatically search for classes that are inherited fromAbstractValidatorand addValidationBehaviorfor requests that are passed as a generic parameter in DI. If any of these requests are not returning theResult<A>type theInvalidOperationExceptionis thrown.- NOTE: in this case
ValidationBehaviorfor request is automatically added, so it is highly recommended to mind the order ofIPipelineBehaviorimplementations added in DI.
- NOTE: in this case
- Another way is to create
ValidationBehaviorimplementations by callingValidationBehaviorCreator.GetValidationPipelineBehaviorForRequestmethod and then add it manually to DI by passing thepipelineBehavioras a service type andvalidationBehavioras implementation type. This way order of pipeline behaviors executed for each request is handled more clearly by the user, which is adding them.
- One way is to call
Example
Example usage shown in Example project
| 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 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.
-
net8.0
- FluentValidation (>= 11.9.0)
- FluentValidation.DependencyInjectionExtensions (>= 11.9.0)
- WebApiSkeleton.Contracts.Base (>= 1.1.1)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on WebApiSkeleton.Contracts.Validation:
| Package | Downloads |
|---|---|
|
WebApiSkeleton.FileSystem.MinIO
Package containing implementation of file system based on Minio S3 storage. |
|
|
WebApiSkeleton.Security
Package containing security core implementation that is based on MediatR and other WebApiSkeleton MediatR-related packages. |
GitHub repositories
This package is not used by any popular GitHub repositories.