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.
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.
// Install WebApiSkeleton.Contracts.Validation as a Cake Addin #addin nuget:?package=WebApiSkeleton.Contracts.Validation&version=1.1.1 // Install WebApiSkeleton.Contracts.Validation as a Cake Tool #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
(orAddValidatorsFromAssembly
fromFluentValidation
) to add validators to DI - Add validation behaviors for requests in DI
- One way is to call
AddValidationPipelineBehaviorsFromAssembly
that will automatically search for classes that are inherited fromAbstractValidator
and addValidationBehavior
for requests that are passed as a generic parameter in DI. If any of these requests are not returning theResult<A>
type theInvalidOperationException
is thrown.- NOTE: in this case
ValidationBehavior
for request is automatically added, so it is highly recommended to mind the order ofIPipelineBehavior
implementations added in DI.
- NOTE: in this case
- Another way is to create
ValidationBehavior
implementations by callingValidationBehaviorCreator.GetValidationPipelineBehaviorForRequest
method and then add it manually to DI by passing thepipelineBehavior
as a service type andvalidationBehavior
as 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. |
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.