Validation in ASP.NET Core
We can use the default method of adding
DataAnnotations attributes (like
[Required]), build custom
DataAnnotations or use FluentValidation package.
For ASP.NET Core we need to install FluentValidation.AspNetCore.
It’s a 3rd part validation library that is an alternative for the default
DataAnnotationsis based on
Attribute, so it doesn’t play well with the DI
- We can create validations that use multiple properties of an object (e.g.
- Easier to test
- Validation logic is outside of the models