Skip to content

[API Proposal]: Add new constructor for HttpValidationProblemDetails that accepts a IEnumerable<KeyValuePair<string, string[]>> #56370

Closed
@joegoldman2

Description

Background and Motivation

#41899 introduces new overloads for Results.ValidationProblem and TypedResults.ValidationProblem that accepts a IEnumerable<KeyValuePair<string, string[]>> for the errors.

For the sake of consistency, it would be good to have a constructor in HttpValidationProblemDetails that also accepts a IEnumerable<KeyValuePair<string, string[]>>.

More context: #41899 (comment)

Proposed API

namespace Microsoft.AspNetCore.Http;

public partial class HttpValidationProblemDetails : ProblemDetails
{
     // existing
     public HttpValidationProblemDetails()
     public HttpValidationProblemDetails(IDictionary<string, string[]> errors)

     // new
+    public HttpValidationProblemDetails(IEnumerable<KeyValuePair<string, string[]>> errors);
}

Usage Examples

var errors = new List<KeyValuePair<string, string[]>> { new("testField", new[] { "test error" }) };
var problemDetails = new HttpValidationProblemDetails(errors);

Risks

Nothing I can see now.

Metadata

Assignees

No one assigned

    Labels

    api-approvedAPI was approved in API review, it can be implementedarea-mvcIncludes: MVC, Actions and Controllers, Localization, CORS, most templatesfeature-problem-details

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions