ASP.NET Core 10 New Validation Features in Minimal APIs
ASP.NET Core 10 New Validation Features in Minimal APIs ASP.NET Core 10 introduces built-in validation support for Minimal APIs. This is one of an important improvement because Minimal APIs can now validate incoming request data automatically before endpoint logic runs. In the sample API, validation is enabled by using the following line: builder.Services.AddValidation(); Once validation is enabled, ASP.NET Core can validate request body models, query string values, route values, and headers using familiar Data Annotations attributes such as [Required] , [Range] , [StringLength] , [EmailAddress] , and [RegularExpression] . What Are the New ASP.NET Core 10 Validation Features? ASP.NET Core 10 adds automatic validation support for Minimal API endpoints. Earlier, automatic validation was commonly associated with MVC controllers and the [ApiController] attribute. Minimal APIs were lightweight and simple, but developers often had to wri...