Skip to content

Commit fb50111

Browse files
authored
No-op if ValidateComplexType is validated without the right context (#18935)
Fixes #17316
1 parent 074f8fa commit fb50111

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/Components/Blazor/Validation/src/ValidateComplexTypeAttribute.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,10 @@ public sealed class ValidateComplexTypeAttribute : ValidationAttribute
1919
/// <inheritdoc />
2020
protected override ValidationResult IsValid(object value, ValidationContext validationContext)
2121
{
22-
if (!ObjectGraphDataAnnotationsValidator.TryValidateRecursive(value, validationContext))
23-
{
24-
throw new InvalidOperationException($"{nameof(ValidateComplexTypeAttribute)} can only used with {nameof(ObjectGraphDataAnnotationsValidator)}.");
25-
}
22+
ObjectGraphDataAnnotationsValidator.TryValidateRecursive(value, validationContext);
2623

24+
// Validation of the properties on the complex type are responsible for adding their own messages.
25+
// Therefore, we can always return success from here.
2726
return ValidationResult.Success;
2827
}
2928
}

0 commit comments

Comments
 (0)