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…