Skip to content

Commit 3a24202

Browse files
committed
minor symfony#16099 [Validator] Cidr constraint tweaks (javiereguiluz)
This PR was merged into the 5.4 branch. Discussion ---------- [Validator] Cidr constraint tweaks Commits ------- 6f70302 [Validator] Cidr constraint tweaks
2 parents 455aa5b + 6f70302 commit 3a24202

File tree

1 file changed

+20
-25
lines changed

1 file changed

+20
-25
lines changed

reference/constraints/Cidr.rst

Lines changed: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ Basic Usage
2323

2424
.. code-block:: php-annotations
2525
26-
// src/Entity/Author.php
26+
// src/Entity/NetworkSettings.php
2727
namespace App\Entity;
2828
2929
use Symfony\Component\Validator\Constraints as Assert;
3030
31-
class Author
31+
class NetworkSettings
3232
{
3333
/**
3434
* @Assert\Cidr
@@ -38,12 +38,12 @@ Basic Usage
3838
3939
.. code-block:: php-attributes
4040
41-
// src/Entity/Author.php
41+
// src/Entity/NetworkSettings.php
4242
namespace App\Entity;
4343
4444
use Symfony\Component\Validator\Constraints as Assert;
4545
46-
class Author
46+
class NetworkSettings
4747
{
4848
#[Assert\Cidr]
4949
protected $cidrNotation;
@@ -52,7 +52,7 @@ Basic Usage
5252
.. code-block:: yaml
5353
5454
# config/validator/validation.yaml
55-
App\Entity\Author:
55+
App\Entity\NetworkSettings:
5656
properties:
5757
cidrNotation:
5858
- Cidr: ~
@@ -65,7 +65,7 @@ Basic Usage
6565
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
6666
xsi:schemaLocation="http://symfony.com/schema/dic/constraint-mapping https://symfony.com/schema/dic/constraint-mapping/constraint-mapping-1.0.xsd">
6767
68-
<class name="App\Entity\Author">
68+
<class name="App\Entity\NetworkSettings">
6969
<property name="cidrNotation">
7070
<constraint name="Cidr"/>
7171
</property>
@@ -74,13 +74,13 @@ Basic Usage
7474
7575
.. code-block:: php
7676
77-
// src/Entity/Author.php
77+
// src/Entity/NetworkSettings.php
7878
namespace App\Entity;
7979
8080
use Symfony\Component\Validator\Constraints as Assert;
8181
use Symfony\Component\Validator\Mapping\ClassMetadata;
8282
83-
class Author
83+
class NetworkSettings
8484
{
8585
public static function loadValidatorMetadata(ClassMetadata $metadata)
8686
{
@@ -103,34 +103,34 @@ Options
103103
This message is shown if the string is not a valid CIDR notation.
104104

105105
``netmaskMin``
106-
~~~~~~~~~~~
106+
~~~~~~~~~~~~~~
107107

108108
**type**: ``integer`` **default**: ``0``
109109

110110
It's a constraint for the lowest value a valid netmask may have.
111111

112112
``netmaskMax``
113-
~~~~~~~~~~~
113+
~~~~~~~~~~~~~~
114114

115-
**type**: ``string`` **default**: ``32 for IPv4 or 128 for IPv6``
115+
**type**: ``string`` **default**: ``32`` for IPv4 or ``128`` for IPv6
116116

117117
It's a constraint for the biggest value a valid netmask may have.
118118

119119
``netmaskRangeViolationMessage``
120-
~~~~~~~~~~~
120+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
121121

122122
**type**: ``string`` **default**: ``The value of the netmask should be between {{ min }} and {{ max }}.``
123123

124-
This message is shown if the value of the CIDR's netmask is bigger then the value of the `max_` or lower than
125-
the value of the `min_`.
124+
This message is shown if the value of the CIDR's netmask is bigger than the
125+
``netmaskMax`` value or lower than the ``netmaskMin`` value.
126126

127127
You can use the following parameters in this message:
128128

129129
=============== ==============================================================
130130
Parameter Description
131131
=============== ==============================================================
132-
``{{ min }}`` The minimum value a CIDR netmask may have
133-
``{{ max }}`` The maximum value a CIDR netmask may have
132+
``{{ min }}`` The minimum value a CIDR netmask may have
133+
``{{ max }}`` The maximum value a CIDR netmask may have
134134
=============== ==============================================================
135135

136136
.. include:: /reference/constraints/_payload-option.rst.inc
@@ -141,15 +141,10 @@ Parameter Description
141141
**type**: ``string`` **default**: ``all``
142142

143143
This determines exactly *how* the CIDR notation is validated and can take one
144-
of a variety of different values:
145-
146-
**All ranges**
144+
of these values:
147145

148-
``4``
149-
Validates for CIDR notations that have an IPv4.
150-
``6``
151-
Validates for CIDR notations that have an IPv6.
152-
``all``
153-
Validates all CIDR formats
146+
* ``4``: validates for CIDR notations that have an IPv4;
147+
* ``6``: validates for CIDR notations that have an IPv6;
148+
* ``all``: validates all CIDR formats.
154149

155150
.. _`CIDR`: https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing

0 commit comments

Comments
 (0)