Class ValueObjectProblemDetails
Namespace: AdCodicem.ValueObjects.AspNetCore
Assembly: AdCodicem.ValueObjects.AspNetCore.dll
Carries the violated rule from the model binder to the problem details response.
public static class ValueObjectProblemDetails
Inheritance
object ← ValueObjectProblemDetails
Inherited Members
object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.MemberwiseClone(), object.ReferenceEquals(object?, object?), object.ToString()
Remarks
ModelStateDictionary only holds a message, and a message is not something a client can branch on. The
stable error code rides alongside it on the request, and
errorCodes extension.
Fields
ExtensionName
The extension member added to the problem details body, mapping each rejected member to its error code.
public const string ExtensionName = "errorCodes"
Field Value
Methods
GetErrorCodes(HttpContext?)
Gets the codes recorded for the current request.
public static IReadOnlyDictionary<string, string> GetErrorCodes(HttpContext? httpContext)
Parameters
httpContext HttpContext?
Current request.
Returns
IReadOnlyDictionary<string, string>
The recorded codes, or an empty dictionary.
RecordErrorCode(HttpContext?, string, string)
Records the code of the rule a bound value violated.
public static void RecordErrorCode(HttpContext? httpContext, string memberName, string errorCode)
Parameters
httpContext HttpContext?
Current request.
memberName string
Name of the rejected model member.
errorCode string
Stable code of the violated rule.