@@ -82,13 +82,43 @@ Available Options
82
82
The minimum required strength of the password between ``1 `` and ``4 `` included.
83
83
``1 `` is the weakest and ``4 `` is the strongest.
84
84
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
+
85
100
``lowStrengthMessage ``
86
101
~~~~~~~~~~~~~~~~~~~~~~
87
102
88
103
**type **: ``string `` **default **: ``The password strength is too low. Please use a stronger password. ``
89
104
90
105
The default message supplied when the password does not reach the minimum required score.
91
106
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
+
92
122
``restrictedData ``
93
123
~~~~~~~~~~~~~~~~~~
94
124
@@ -97,11 +127,41 @@ The default message supplied when the password does not reach the minimum requir
97
127
It is possible to determine if the submitted password contains restricted data
98
128
such as the user given/family name,
99
129
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
+
100
145
``restrictedDataMessage ``
101
146
~~~~~~~~~~~~~~~~~~~~~~~~~
102
147
103
148
**type **: ``string `` **default **: ``The password contains the following restricted data: {{ wordList }}. ``
104
149
105
150
The default message supplied when the password contains at least one restricted data.
106
151
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
+
107
167
.. _`zxcvbn-php` : https://github.com/bjeavons/zxcvbn-php
0 commit comments