Useful data annotations that are new in .NET 8

Опубликовано: 05 Декабрь 2023
на канале: Round The Code
5,631
97

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


Смотрите видео Useful data annotations that are new in .NET 8 онлайн без регистрации, длительностью часов минут секунд в хорошем качестве. Это видео добавил пользователь Round The Code 05 Декабрь 2023, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 5,631 раз и оно понравилось 97 людям.