-
Notifications
You must be signed in to change notification settings - Fork 122
Using square brackets in regex constraints #373
Comments
Escape (double) the special characters: That said, we should improve the message in this case. An un-escaped curly brace leads to an informative message:
message appears only when square brackets appear within square-bracketed tokens. Nit: The curly-brace message should end with a period 😈 |
Oh that's awesome. Not sure how I looked at it so many times and didn't see the Would it be helpful to include this in the routing docs? I can open an issue if it would help. I scoured that page to find the info; this issue was my last resort. |
Yeah definitely something we can improve. I think the fixes are:
At the same time, I'm working on some improvements to the routing docs to clarify some of this. |
Here's my PR to improve the docs if anyone wants to take a look: dotnet/AspNetCore.Docs#2450 |
I have a controller that accepts either an ID or a string at a given endpoint. I have the ID function set correctly using
api/departments/{id:long}
, but I cannot figure out how to route to the string endpoint. Thealpha
constraint is not enough as the string can contain numbers.I'm trying to use this route to accept any valid string but require that the first character be a letter.
This does not work, however:
What is the correct way to approach this?
The text was updated successfully, but these errors were encountered: