Use FluentValidation in ASP.NET or ASP.NET Core
Getting started — How to use Fluent Validation in .NET and .NET Core?

TL;DR
FluentValidation is a popular .NET library for building strongly-typed validation rules. It is a small validation library that uses a fluent interface and lambda expressions for building validation rules.
Introduction to FluentValidation
Data Validation is essential for any Application. When it comes to Validating Models, developers usually use Data Annotations. There are few issues with Data Annotations approach: 1. Validation rules are tightly coupled with models. 2. Add complexity to Models/DTOs. 3. Difficult to make dynamic and conditional validations. 4. Difficult to extend and scale.
FluentValidation is a replacement for the existing validation attributes (Data Annotations). It can turn up the validation game to a new level, gives total control. It separates the validation rules and/or logic from the Model/DTO classes.
It is a open-source library that helps you make validations clean, easy to create, and maintain. It also works on external models that you don’t have access. It makes the model classes clean and readable .
Configure FluentValidation in ASP.NET Core
1. NuGet: To use FluentValidation, you need to install below NuGet packages.
PM> Install-Package FluentValidation.AspNetCore
PM> Install-Package FluentValidation.DependencyInjectionExtensions2. Configuration: Automatic registration of validators is possible. You can make use of the FluentValidation.DependencyInjectionExtensions package which can be used to automatically find all the validators in a specific assembly using an extension method.




