Easily Validate the Options Pattern with FluentValidation
Milan Jovanović
0:00 / 0:00
Easily Validate the Options Pattern with FluentValidation
15 205 просмотров · 2 года назад
Milan Jovanović
168 тыс. подписчиков
15 205 просмотров · 2 года назад
☄️ Master the Modular Monolith Architecture: https://bit.ly/3SXlzSt
📌 Accelerate your Clean Architecture skills: https://bit.ly/3PupkOJ
🚀 Support me on Patreon to access the source code: / milanjovanovic
The options pattern creates strongly typed settings classes in .NET. It's important to validate the options pattern to ensure your configuration values are correctly set. You can do it with data annotations, although this approach isn't flexible. A better solution is to use FluentValidation, and I'll show you how in this video.
Join my weekly .NET newsletter:
https://www.milanjovanovic.tech
Read my Blog here:
https://www.milanjovanovic.tech/blog
Adding validation to strongly typed configuration objects using FluentValidation:
https://andrewlock.net/adding-validat...
Chapters
0:00 Validating options pattern with Data Annotations
2:58 Registering FluentValidation with dependency injection
3:58 Creating the validator using FluentValidation
6:54 Implementing IValidateOptions using FluentValidation
11:08 Adding extension method to register the validator
13:30 Simplifying everything with another extension method