Skip to content

Need guidance on ValidatableTypeAttribute for class library in documentation, or a fix for experimental attribute #36363

@kgar

Description

@kgar

Description

I have a class library which needs the ability to specify [ValidatableType] on its models, assuming this is required for nested object validation.

After following the documentation for "Use validation models from a different assembly", I am required to use the "Experimental" attribute and suppress the error with pragma tags. Is this intentional? If so, please update the documentation to specifically instruct that people are required to do this, because it feels like this is an oversight when trying to set up class libraries with the new validation.

With that said, I hope there's some better fix than simply putting pragma tags. Upgrading our class libraries to .net 10 with the new validation did not feel seamless or like an upgrade with the need for pragma tags on all of our classes with nested validation.

Sample:

#pragma warning disable ASP0029 // dotnet 10 release notes instruct to use this attribute for nested type validation.
[Microsoft.Extensions.Validation.ValidatableType]
#pragma warning restore ASP0029 // dotnet 10 release notes instruct to use this attribute for nested type validation.
public class MyExampleParentClass {
    public class MyExampleChildClass { get; set; }
}

public class MyExampleChildClass {
    [Required]
    public string? ExampleString { get; set; }
}

Page URL

https://learn.microsoft.com/en-us/aspnet/core/blazor/forms/validation?view=aspnetcore-10.0

Content source URL

https://github.com/dotnet/AspNetCore.Docs/blob/main/aspnetcore/blazor/forms/validation.md

Document ID

bcb470e1-c859-0549-b4ef-c6c9b7ef2c72

Platform Id

b4c1bad9-fc7a-21f5-2552-f0f3617f77db

Article author

@guardrex

Metadata

  • ID: bcb470e1-c859-0549-b4ef-c6c9b7ef2c72
  • PlatformId: b4c1bad9-fc7a-21f5-2552-f0f3617f77db
  • Service: aspnet-core
  • Sub-service: blazor

Related Issues

Metadata

Metadata

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions