Skip to content

Commit 678dbf8

Browse files
committed
Add ErrorCodeName to ValidationError
1 parent 33d3ae0 commit 678dbf8

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
namespace LeanCode.Contracts.Validation;
22

3-
public class ValidationError(string propertyName, string errorMessage, int errorCode)
3+
public class ValidationError(string propertyName, string errorMessage, int errorCode, string? errorCodeName = null)
44
{
55
public string PropertyName { get; } = propertyName;
66
public string ErrorMessage { get; } = errorMessage;
77
public int ErrorCode { get; } = errorCode;
8+
public string? ErrorCodeName { get; } = errorCodeName;
89
}

src/LeanCode.ContractsGenerator.Tests/Serialization/CommandResultSerializationTests.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace LeanCode.ContractsGenerator.Tests.Serialization;
99
public class CommandResultSerializationTests
1010
{
1111
private static readonly CommandResult SampleCommandResult = CommandResult.NotValid(
12-
new([new ValidationError("A property", "An error message", 1)])
12+
new([new ValidationError("A property", "An error message", 1, "ErrorCodeName")])
1313
);
1414

1515
private const string Json = $$"""
@@ -18,7 +18,8 @@ public class CommandResultSerializationTests
1818
{
1919
"{{nameof(ValidationError.PropertyName)}}": "A property",
2020
"{{nameof(ValidationError.ErrorMessage)}}": "An error message",
21-
"{{nameof(ValidationError.ErrorCode)}}": 1
21+
"{{nameof(ValidationError.ErrorCode)}}": 1,
22+
"{{nameof(ValidationError.ErrorCodeName)}}": "ErrorCodeName"
2223
}
2324
],
2425
"{{nameof(CommandResult.WasSuccessful)}}": false

0 commit comments

Comments
 (0)