Respect JsonSerializerOptions casing for property names in validation errors #61764
Labels
area-minimal
Includes minimal APIs, endpoint filters, parameter binding, request delegate generator etc
feature-validation
Issues related to model validation in minimal and controller-based APIs
HttpValidationProblemDetails (returned by TypedResults.ValidationProblem, BadRequest(ModelState) and the automatic minimal-API parameter validation pipeline) currently reports member names exactly as they appear in CLR code (PascalCase). When an app opts into a different JSON naming policy—most commonly camelCase via
the payload that describes the validation failure no longer matches the property names clients actually send or expect to receive. This breaks tooling that relies on the error object for UI-binding or automatic form generation and is inconsistent with other framework-generated JSON (OpenAPI, regular serialization, etc.). 
The root cause is that the code paths in src/Http/Http.Abstractions/src/Validation choose ValidationResult.MemberName from reflection data (PropertyInfo.Name) without running it through the serializer’s PropertyNamingPolicy.
Reproduction
Request
⸻
Current output
Notice the PascalCase LastName.
⸻
Expected output
The member name should respect the configured naming policy or any [JsonPropertyName] attribute.
The fix for this should include:
Because the validation helpers live entirely in Http.Abstractions, the change is self-contained and should not affect MVC's codepaths.
The text was updated successfully, but these errors were encountered: