Skip to content

Commit f49cb6a

Browse files
committed
[Routing] Add Requirement, a collection of universal regular-expression constants to use as route parameter requirements
1 parent 8064a5c commit f49cb6a

File tree

3 files changed

+469
-0
lines changed

3 files changed

+469
-0
lines changed

src/Symfony/Component/Routing/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ CHANGELOG
99
* Support the `attribute` type (alias of `annotation`) in annotation loaders
1010
* Already encoded slashes are not decoded nor double-encoded anymore when generating URLs (query parameters)
1111
* Add `EnumRequirement` to help generate route requirements from a `\BackedEnum`
12+
* Add `Requirement`, a collection of universal regular-expression constants to use as route parameter requirements
1213

1314
5.3
1415
---
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Routing\Requirement;
13+
14+
/*
15+
* A collection of universal regular-expression constants to use as route parameter requirements.
16+
*/
17+
enum Requirement
18+
{
19+
public const ASCII_SLUG = '[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*'; // symfony/string AsciiSlugger default implementation
20+
public const CATCH_ALL = '.+';
21+
public const DATE_YMD = '[0-9]{4}-(?:0[1-9]|1[012])-(?:0[1-9]|[12][0-9]|(?<!02-)3[01])'; // YYYY-MM-DD
22+
public const DIGITS = '[0-9]+';
23+
public const UID_BASE32 = '[0-9A-HJKMNP-TV-Z]{26}';
24+
public const UID_BASE58 = '[1-9A-HJ-NP-Za-km-z]{22}';
25+
public const UID_RFC4122 = '[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}';
26+
public const ULID = '[0-7][0-9A-HJKMNP-TV-Z]{25}';
27+
public const UUID = '[0-9a-f]{8}-[0-9a-f]{4}-[1-6][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}';
28+
public const UUID_V1 = '[0-9a-f]{8}-[0-9a-f]{4}-1[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}';
29+
public const UUID_V3 = '[0-9a-f]{8}-[0-9a-f]{4}-3[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}';
30+
public const UUID_V4 = '[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}';
31+
public const UUID_V5 = '[0-9a-f]{8}-[0-9a-f]{4}-5[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}';
32+
public const UUID_V6 = '[0-9a-f]{8}-[0-9a-f]{4}-6[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}';
33+
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy