-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Closed
Labels
area-minimalIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcfeature-validationIssues related to model validation in minimal and controller-based APIsIssues related to model validation in minimal and controller-based APIs
Description
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
Certain validations, such as [Required]
and [MinLength]
, are not working as expected on query or path parameters to a minimal API endpoint.
For example, this endpoint:
app.MapGet("/required-param", (
[Required] string? name
) =>
{
return TypedResults.Ok($"Hello {name}");
});
does not validate that a name was specified in the query string. Also, this endpoint
app.MapGet("/minlength-param", (
[MaxLength(5)] string? name
) =>
{
return TypedResults.Ok($"Hello {name}");
});
does not generate a validation error for a name with less that 5 characters.
The problem also occurs for path parameters, such as in this case:
app.MapGet("/path-param/{name}", (
[MaxLength(5)] string? name
) =>
{
return TypedResults.Ok($"Hello {name}");
});
Expected Behavior
Validations should be performed as specified.
Steps To Reproduce
Repro of all the cases above are in the project in the validate-required-params directory of this repo:
https://github.com/mikekistler/dotnet10-issue-repros
Exceptions (if any)
No response
.NET Version
10.0.100-preview.4.25258.110
Anything else?
No response
Metadata
Metadata
Assignees
Labels
area-minimalIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcfeature-validationIssues related to model validation in minimal and controller-based APIsIssues related to model validation in minimal and controller-based APIs