Skip to content

Commit 4f674e3

Browse files
committed
API changes
1 parent 3be6007 commit 4f674e3

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/Validation/src/ValidatablePropertyInfo.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,12 +160,14 @@ void ValidateValue(object? val, string errorPrefix, ValidationAttribute[] valida
160160
var result = attribute.GetValidationResult(val, context.ValidationContext);
161161
if (result is not null && result != ValidationResult.Success && result.ErrorMessage is not null)
162162
{
163-
context.AddOrExtendValidationErrors([result.ErrorMessage], errorPrefix.TrimStart('.'), container);
163+
var key = errorPrefix.TrimStart('.');
164+
context.AddOrExtendValidationErrors(string.Empty, key, [result.ErrorMessage], container);
164165
}
165166
}
166167
catch (Exception ex)
167168
{
168-
context.AddOrExtendValidationErrors([ex.Message], errorPrefix.TrimStart('.'), container);
169+
var key = errorPrefix.TrimStart('.');
170+
context.AddOrExtendValidationErrors(string.Empty, key, [ex.Message], container);
169171
}
170172
}
171173
}

src/Validation/src/ValidatableTypeInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,13 @@ public virtual async Task ValidateAsync(object? value, ValidateContext context,
109109
var key = string.IsNullOrEmpty(originalPrefix) ?
110110
memberName :
111111
$"{originalPrefix}.{memberName}";
112-
context.AddOrExtendValidationError(key, validationResult.ErrorMessage, value);
112+
context.AddOrExtendValidationError(memberName, key, validationResult.ErrorMessage, value);
113113
}
114114

115115
if (!validationResult.MemberNames.Any())
116116
{
117117
// If no member names are specified, then treat this as a top-level error
118-
context.AddOrExtendValidationError(string.Empty, validationResult.ErrorMessage, value);
118+
context.AddOrExtendValidationError(string.Empty, string.Empty, validationResult.ErrorMessage, value);
119119
}
120120
}
121121
}

0 commit comments

Comments
 (0)