Skip to content

Commit 1002c23

Browse files
committed
Add ctor in HttpValidationProblemDetails that takes a IEnumerable<KeyValuePair<string, string[]>>
1 parent 75595a3 commit 1002c23

File tree

4 files changed

+12
-2
lines changed

4 files changed

+12
-2
lines changed

src/Http/Http.Abstractions/src/Microsoft.AspNetCore.Http.Abstractions.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ Microsoft.AspNetCore.Http.HttpResponse</Description>
3737
<ItemGroup>
3838
<InternalsVisibleTo Include="Microsoft.AspNetCore.Http.Abstractions.Microbenchmarks" />
3939
<InternalsVisibleTo Include="Microsoft.AspNetCore.Http.Extensions" />
40+
<InternalsVisibleTo Include="Microsoft.AspNetCore.Http.Results" />
4041
</ItemGroup>
4142

4243
<ItemGroup>

src/Http/Http.Abstractions/src/ProblemDetails/HttpValidationProblemDetails.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,15 @@ public HttpValidationProblemDetails(IDictionary<string, string[]> errors)
2828
{
2929
}
3030

31+
/// <summary>
32+
/// Initializes a new instance of <see cref="HttpValidationProblemDetails"/> using the specified <paramref name="errors"/>.
33+
/// </summary>
34+
/// <param name="errors">The validation errors.</param>
35+
internal HttpValidationProblemDetails(IEnumerable<KeyValuePair<string, string[]>> errors)
36+
: this(new Dictionary<string, string[]>(errors ?? throw new ArgumentNullException(nameof(errors)), StringComparer.Ordinal))
37+
{
38+
}
39+
3140
private HttpValidationProblemDetails(Dictionary<string, string[]> errors)
3241
{
3342
Title = "One or more validation errors occurred.";

src/Http/Http.Results/src/Results.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -799,7 +799,7 @@ public static IResult ValidationProblem(
799799
ArgumentNullException.ThrowIfNull(errors);
800800

801801
// TypedResults.ValidationProblem() does not allow setting the statusCode so we do this manually here
802-
var problemDetails = new HttpValidationProblemDetails(new Dictionary<string, string[]>(errors, StringComparer.Ordinal))
802+
var problemDetails = new HttpValidationProblemDetails(errors)
803803
{
804804
Detail = detail,
805805
Instance = instance,

src/Http/Http.Results/src/TypedResults.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -854,7 +854,7 @@ public static ValidationProblem ValidationProblem(
854854
{
855855
ArgumentNullException.ThrowIfNull(errors);
856856

857-
var problemDetails = new HttpValidationProblemDetails(new Dictionary<string, string[]>(errors))
857+
var problemDetails = new HttpValidationProblemDetails(errors)
858858
{
859859
Detail = detail,
860860
Instance = instance,

0 commit comments

Comments
 (0)