Created
March 4, 2021 09:57
-
-
Save maximgorbatyuk/7663b52c0a13b084ade24802e307de42 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Net; | |
using Microsoft.AspNetCore.Mvc; | |
namespace YourNamespace | |
{ | |
public class ValidationProblemDetails : ProblemDetails | |
{ | |
// 400 status ccode is usually used for input validation errors | |
public const int ValidationStatusCode = (int)HttpStatusCode.BadRequest; | |
public ValidationProblemDetails(ICollection<ValidationError> validationErrors) | |
{ | |
ValidationErrors = validationErrors; | |
Status = ValidationStatusCode; | |
Title = "Request Validation Error"; | |
} | |
public ICollection<ValidationError> ValidationErrors { get; } | |
public string RequestId => Guid.NewGuid().ToString(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment