diff --git a/src/Symfony/Component/Routing/CHANGELOG.md b/src/Symfony/Component/Routing/CHANGELOG.md index 62e7cd25f0dc..fac41b5e638f 100644 --- a/src/Symfony/Component/Routing/CHANGELOG.md +++ b/src/Symfony/Component/Routing/CHANGELOG.md @@ -1,6 +1,11 @@ CHANGELOG ========= +6.2 +--- + + * Add `Requirement::POSITIVE_INT` for common ids and pagination + 6.1 --- diff --git a/src/Symfony/Component/Routing/Requirement/Requirement.php b/src/Symfony/Component/Routing/Requirement/Requirement.php index aa5e464e7260..eefc62e7aae2 100644 --- a/src/Symfony/Component/Routing/Requirement/Requirement.php +++ b/src/Symfony/Component/Routing/Requirement/Requirement.php @@ -20,6 +20,7 @@ enum Requirement public const CATCH_ALL = '.+'; public const DATE_YMD = '[0-9]{4}-(?:0[1-9]|1[012])-(?:0[1-9]|[12][0-9]|(?assertMatchesRegularExpression( + (new Route('/{digits}', [], ['digits' => Requirement::POSITIVE_INT]))->compile()->getRegex(), + '/'.$digits, + ); + } + + /** + * @testWith [""] + * ["0"] + * ["045"] + * ["foo"] + * ["-1"] + * ["3.14"] + */ + public function testPositiveIntKO(string $digits) + { + $this->assertDoesNotMatchRegularExpression( + (new Route('/{digits}', [], ['digits' => Requirement::POSITIVE_INT]))->compile()->getRegex(), + '/'.$digits, + ); + } + /** * @testWith ["00000000000000000000000000"] * ["ZZZZZZZZZZZZZZZZZZZZZZZZZZ"]
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: