# 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.

![Cheat sheet: Data Annotations and ModelState](https://fsdtrainingmedia.blob.core.windows.net/public/images/2026/11/4ddbd30f88274c8daaaddb1febee281f.webp)

- Category: ASP.NET Core
- Level: Journeyman
- Tags: aspnet-core, c-sharp, Data Annotations, Model Validation, ModelState, Validation Tag Helpers
- Updated: November 3, 2026

Source: https://www.ask-codey.com/cheat-sheets/model-binding-and-validation-data-annotations-and-modelstate-cheat-sheet
