Skip to content

Commit 5526ed3

Browse files
committed
Examples added
1 parent b5ecb0c commit 5526ed3

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

reference/constraints/PasswordStrength.rst

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,43 @@ Available Options
8282
The minimum required strength of the password between ``1`` and ``4`` included.
8383
``1`` is the weakest and ``4`` is the strongest.
8484

85+
.. code-block:: php-attributes
86+
87+
// src/Entity/User.php
88+
namespace App\Entity;
89+
90+
use Symfony\Component\Validator\Constraints as Assert;
91+
92+
class User
93+
{
94+
#[Assert\PasswordStrength([
95+
'minScore' => 4, // Very strong password required
96+
])]
97+
protected $rawPassword;
98+
}
99+
85100
``lowStrengthMessage``
86101
~~~~~~~~~~~~~~~~~~~~~~
87102

88103
**type**: ``string`` **default**: ``The password strength is too low. Please use a stronger password.``
89104

90105
The default message supplied when the password does not reach the minimum required score.
91106

107+
.. code-block:: php-attributes
108+
109+
// src/Entity/User.php
110+
namespace App\Entity;
111+
112+
use Symfony\Component\Validator\Constraints as Assert;
113+
114+
class User
115+
{
116+
#[Assert\PasswordStrength([
117+
'lowStrengthMessage' => 'Le mot de passe est trop faible. Veuillez utiliser un mot de passe plus fort.'
118+
])]
119+
protected $rawPassword;
120+
}
121+
92122
``restrictedData``
93123
~~~~~~~~~~~~~~~~~~
94124

@@ -97,11 +127,41 @@ The default message supplied when the password does not reach the minimum requir
97127
It is possible to determine if the submitted password contains restricted data
98128
such as the user given/family name,
99129

130+
.. code-block:: php-attributes
131+
132+
// src/Entity/User.php
133+
namespace App\Entity;
134+
135+
use Symfony\Component\Validator\Constraints as Assert;
136+
137+
class User
138+
{
139+
#[Assert\PasswordStrength([
140+
'restrictedData' => ['john', 'doe', 'john.doe', 'john.doe@example.foo', 'BigCorp', 'FooBar App']
141+
])]
142+
protected $rawPassword;
143+
}
144+
100145
``restrictedDataMessage``
101146
~~~~~~~~~~~~~~~~~~~~~~~~~
102147

103148
**type**: ``string`` **default**: ``The password contains the following restricted data: {{ wordList }}.``
104149

105150
The default message supplied when the password contains at least one restricted data.
106151

152+
.. code-block:: php-attributes
153+
154+
// src/Entity/User.php
155+
namespace App\Entity;
156+
157+
use Symfony\Component\Validator\Constraints as Assert;
158+
159+
class User
160+
{
161+
#[Assert\PasswordStrength([
162+
'restrictedDataMessage' => 'Le mot de passe contient des termes qui ne sont pas autorisées : {{ wordList }}.'
163+
])]
164+
protected $rawPassword;
165+
}
166+
107167
.. _`zxcvbn-php`: https://github.com/bjeavons/zxcvbn-php

0 commit comments

Comments
 (0)