C
C#3mo ago
Lounder

ASP.NET Core - Database Model and ViewModel Validation

What is the point of writing Validation attributes outside of the EF Core Data Model (for example in the ViewModel), given that the checks are not only valid for the database, but are also triggered when a request is received?
4 Replies
Lounder
Lounder3mo ago
Please ping @ me
Unknown User
Unknown User3mo ago
Message Not Public
Sign In & Join Server To View
Lounder
Lounder3mo ago
@TeBeCo Does this mean you need to write the same rules from the DB Model validation to the DTO Validation? This way the request will get stopped before reaching the database Example validation attribute: [Range(1, 10)] @ me for immediate response
Unknown User
Unknown User3mo ago
Message Not Public
Sign In & Join Server To View