The best way to validate your options in .NET Core

The best way to validate your options in .NET Core

HomeMilan JovanovićThe best way to validate your options in .NET Core
The best way to validate your options in .NET Core
ChannelPublish DateThumbnail & View CountDownload Video
Channel AvatarPublish Date not found Thumbnail
0 Views
️ Master the modular monolith architecture: https://bit.ly/3SXlzSt
Accelerate your Clean Architecture knowledge: https://bit.ly/3PupkOJ
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 settings in our application at runtime. However, you have no guarantee that the configuration settings injected using IOptions will be read correctly from the application settings. In this video, I'll show you how to introduce validation in your IOptions and make sure the application settings are correct. You'll also see how to check that the options are correctly configured when the application starts.

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

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

Subscribe to 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_confirmation1

Chapter
0:00 Configuring the option pattern
1:40 Checking the setting value
2:27 What could go wrong?
3:05 Add validation with data annotations
3:35 Configuring the options pattern for validation
5:20 Validate options at application startup
6:42 Adding custom validation rules

Please take the opportunity to connect with your friends and family and share this video with them if you find it useful.