Use FluentValidation in ASP.NET or ASP.NET Core

Ashish Patel
.NET Hub
Published in
3 min readJul 7, 2021

--

Getting started — How to use Fluent Validation in .NET and .NET Core?

FluentValidation in .NET

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.

Most popular .NET Libraries every developer should know.

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…

--

--

Ashish Patel
.NET Hub

Cloud Architect • 4x AWS Certified • 6x Azure Certified • 1x Kubernetes Certified • MCP • .NET • Terraform • DevOps • Blogger [https://bit.ly/iamashishpatel]