Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[RFC] Predefined conditions in route parameter requirements #26524

Copy link
Copy link
Closed
@linaori

Description

@linaori
Issue body actions
Q A
Bug report? no
Feature request? yes
BC Break report? no
RFC? yes
Symfony version 4.1

Often enough when defining a route, you want a certain condition bound to your parameter. Often those conditions are a digit, a set of alpha-numerical characters or maybe even a uuid. The gives a lot of repetition and chances of faulty conditions.

It would be nice if we could add some predefined conditions in the form of configuration via either the application or provide it via a bundle. The discussion on slack:

@Taluu

What could be good IMO could be to be able to set "default requirements" on routes. We have a lot of "requirements"={"id"="[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}"} in our routes (uuids), so being able to have a kind of template / default "for id, if not specified otherwise, use this requirement"

@iltar

the ability to refer to predefined conditions would be nice
@Route("/foo/{bar<:uuid>}/")

@nicolas-grekas

using subroutines, we could make it @Route("/foo/{bar<(?&uuid)>}/") https://pcre.org/current/doc/html/pcre2syntax.html#SEC21
we would "just" need a way to define subroutines
please open an issue if you want to keep track of the idea

This in reference to the awesome feature that nicolas is working on: #26518

Metadata

Metadata

Assignees

No one assigned

    Labels

    FeatureRFCRFC = Request For Comments (proposals about features that you want to be discussed)RFC = Request For Comments (proposals about features that you want to be discussed)Routing

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.