model validation
Checking that incoming data meets the rules, such as required fields and ranges, before the application acts on it.
In more detail
Validate at the boundary, before business work or persistence, and return errors that name the field and the rule. ASP.NET Core runs data annotation validation automatically for [ApiController] controllers.
Related terms
- data annotations — Attributes from System.ComponentModel.DataAnnotations, such as [Required] and [Range(1, 200)], that declare simple validation rules on properties.
- FluentValidation — A .NET library for writing validation rules as classes with a fluent API, such as RuleFor(x => x.Price).GreaterThan(0).
- Problem Details — A standard JSON shape for HTTP error responses, defined in RFC 9457, with members such as type, title, status, detail and instance.
- [ApiController] — An attribute that switches on web API conventions for a controller, including automatic 400 responses for invalid models and inferred binding sources.
Taught in
- The Options Pattern: Strongly Typed Configuration — Modern .NET Core, C# & Enterprise Microservices
- Building Routes with Controllers — Modern .NET Core, C# & Enterprise Microservices
- Model Validation and FluentValidation — Modern .NET Core, C# & Enterprise Microservices