Introduction
This blog was written in order to work on an ASP.NET Core 3.1 API Project that does nothing other than just validation with Fluent Validation.
I will be using
Postman to test and receive the validation messages and
Visual Studio 2019 Community as my IDE (The best for C# development)
In order to build and test out our API, we’ll need the following installed:
Installation
Before creating any validators, you will need to add a reference to FluentValidation.dll in your project. It is available as either a netstandard2.0 library or as a net461 library for older projects.
The simplest way to do this is to use either the NuGet package manager or the dotnet CLI.
- Using the NuGet package manager console within Visual Studio run the following command:
Install-Package FluentValidation
- Or using the .NET Core CLI from a terminal window:
dotnet add package FluentValidation
For integration with ASP.NET Core:
- Install the FluentValidation.AspNetCore package from Visual Studio:
Install-Package FluentValidation.AspNetCore
- Or from the command line:
dotnet add package FluentValidation.AspNetCore