-
Notifications
You must be signed in to change notification settings - Fork 9.8k
/
HttpValidationProblemDetails.cs
40 lines (34 loc) · 1.46 KB
/
HttpValidationProblemDetails.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using Microsoft.AspNetCore.Mvc;
namespace Microsoft.AspNetCore.Http;
/// <summary>
/// A <see cref="ProblemDetails"/> for validation errors.
/// </summary>
public class HttpValidationProblemDetails : ProblemDetails
{
/// <summary>
/// Initializes a new instance of <see cref="HttpValidationProblemDetails"/>.
/// </summary>
public HttpValidationProblemDetails()
: this(new Dictionary<string, string[]>(StringComparer.Ordinal))
{
}
/// <summary>
/// Initializes a new instance of <see cref="HttpValidationProblemDetails"/> using the specified <paramref name="errors"/>.
/// </summary>
/// <param name="errors">The validation errors.</param>
public HttpValidationProblemDetails(IDictionary<string, string[]> errors)
: this(new Dictionary<string, string[]>(errors ?? throw new ArgumentNullException(nameof(errors)), StringComparer.Ordinal))
{
}
private HttpValidationProblemDetails(Dictionary<string, string[]> errors)
{
Title = "One or more validation errors occurred.";
Errors = errors;
}
/// <summary>
/// Gets the validation errors associated with this instance of <see cref="HttpValidationProblemDetails"/>.
/// </summary>
public IDictionary<string, string[]> Errors { get; set; } = new Dictionary<string, string[]>(StringComparer.Ordinal);
}