Skip to content

[Validator] Add additional versions (*_NO_PUBLIC, *_ONLY_PRIV & *_ONLY_RES) in IP address & CIDR constraint #19503

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions reference/constraints/Cidr.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 <reference-constraint-ip-version>`.

* ``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
34 changes: 34 additions & 0 deletions reference/constraints/Ip.rst
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ Parameter Description

.. include:: /reference/constraints/_payload-option.rst.inc

.. _reference-constraint-ip-version:

``version``
~~~~~~~~~~~

Expand Down Expand Up @@ -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``
Expand All @@ -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.