No-op if ValidateComplexType is validated without the right context (#18935)
Fixes https://github.com/dotnet/aspnetcore/issues/17316
This commit is contained in:
parent
074f8faf58
commit
fb50111c92
|
|
@ -19,11 +19,10 @@ namespace System.ComponentModel.DataAnnotations
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
protected override ValidationResult IsValid(object value, ValidationContext validationContext)
|
protected override ValidationResult IsValid(object value, ValidationContext validationContext)
|
||||||
{
|
{
|
||||||
if (!ObjectGraphDataAnnotationsValidator.TryValidateRecursive(value, validationContext))
|
ObjectGraphDataAnnotationsValidator.TryValidateRecursive(value, validationContext);
|
||||||
{
|
|
||||||
throw new InvalidOperationException($"{nameof(ValidateComplexTypeAttribute)} can only used with {nameof(ObjectGraphDataAnnotationsValidator)}.");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// Validation of the properties on the complex type are responsible for adding their own messages.
|
||||||
|
// Therefore, we can always return success from here.
|
||||||
return ValidationResult.Success;
|
return ValidationResult.Success;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue