@@ -2,7 +2,7 @@ PasswordStrength
2
2
================
3
3
4
4
Validates that the given password has reached the minimum strength required by
5
- the constraint. The strength is measured using the ` zxcvbn-php `_ library.
5
+ the constraint.
6
6
7
7
========== ===================================================================
8
8
Applies to :ref: `property or method <validation-property-target >`
@@ -77,10 +77,16 @@ Available Options
77
77
``minScore ``
78
78
~~~~~~~~~~~~
79
79
80
- **type **: ``integer `` **default **: ``2 ``
80
+ **type **: ``integer `` **default **: ``PasswordStrength::STRENGTH_REASONABLE `` (`` 2 ``)
81
81
82
- The minimum required strength of the password between ``1 `` and ``4 `` included.
83
- ``1 `` is the weakest and ``4 `` is the strongest.
82
+ The minimum required strength of the password. Available constants are:
83
+ * ``PasswordStrength::STRENGTH_WEAK `` = ``1 ``
84
+ * ``PasswordStrength::STRENGTH_REASONABLE `` = ``2 ``
85
+ * ``PasswordStrength::STRENGTH_STRONG `` = ``3 ``
86
+ * ``PasswordStrength::STRENGTH_VERY_STRONG `` = ``4 ``
87
+
88
+ ``PasswordStrength::STRENGTH_VERY_WEAK `` is available but only used internally
89
+ or by a custom password strength estimator.
84
90
85
91
.. code-block :: php-attributes
86
92
@@ -92,12 +98,12 @@ The minimum required strength of the password between ``1`` and ``4`` included.
92
98
class User
93
99
{
94
100
#[Assert\PasswordStrength([
95
- 'minScore' => 4 , // Very strong password required
101
+ 'minScore' => PasswordStrength::STRENGTH_VERY_STRONG , // Very strong password required
96
102
])]
97
103
protected $rawPassword;
98
104
}
99
105
100
- ``lowStrengthMessage ``
106
+ ``message ``
101
107
~~~~~~~~~~~~~~~~~~~~~~
102
108
103
109
**type **: ``string `` **default **: ``The password strength is too low. Please use a stronger password. ``
@@ -114,54 +120,7 @@ The default message supplied when the password does not reach the minimum requir
114
120
class User
115
121
{
116
122
#[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
-
122
- ``restrictedData ``
123
- ~~~~~~~~~~~~~~~~~~
124
-
125
- **type **: ``string[] `` **default **: ``[] ``
126
-
127
- It is possible to determine if the submitted password contains restricted data
128
- such as the user given/family name,
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']
123
+ 'message' => 'Le mot de passe est trop faible. Veuillez utiliser un mot de passe plus fort.'
141
124
])]
142
125
protected $rawPassword;
143
126
}
144
-
145
- ``restrictedDataMessage ``
146
- ~~~~~~~~~~~~~~~~~~~~~~~~~
147
-
148
- **type **: ``string `` **default **: ``The password contains the following restricted data: {{ wordList }}. ``
149
-
150
- The default message supplied when the password contains at least one restricted data.
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
-
167
- .. _`zxcvbn-php` : https://github.com/bjeavons/zxcvbn-php
0 commit comments