From d22ad24c30b338244566646729cfbaf58bfbb80e Mon Sep 17 00:00:00 2001 From: Antoine Lamirault Date: Sun, 4 Feb 2024 21:33:12 +0100 Subject: [PATCH] [Validator] Add additional versions (*_NO_PUBLIC, *_ONLY_PRIV & *_ONLY_RES) in IP address & CIDR constraint --- reference/constraints/Cidr.rst | 8 ++++---- reference/constraints/Ip.rst | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 4 deletions(-) diff --git a/reference/constraints/Cidr.rst b/reference/constraints/Cidr.rst index d7bc9e6b4a0..24abeb57338 100644 --- a/reference/constraints/Cidr.rst +++ b/reference/constraints/Cidr.rst @@ -124,10 +124,10 @@ Parameter Description **type**: ``string`` **default**: ``all`` This determines exactly *how* the CIDR notation is validated and can take one -of these values: +of :ref:`IP version ranges `. -* ``4``: validates for CIDR notations that have an IPv4; -* ``6``: validates for CIDR notations that have an IPv6; -* ``all``: validates all CIDR formats. +.. versionadded:: 7.1 + + The support of all IP version ranges was introduced in Symfony 7.1. .. _`CIDR`: https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing diff --git a/reference/constraints/Ip.rst b/reference/constraints/Ip.rst index 2f05f677601..9168d463f77 100644 --- a/reference/constraints/Ip.rst +++ b/reference/constraints/Ip.rst @@ -97,6 +97,8 @@ Parameter Description .. include:: /reference/constraints/_payload-option.rst.inc +.. _reference-constraint-ip-version: + ``version`` ~~~~~~~~~~~ @@ -132,6 +134,33 @@ of a variety of different values: ``all_no_res`` Validates for all IP formats but without reserved IP ranges +**No public ranges** + +``4_no_public`` + Validates for IPv4 but without public IP ranges +``6_no_public`` + Validates for IPv6 but without public IP ranges +``all_no_public`` + Validates for all IP formats but without public IP range + +**Only private ranges** + +``4_private`` + Validates for IPv4 but without public and reserved ranges +``6_private`` + Validates for IPv6 but without public and reserved ranges +``all_private`` + Validates for all IP formats but without public and reserved ranges + +**Only reserved ranges** + +``4_reserved`` + Validates for IPv4 but without private and public ranges +``6_reserved`` + Validates for IPv6 but without private and public ranges +``all_reserved`` + Validates for all IP formats but without private and public ranges + **Only public ranges** ``4_public`` @@ -140,3 +169,8 @@ of a variety of different values: Validates for IPv6 but without private and reserved ranges ``all_public`` Validates for all IP formats but without private and reserved ranges + +.. versionadded:: 7.1 + + The ``*_no_public``, ``*_reserved`` and ``*_public`` ranges were introduced + in Symfony 7.1.