Adding Validation To The Options Pattern In ASP.NET Core
Support me on Patreon to access the source code:
https://www.patreon.com/milanjovanovic
The Options pattern allows us to use classes to provide strongly typed configuration values in our application at runtime. But you have no guarantee that the configuration values injected with IOptions will be correctly read from the application settings. In this video, I will show you how to introduce validation to your IOptions and ensure the application settings are correct. You will also see how to verify that the options are correctly configured at the application start.
Adding Validation To The Options Pattern In ASP.NET Core
https://www.milanjovanovic.tech/blog/adding-validation-to-the-options-pattern-in-asp-net-core
How To Use The Options Pattern In ASP.NET Core 7:
https://www.milanjovanovic.tech/blog/how-to-use-the-options-pattern-in-asp-net-core-7
Join my weekly .NET newsletter:
https://www.milanjovanovic.tech
Read my Blog here:
https://www.milanjovanovic.tech/blog
Subscribe for more:
https://www.youtube.com/@MilanJovanovicTech?sub_confirmation=1
Chapters
0:00 Configuring the Options pattern
1:40 Checking the setting’s value
2:27 What could go wrong?
3:05 Adding validation with Data Annotations
3:35 Configuring the Options pattern for validation
5:20 Validating options at application start
6:42 Adding custom validation rules
Comments are closed.