Question Details

No question body available.

Tags

asp.net-core validation system.text.json minimal-apis .net-10.0

Answers (1)

Accepted Answer Available
Accepted Answer
June 8, 2026 Score: 3 Rep: 153,230 Quality: Expert Completeness: 80%

It seems to be a known issue - see Validations in minimal APIs fails on several types from System.Text.Json @github which should be fixed in one of the upcoming releases based on the links in the fix @github

For now you can try fixing it by using another type, like JsonNode:

public class MyRequest
{
    [Required]
    [MaxLength(10)]
    public string Name { get; set; } = default!;

public JsonNode Payload { get; set; } }

Which works for me (checked 10.0.201 and 10.0.300):

enter image description here