-
Notifications
You must be signed in to change notification settings - Fork 886
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
URL segment validation needs clarity in predicate docs #3597
Comments
Thank you. Your suggestions sound reasonable to me. I'd like another opinion from a core contributor before you invest your time to start a PR for review, just in case there is something I don't fully understand. @mmerickel @bertjwregeer |
I think part of the complexity is that I think almost all of the standard predicates are available to both views and routes and so we like to document those in one spot. I agree that there's lots of problems with how that is structured right now however and welcome improvements. I totally agree that the docs are unclear about route predicates versus view predicates. |
I have a few more thoughts and suggestions.
With that I'll try to summarize a task list. Feedback appreciated.
The last four items will also improve the search index generated by Sphinx and in third party search engines. |
I have recently changed a predicate and added a new one, and it wasn’t great to add documentation in three spots. Mark me interested in improving the situation. |
I was trying to figure out how to match a URL segment to a UUID value today to prevent unintended route matching. I had the route
/companies/{uuid}
and the route/companies/{uuid}/edit
and a broken route path was causing the application to go to/companies/edit
. This was causing backend issues since there was no UUID validation on the route itself.The documentation for doing this is conflicting, hard to find, and missing some helpful functionality.
The conflicting portion of the documentation is here. It mentions the use of
custom_predicates
which has actually been deprecated since1.5
.It seems that the preferred method of performing this validation is via route predicates. This was hard to find because I originally associated this page more-so with application middleware instead of route matching. I can understand why it was put on this page after reading it because the route predicates act as a form of routing middleware, but it wasn't immediately obvious when trying to perform a google search.
The documentation is also missing the fact that you can define predicate usage using the
predicates
attribute on theadd_route
method for the configurator. It's actually incredibly useful because it seems you can define multiple predicate values with the same predicate this way, but it's buried in the docstrings.Suggestions
predicates
attribute for both the view configuration and the route configuration in the view and route predicates section. Highlight how each attribute correlates to their respective predicates, meaning that thepredicates
attribute for view configuration only applies to view predicates and that thepredicates
attribute on the route configuration only applies to route predicates (at least that's how it seems to be based on the docstrings).predicates
attribute between the view and route configurations.The text was updated successfully, but these errors were encountered: