Data Annotation Updates in .NET 8

  Рет қаралды 13,732

IAmTimCorey

IAmTimCorey

6 ай бұрын

In .NET 8, we were given some new data annotation options for validating our properties. Let's look at these new options and how to use them in this 10-minute training video.
Full Training Courses: IAmTimCorey.com
Source Code: leadmagnets.app/?Resource=Dat...
Mailing List: signup.iamtimcorey.com/

Пікірлер: 42
@KarmCraft
@KarmCraft 6 ай бұрын
Tim you need to show what happens if you enter an invalid value. Is it design time or runtime? What does it throw?
@chris_cole
@chris_cole 6 ай бұрын
Love these quick and simple videos. I didn't even realize until now that they had added these.
@dmytroshchotkin2939
@dmytroshchotkin2939 6 ай бұрын
Thanks, Tim. It would have been nicer if you had shown one use-case scenario. Are the attributes applicable when we deserialize using System.Text serializer only?
@andergarcia1115
@andergarcia1115 6 ай бұрын
Thanks, Master. You're amazing as always.
@anandvgchennai1974
@anandvgchennai1974 6 ай бұрын
Thanks for explaining these new cool features. Next time I think MS should come with LengthAfterTrim (5, 25). Most of the time we check the length of string after trimming the values entered.
@Vsd13
@Vsd13 6 ай бұрын
It would be interesting to know what to do with the project after its development, how to upload your project and database to the server. For example, so that I can send a link to the site I created. Maybe you already have a video that indirectly explains this topic?
@shadmansudipto7287
@shadmansudipto7287 6 ай бұрын
What? You need to watch a beginner aspnet tutorial. There are many on KZbin. Why ask him to make yet another? It doesn't add any value to do what is already done.
@user-fqlt
@user-fqlt 6 ай бұрын
Thanks very useful.
@aslamsayyedsayyed2885
@aslamsayyedsayyed2885 6 ай бұрын
Lots of love and respect from India. Thanks for your efforts.
@IAmTimCorey
@IAmTimCorey 6 ай бұрын
You are welcome.
@benjaminshinar9509
@benjaminshinar9509 5 ай бұрын
seems nice, but I could really use a demo of those. are they checked at runtime or compile time? do they throw exceptions?
@Anton-Os
@Anton-Os 6 ай бұрын
Tim, thanks!
@IAmTimCorey
@IAmTimCorey 6 ай бұрын
You are welcome.
@marcusreinicke7352
@marcusreinicke7352 5 ай бұрын
Thx Tim, can combined the allowed and denied values with RegEx matching?
@queenstownswords
@queenstownswords 6 ай бұрын
Hello Tim. Great video. Would you need to check for consistency in the database table, in the class definition annotation (this video) and in a UI text attributes? Is there an annotation for keeping DeniedValues - like something that is not UTF-8 - out of the input?
@IAmTimCorey
@IAmTimCorey 6 ай бұрын
I always check the data whenever a user has access to create/change it. Never trust the user. Data integrity in the database is a whole different topic and not one you would typically address with these types of rules. As for a non-UTF-8 check, that would probably need to be a custom rule.
@BrentHollett
@BrentHollett 6 ай бұрын
Do any of these flow to EF and remove the need for some Entity Configuration steps?
@kvelez
@kvelez 24 күн бұрын
Cool excellent man.
@IAmTimCorey
@IAmTimCorey 23 күн бұрын
Thanks!
@scdecade
@scdecade 6 ай бұрын
Hmmm now I'm curious to see the error messages generated by these validations
@FernandoZamudioC
@FernandoZamudioC 4 ай бұрын
Thanks for this wonderful videos ! I hace a question...i usually i used a partial class to define this data annotatios but ModelMetadataType in the Microsoft.aspnetCore.mvc is deprecated ! can you helpme ?
@IAmTimCorey
@IAmTimCorey 4 ай бұрын
I believe you just need to use the Core version of the library: learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.mvc.modelmetadatatypeattribute?view=aspnetcore-8.0
@cissemy
@cissemy 6 ай бұрын
Thanks
@IAmTimCorey
@IAmTimCorey 6 ай бұрын
You are welcome.
@dotnetdevni
@dotnetdevni 5 ай бұрын
i wish they allowed dyanmic annotations so could come from the db
@Don-ii4vm
@Don-ii4vm 6 ай бұрын
4:38 Is it possible to dynamically set AllowedValues from a table?
@ajdin3511
@ajdin3511 6 ай бұрын
If its data that is a lookup table(values that dont change often), perhaps a table that stores types of roles user can have, I believe you can just create an enum and use its values in data annotation as allowed values and it should work fine, making it dynamic is an issue i dont think this solves.
@Don-ii4vm
@Don-ii4vm 6 ай бұрын
@@ajdin3511 The values dont change often, but they do change and it would be useful if the software didnt need to be recompiled each time.
@anandvgchennai1974
@anandvgchennai1974 6 ай бұрын
I also had the same question in my mind.
@Don-ii4vm
@Don-ii4vm 6 ай бұрын
@@anandvgchennai1974 As Luke says, it woiuld be best to write a custom validator in that case.
@anandvgchennai1974
@anandvgchennai1974 6 ай бұрын
@@Don-ii4vm Yes. Thats a good option.
@DDDD-rr6uo
@DDDD-rr6uo 6 ай бұрын
Hello IAmTimCorey! I wont you to tell your students when its good to use ai or copilot for coding or how much is it allowed to do so as a new c sharp students who are following your master course
@IAmTimCorey
@IAmTimCorey 6 ай бұрын
I would recommend avoiding it when you are learning. Copilot is great, but it isn't always right. Learn how to do things right before you get led astray by code that looks right but actually isn't.
@Maykon861
@Maykon861 3 күн бұрын
Can I validate that there are no duplicate objects in a list?
@IAmTimCorey
@IAmTimCorey 3 күн бұрын
That would need to be a custom validator. Either that or you could use a specific list type that did not allow duplicates like HashSet.
@swordblaster2596
@swordblaster2596 6 ай бұрын
But what's it FOR?
@IAmTimCorey
@IAmTimCorey 6 ай бұрын
Data validation. So if you have a user fill out a form, you can check to see if the data is valid according to your rules.
@holger_p
@holger_p 6 ай бұрын
@@IAmTimCorey So is there a package like EF or Dabber, processing these annotations, or do I have to do it myself, if you say "you can check" ? If I have to do it myself, I can always define the Annotations myself and the entire thing would be useless - if nobody else is processing it. When I just query a remote database into these annotated classes, does the execution fail, if incoming data are invalid.
@IAmTimCorey
@IAmTimCorey 6 ай бұрын
When the user submits a form, the validations can be automatically checked before the submit button is processed (client-side) and once the data is sent to the server (server-side). It isn't something you need to do manually.
@holger_p
@holger_p 6 ай бұрын
@@IAmTimCorey OK, the question came up, cause Entity Framework is building a SQL-structure from such kind of annotations, translating MinLength, MaxLength into Datatype NVarChar(min, max) The term "Data annotations" is not unique to validation.
@E_G_
@E_G_ 6 ай бұрын
Waiting for BlackFriday Dsicounts :)
Dependency Injection Updates in .NET - Keyed Implementations
8:31
The Dictionary Data Structure in C# in 10 Minutes or Less
10:20
IAmTimCorey
Рет қаралды 28 М.
Miracle Doctor Saves Blind Girl ❤️
00:59
Alan Chikin Chow
Рет қаралды 25 МЛН
Разбудила маму🙀@KOTVITSKY TG:👉🏼great_hustle
00:11
МишАня
Рет қаралды 3,9 МЛН
Conforto para a barriga de grávida 🤔💡
00:10
Polar em português
Рет қаралды 107 МЛН
Containerize Your C# Application Easily with the .NET CLI
9:57
IAmTimCorey
Рет қаралды 34 М.
NLP for Developers: Annotating Language Data | Rasa
7:26
(S1: EP:08) Blazor adding CSS File and Style in your Page.
8:29
Dotnetist Enterprise
Рет қаралды 7 М.
Setting Up Our Project: Building a Postman Clone Course
22:49
IAmTimCorey
Рет қаралды 8 М.
How Entity Framework Tries to Copy Dapper in .NET 8
9:46
Nick Chapsas
Рет қаралды 40 М.
C# inheritance 👪
4:29
Bro Code
Рет қаралды 50 М.
JAVA DTO Pattern Tutorial | Simplify Your Code
19:12
Amigoscode
Рет қаралды 186 М.
Choosing a Database for Systems Design: All you need to know in one video
23:58
Command Line Arguments in C# Applications in 10 Minutes or Less
8:47
Data annotations in asp.net core MVC | Asp.net Core MVC tutorial for beginners
11:40