There are some new data annotations in .NET 8 that can be used for model validation in ASP.NET Core MVC and Web API.
These include being able to validate a Base64 string, specifying any allowed and denied values through the AllowedValues and DeniedValues attributes, and specify the number of items that appears in a list.
In-addition, there is also additional properties added to the Range attribute where you can mark whether the minimum or maximum is exclusive. Essentially, you can throw a validation error if the value is equal to either the minimum or maximum.
In this video, we'll write a model validation class that we'll use in an ASP.NET Core Web API controller endpoint. Afterwards, we'll test the validation out in Swagger to see how it works.
💻 Download the code example for this tutorial💻
https://www.roundthecode.com/dotnet-c...
📖 Learn .NET and C# with our online courses 📖
https://www.roundthecode.com/dotnet-c...
👨💻Take our .NET and C# coding challenges👨💻
https://www.roundthecode.com/dotnet-c...
► More information:
https://www.roundthecode.com/dotnet-t...
🎥 Playlist 🎥
• .NET 8 and C# 12 new features
► Chapters
0:00 What we'll cover
0:16 Writing the model for validation
2:18 Writing the controller for validation
2:53 Test out the validation in Swagger
4:30 More data annotations in .NET
#validation #webapi #dotnet
Watch video Useful data annotations that are new in .NET 8 online without registration, duration hours minute second in high quality. This video was added by user Round The Code 05 December 2023, don't forget to share it with your friends and acquaintances, it has been viewed on our site 5,631 once and liked it 97 people.