Data Annotations and ModelState

Put validation rules on the model with data annotations such as [Required], [StringLength] and [Range]; check ModelState.IsValid in the action; add your own errors with AddModelError; and show the messages with validation tag helpers.

Updated

Cheat sheet: Data Annotations and ModelState
Category
ASP.NET Core
Level
Journeyman
Tags
aspnet-core, c-sharp, Data Annotations, Model Validation, ModelState, Validation Tag Helpers