Skip to content

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

Open
@clementinelove

Description

@clementinelove

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions