Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/LeanCode.Contracts/Validation/ValidationError.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
namespace LeanCode.Contracts.Validation;

public class ValidationError(string propertyName, string errorMessage, int errorCode)
public class ValidationError(string propertyName, string errorMessage, int errorCode, string? errorName = null)
{
public string PropertyName { get; } = propertyName;
public string ErrorMessage { get; } = errorMessage;
public int ErrorCode { get; } = errorCode;
public string? ErrorName { get; } = errorName;
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace LeanCode.ContractsGenerator.Tests.Serialization;
public class CommandResultSerializationTests
{
private static readonly CommandResult SampleCommandResult = CommandResult.NotValid(
new([new ValidationError("A property", "An error message", 1)])
new([new ValidationError("A property", "An error message", 1, "ErrorCodeName")])
);

private const string Json = $$"""
Expand All @@ -18,7 +18,8 @@ public class CommandResultSerializationTests
{
"{{nameof(ValidationError.PropertyName)}}": "A property",
"{{nameof(ValidationError.ErrorMessage)}}": "An error message",
"{{nameof(ValidationError.ErrorCode)}}": 1
"{{nameof(ValidationError.ErrorCode)}}": 1,
"{{nameof(ValidationError.ErrorName)}}": "ErrorCodeName"
}
],
"{{nameof(CommandResult.WasSuccessful)}}": false
Expand Down
Loading