MediatR.Extensions.FluentValidation.AspNetCore 1.2.0

Install-Package MediatR.Extensions.FluentValidation.AspNetCore -Version 1.2.0
dotnet add package MediatR.Extensions.FluentValidation.AspNetCore --version 1.2.0
<PackageReference Include="MediatR.Extensions.FluentValidation.AspNetCore" Version="1.2.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add MediatR.Extensions.FluentValidation.AspNetCore --version 1.2.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: MediatR.Extensions.FluentValidation.AspNetCore, 1.2.0"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install MediatR.Extensions.FluentValidation.AspNetCore as a Cake Addin
#addin nuget:?package=MediatR.Extensions.FluentValidation.AspNetCore&version=1.2.0

// Install MediatR.Extensions.FluentValidation.AspNetCore as a Cake Tool
#tool nuget:?package=MediatR.Extensions.FluentValidation.AspNetCore&version=1.2.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.


GitHub Actions Status NuGet NuGet license

MediatR extension for FluentValidation using core


A priori you need to install packages Mediatr and FluentValidation then continue below

Install with nuget

Install-Package MediatR.Extensions.FluentValidation.AspNetCore

Install with .NET CLI

dotnet add package MediatR.Extensions.FluentValidation.AspNetCore

How to use

Setup - Add configuration in startup

public void ConfigureServices(IServiceCollection services)
    // Add framework services etc.
    var domainAssembly = typeof(GenerateInvoiceHandler).GetTypeInfo().Assembly;
    // Add MediatR

    //Add FluentValidation
    services.AddFluentValidation(new[] {domainAssembly});
    //Add other stuffs


Just to write down validators for IRequest implementation. Validation will be executed before handling IRequestHandler.

public class GenerateInvoiceValidator : AbstractValidator<GenerateInvoiceRequest>
    public GenerateInvoiceValidator()
        RuleFor(x => x.Month).LowerThan(13);
        // etc.

public class GenerateInvoiceRequest : IRequest
    public int Month { get; set; }
public class GenerateInvoiceRequestHandler : IRequestHandler<GenerateInvoiceRequest>
    public async Task<Unit> Handle(GenerateInvoiceRequest request, CancellationToken cancellationToken)
        // request data has been validated

More examples check FluentValidation docs:

NuGet packages (2)

Showing the top 2 NuGet packages that depend on MediatR.Extensions.FluentValidation.AspNetCore:

Package Downloads

Package Description


Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.2.0 71,297 5/13/2021
1.1.1 156,402 8/23/2020
1.1.0 6,465 8/5/2020
1.0.3 2,129 7/31/2020
1.0.2 12,766 6/18/2020
1.0.1 31,104 9/3/2019
1.0.0 3,835 9/3/2019