Skip to content
This repository has been archived by the owner on Nov 27, 2018. It is now read-only.

Implement a 'required' constraint #79

Closed
wants to merge 4 commits into from
Closed

Conversation

rynowak
Copy link
Member

@rynowak rynowak commented Jul 2, 2014

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.

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) },
Copy link
Contributor

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?

Copy link
Member Author

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.

@rynowak
Copy link
Member Author

rynowak commented Jul 8, 2014

PR updated, please take a look

@rynowak
Copy link
Member Author

rynowak commented Jul 8, 2014

/cc @harshgMSFT

/// This constraint is primarily used to enforce that a non-parameter value is present during
/// URL generation.
/// </remarks>
public class RequiredConstraint : IRouteConstraint
Copy link
Contributor

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure

@harshgMSFT
Copy link
Contributor

:shipit:

@rynowak rynowak closed this Jul 8, 2014
@rynowak rynowak deleted the required-constraint branch July 8, 2014 23:27
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants