dotnet / dotnet/aspnetcore

Minimal API validation should support validation attributes on primary constructor parameters

Open
#61,526 2 comments 0 reactions 0 assignees View on GitHub
area-minimal feature-validation
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 6h
Merged PRs (30d)
290

Description

The implementation currently doesn't support scenarios like the following:

```
public class SubType(string? requiredProperty, [StringLength(10)] string? stringWithLength)
{
[Required]
public string RequiredProperty { get; } = requiredProperty;

public string? StringWithLength { get; } = stringWithLength;
}
```

Where attributes are applied on parameters for a primary constructor for a class. We need to update the constructor discovery logic to be less greedy when discovering primary constructors for non-record types.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.