From 49cb38bd83cad6d3097f3baae4c1489b520e9093 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Mon, 22 Sep 2025 17:51:11 +0200 Subject: [PATCH] [Validator] Add option to allow ANY protocol in Assert\Url constraint --- reference/constraints/Url.rst | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/reference/constraints/Url.rst b/reference/constraints/Url.rst index c3fac520f96..5a9b4cd0da8 100644 --- a/reference/constraints/Url.rst +++ b/reference/constraints/Url.rst @@ -237,6 +237,21 @@ the ``ftp://`` type URLs to be valid, redefine the ``protocols`` array, listing } } +The value of this option can also be an asterisk (``*``) to allow all protocols +or a regular expression:: + + // allows all protocols whose names are RFC 3986 compliant + // (e.g. 'https://', 'git+ssh://', 'file://', 'custom://') + protocols: ['*'] + + // regular expressions are also valid + protocols: ['https?', 'custom.*', 'my-app-.*'] + +.. versionadded:: 7.4 + + Support for ``*`` and regular expressions in the ``protocols`` option was + introduced in Symfony 7.4. + ``relativeProtocol`` ~~~~~~~~~~~~~~~~~~~~