Validator Behavior

Validator Behavior in MediatR pipeline within RCommon.

The validator behavior is useful anytime you want to de-couple request/DTO validation from your application logic. It can be added by doing this in your dependency injection section:

protected void InitializeRCommon(IServiceCollection services)
{

    ConfigureRCommon.Using(new DotNetCoreContainerAdapter(Services))
        .AddValidationToMediatorPipeline());
        
    // This will inject all fluent validators
    services.AddValidatorsFromAssemblyContaining<ClassInAssemblyThatHasValidators>();
}

Last updated