Add validation pipeline with FluentValidation and MediatR
Introduced a validation pipeline using FluentValidation and MediatR to enhance request validation. Added the following: - Registered FluentValidation and MediatR dependencies in `ReC.Application.csproj`. - Updated `DependencyInjection.cs` to register validators and MediatR behaviors, including `ValidationBehavior<,>`. - Added `ValidationBehavior<TRequest, TResponse>` to handle request validation in the MediatR pipeline. - Created `ReadOutResQueryValidator` to enforce validation rules for `ReadOutResQuery`. - Refactored namespaces and imports for better organization. These changes improve extensibility, maintainability, and separation of concerns in the application.
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
using FluentValidation;
|
||||
|
||||
namespace ReC.Application.OutResults.Queries;
|
||||
|
||||
public class ReadOutResQueryValidator : AbstractValidator<ReadOutResQuery>
|
||||
{
|
||||
public ReadOutResQueryValidator()
|
||||
{
|
||||
RuleFor(x => x)
|
||||
.Must(x => x.ActionId.HasValue || x.ProfileId.HasValue)
|
||||
.WithMessage("At least one of ActionId or ProfileId must be provided.");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user