dotnet-api-docs icon indicating copy to clipboard operation
dotnet-api-docs copied to clipboard

Missing information that `Validator.ValidateObject` / `Validator.TryValidateObject` also calls `IValidatableObject.Validate`

Open clementinelove opened this issue 11 months ago • 1 comments

Type of issue

Missing information

Description

From the source code of Validator.ValidateObject / Validator.TryValidateObject we can see they will first validate all the attributes, then if the given object instance are IValidatableObject, it will call the IValidatableObject.Validate to validate it.

I believe it's quite important to make this behavior explicit as people may already rely on this behavior for a long time.

Page URL

https://learn.microsoft.com/en-us/dotnet/api/system.componentmodel.dataannotations.validator.validateobject?view=net-9.0

Content source URL

https://github.com/dotnet/dotnet-api-docs/blob/main/xml/System.ComponentModel.DataAnnotations/Validator.xml

Document Version Independent Id

6ebc3f46-2534-6c8d-797c-3ec39f57feca

Article author

@dotnet-bot

clementinelove avatar Jan 24 '25 09:01 clementinelove

Tagging subscribers to this area: @ajcvickers