[API Proposal]: Add new constructor for HttpValidationProblemDetails
that accepts a IEnumerable<KeyValuePair<string, string[]>>
#56370
Closed
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.