Skip to content

[Validator] Updated: Ip & Cidr constraints documentation #19117

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

Closed
wants to merge 2 commits into from
Closed
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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ We love contributors! For more information on how you can contribute, please rea
the [Symfony Docs Contributing Guide](https://symfony.com/doc/current/contributing/documentation/overview.html).

> [!IMPORTANT]
> Use `5.4` branch as the base of your pull requests, unless you are documenting a
> feature that was introduced *after* Symfony 5.4 (e.g. in Symfony 6.3).
> Use `6.4` branch as the base of your pull requests, unless you are documenting a
> feature that was introduced *after* Symfony 6.4 (e.g. in Symfony 6.3).

Build Documentation Locally
---------------------------
Expand Down
10 changes: 4 additions & 6 deletions reference/constraints/Cidr.rst
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ It's a constraint for the lowest value a valid netmask may have.

**type**: ``string`` **default**: ``32`` for IPv4 or ``128`` for IPv6

It's a constraint for the biggest value a valid netmask may have.
It's a constraint for the biggest value a valid netmask may have. The value will be overwritten to `32` if it is greater than `32` and a `V4` is validated.

``netmaskRangeViolationMessage``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand All @@ -116,6 +116,8 @@ Parameter Description
``{{ max }}`` The maximum value a CIDR netmask may have
=============== ==============================================================

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

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

``version``
Expand All @@ -124,10 +126,6 @@ Parameter Description
**type**: ``string`` **default**: ``all``

This determines exactly *how* the CIDR notation is validated and can take one
of these values:

* ``4``: validates for CIDR notations that have an IPv4;
* ``6``: validates for CIDR notations that have an IPv6;
* ``all``: validates all CIDR formats.
of the values available for `Ip` constraint.

.. _`CIDR`: https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing
51 changes: 39 additions & 12 deletions reference/constraints/Ip.rst
Original file line number Diff line number Diff line change
Expand Up @@ -107,36 +107,63 @@ of a variety of different values:

**All ranges**

``4``
``4` (`Assert\Ip::V4`)`
Validates for IPv4 addresses
``6``
``6` (`Assert\Ip::V6`)`
Validates for IPv6 addresses
``all``
``all` (`Assert\Ip::ALL`)`
Validates all IP formats

**No public ranges**

``4_no_public` (`Assert\Ip::V4_NO_PUBLIC`)`
Validates for IPv4 but without public IP ranges
``6_no_public` (`Assert\Ip::V6_NO_PUBLIC`)`
Validates for IPv6 but without public IP ranges
``all_no_public` (`Assert\Ip::ALL_NO_PUBLIC`)`
Validates for all IP formats but without public IP ranges

**No private ranges**

``4_no_priv``
``4_no_private` (`Assert\Ip::V4_NO_PRIVATE`)`
Validates for IPv4 but without private IP ranges
``6_no_priv``
``6_no_private` (`Assert\Ip::V6_NO_PRIVATE`)`
Validates for IPv6 but without private IP ranges
``all_no_priv``
``all_no_private` (`Assert\Ip::ALL_NO_PRIVATE`)`
Validates for all IP formats but without private IP ranges

**No reserved ranges**

``4_no_res``
``4_no_reserved` (`Assert\Ip::V4_NO_RESERVED`)`
Validates for IPv4 but without reserved IP ranges
``6_no_res``
``6_no_reserved` (`Assert\Ip::V6_NO_RESERVED`)`
Validates for IPv6 but without reserved IP ranges
``all_no_res``
``all_no_reserved` (`Assert\Ip::ALL_NO_RESERVED`)`
Validates for all IP formats but without reserved IP ranges

**Only public ranges**

``4_public``
``4_public` (`Assert\Ip::V4_ONLY_PUBLIC`)`
Validates for IPv4 but without private and reserved ranges
``6_public``
``6_public` (`Assert\Ip::V6_ONLY_PUBLIC`)`
Validates for IPv6 but without private and reserved ranges
``all_public``
``all_public` (`Assert\Ip::ALL_ONLY_PUBLIC`)`
Validates for all IP formats but without private and reserved ranges

**Only private ranges**

``4_private` (`Assert\Ip::V4_ONLY_PRIVATE`)`
Validates for IPv4 but without public and reserved ranges
``6_private` (`Assert\Ip::V6_ONLY_PRIVATE`)`
Validates for IPv6 but without public and reserved ranges
``all_private` (`Assert\Ip::ALL_ONLY_PRIVATE`)`
Validates for all IP formats but without public and reserved ranges

**Only reserved ranges**

``4_reserved` (`Assert\Ip::V4_ONLY_RESERVED`)`
Validates for IPv4 but without public and private ranges
``6_reserved` (`Assert\Ip::V6_ONLY_RESERVED`)`
Validates for IPv6 but without public and private ranges
``all_reserved` (`Assert\Ip::ALL_ONLY_RESERVED`)`
Validates for all IP formats but without public and private ranges