I’m trying to create a new Blazor App in .NET 8, using Mediatr, and I created a custom behavior pipeline for MediatR to handle some validations, using FluentValidation. However it seems to be getting ignored and it is not called.
public class ValidatorBehavior<TRequest, TResponse>(ILogger<ValidatorBehavior<TRequest, TResponse>> logger,
IEnumerable<IValidator<TRequest>> validators)
: IPipelineBehavior<TRequest, TResponse>
where TRequest : IRequest<TResponse>
{
//implementation here
}
And this is how i registered it
private static void RegisterMediatorBehavior(this MediatRServiceConfiguration configuration)
{
ArgumentNullException.ThrowIfNull(configuration);
configuration.AddOpenBehavior(typeof(ValidatorBehavior<,>));
}
services.AddMediatR(cfg =>
{
cfg.RegisterServicesFromAssemblies(AppDomain.CurrentDomain.GetAssemblies());
cfg.RegisterMediatorBehavior();
});
Before that I tried to register it as a transient service, still no luck.
Any ideas?