Add validation to a MediatR behavior pipeline?

后端 未结 2 888
误落风尘
误落风尘 2021-02-02 10:28

I\'m using ASP.NET Core, the built-in container, and MediatR 3 which supports \"behavior\" pipelines:

public class MyRequest : IRequest
{
    // ..         


        
2条回答
  •  灰色年华
    2021-02-02 11:17

    I've packed .net core integration into nuget, feel free to use it: https://www.nuget.org/packages/MediatR.Extensions.FluentValidation.AspNetCore

    Just insert in configuration section:

    services.AddFluentValidation(new[] {typeof(GenerateInvoiceHandler).GetTypeInfo().Assembly});
    

    GitHub

提交回复
热议问题