How to Use FluentValidation in ASP.NET Core

added by DotNetKicks
8/24/2020 4:20:40 PM

384 Views

Traditionally, most validation in .NET is done using Data Annotations: public class SampleClass { [Required] public int Id { get; set; } [MaxLength(100)] public string Name { get; set; } } There are a few issues with this approach: Our model can get "bloated" Extensibility is limited Testing isn't the nicest experience To address some of these concerns, instead, we're going to utilize a .NET library called FluentValidation to perform validation for our classes.


0 comments