Love these quick and simple videos. I didn't even realize until now that they had added these.
@KarmCraft Жыл бұрын
Tim you need to show what happens if you enter an invalid value. Is it design time or runtime? What does it throw?
@aslamsayyedsayyed2885 Жыл бұрын
Lots of love and respect from India. Thanks for your efforts.
@IAmTimCorey Жыл бұрын
You are welcome.
@dmytroshchotkin2939 Жыл бұрын
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 Жыл бұрын
Thanks, Master. You're amazing as always.
@anandvgchennai1974 Жыл бұрын
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.
@benjaminshinar9509 Жыл бұрын
seems nice, but I could really use a demo of those. are they checked at runtime or compile time? do they throw exceptions?
@pw.705 ай бұрын
Very useful. Thanks Tim.
@IAmTimCorey5 ай бұрын
You are welcome.
@비엠이-l8w5 ай бұрын
Thank you for teaching!😊
@IAmTimCorey5 ай бұрын
You are welcome.
@Vsd13 Жыл бұрын
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 Жыл бұрын
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.
@marcusreinicke Жыл бұрын
Thx Tim, can combined the allowed and denied values with RegEx matching?
@Don-ii4vm Жыл бұрын
4:38 Is it possible to dynamically set AllowedValues from a table?
@ajdin3511 Жыл бұрын
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 Жыл бұрын
@@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 Жыл бұрын
I also had the same question in my mind.
@Don-ii4vm Жыл бұрын
@@anandvgchennai1974 As Luke says, it woiuld be best to write a custom validator in that case.
@anandvgchennai1974 Жыл бұрын
@@Don-ii4vm Yes. Thats a good option.
@dotnetdevni Жыл бұрын
i wish they allowed dyanmic annotations so could come from the db
@FernandoZamudioC11 ай бұрын
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 ?
@IAmTimCorey11 ай бұрын
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
@BrentHollett Жыл бұрын
Do any of these flow to EF and remove the need for some Entity Configuration steps?
@Anton-Os Жыл бұрын
Tim, thanks!
@IAmTimCorey Жыл бұрын
You are welcome.
@scdecade Жыл бұрын
Hmmm now I'm curious to see the error messages generated by these validations
@queenstownswords Жыл бұрын
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 Жыл бұрын
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.
@BrandonChawane7 ай бұрын
Does it mean I no longer need to get/set value in my getter/setter blocks?
@IAmTimCorey7 ай бұрын
I don't understand what you mean. If you are asking if you can remove the get/set in a property, the answer is no. The items I covered in this video just check to be sure the data entered is correct.
@BrandonChawane7 ай бұрын
@@IAmTimCorey oh I see now. Strictly for validation
@kvelez8 ай бұрын
Cool excellent man.
@IAmTimCorey8 ай бұрын
Thanks!
@Maykon8617 ай бұрын
Can I validate that there are no duplicate objects in a list?
@IAmTimCorey7 ай бұрын
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.
@methic-w1l Жыл бұрын
Thanks very useful.
@DDDD-rr6uo Жыл бұрын
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 Жыл бұрын
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.
@zohashobbar1186 ай бұрын
thanks
@IAmTimCorey6 ай бұрын
You are welcome.
@swordblaster2596 Жыл бұрын
But what's it FOR?
@IAmTimCorey Жыл бұрын
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 Жыл бұрын
@@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 Жыл бұрын
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 Жыл бұрын
@@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.