Skip to main content

Explain Model Validation and how it works.

Mid .NET Core
Quick Answer Data annotations on model properties define rules: [Required], [StringLength(100)], [Range(1,100)], [EmailAddress]. ASP.NET Core runs these after binding and populates ModelState. if (!ModelState.IsValid) return BadRequest(ModelState) returns 400 with validation errors. Custom attributes inherit ValidationAttribute for complex rules.

Answer

Runs after binding and before action execution. Uses data annotations, custom validation attributes, and IValidatableObject. Validation results go into ModelState and must be checked before using the data.

S
SugharaIQ Editorial Team Verified Answer

This answer has been peer-reviewed by industry experts holding senior engineering roles to ensure technical accuracy and relevance for modern interview standards.

Want to bookmark, take notes, or join discussions?

Sign in to access all features and personalize your learning experience.

Sign In Create Account

Source: SugharaIQ

Ready to level up? Start Practice