-
Notifications
You must be signed in to change notification settings - Fork 126
Conversation
This is useful for a variety of interesting scenarios in link generation where a default value doesn't appear in the route template as a parameter. This can be used to implement the desired behavior for areas - where the 'area' key is sticky.
@@ -49,6 +49,9 @@ public class RouteOptions | |||
{ "maxlength", typeof(MaxLengthRouteConstraint) }, | |||
{ "length", typeof(LengthRouteConstraint) }, | |||
|
|||
// Required-value constraints | |||
{ "required", typeof(RequiredConstraint) }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does this mean as an inline constraint? Once you have a slug, isn't it required by default?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's true, I did it for completeness but I can't really think of a reason why it would be useful.
There's some weird stuff you can do with it, but nothing super helpful.
PR updated, please take a look |
/cc @harshgMSFT |
/// This constraint is primarily used to enforce that a non-parameter value is present during | ||
/// URL generation. | ||
/// </remarks> | ||
public class RequiredConstraint : IRouteConstraint |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider renaming to RequiredRouteConstraint
all other constraints follow this convention.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure
|
This is useful for a variety of interesting scenarios in link generation
where a default value doesn't appear in the route template as a parameter.
This can be used to implement the desired behavior for areas - where the
'area' key is sticky.