Skip to content

Commit 0e27613

Browse files
committed
Modification as per last design
1 parent ac2049f commit 0e27613

File tree

2 files changed

+13
-56
lines changed

2 files changed

+13
-56
lines changed

reference/configuration/framework.rst

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2594,7 +2594,6 @@ password_strength
25942594

25952595
The :doc:`PasswordStrength </reference/constraints/PasswordStrength>`
25962596
constraint verifies the submitted string entropy is matching the minimum entropy score.
2597-
The strength of the password is measured using the external library `zxcvbn-php`_.
25982597

25992598
.. _reference-validation-email_validation_mode:
26002599

@@ -3697,4 +3696,3 @@ the ``#[WithLogLevel]`` attribute::
36973696
.. _`utf-8 modifier`: https://www.php.net/reference.pcre.pattern.modifiers
36983697
.. _`Link HTTP header`: https://tools.ietf.org/html/rfc5988
36993698
.. _`SMTP session`: https://en.wikipedia.org/wiki/Simple_Mail_Transfer_Protocol#SMTP_transport_example
3700-
.. _`zxcvbn-php`: https://github.com/bjeavons/zxcvbn-php

reference/constraints/PasswordStrength.rst

Lines changed: 13 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ PasswordStrength
22
================
33

44
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.
66

77
========== ===================================================================
88
Applies to :ref:`property or method <validation-property-target>`
@@ -77,10 +77,16 @@ Available Options
7777
``minScore``
7878
~~~~~~~~~~~~
7979

80-
**type**: ``integer`` **default**: ``2``
80+
**type**: ``integer`` **default**: ``PasswordStrength::STRENGTH_REASONABLE`` (``2``)
8181

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.
8490

8591
.. code-block:: php-attributes
8692
@@ -92,12 +98,12 @@ The minimum required strength of the password between ``1`` and ``4`` included.
9298
class User
9399
{
94100
#[Assert\PasswordStrength([
95-
'minScore' => 4, // Very strong password required
101+
'minScore' => PasswordStrength::STRENGTH_VERY_STRONG, // Very strong password required
96102
])]
97103
protected $rawPassword;
98104
}
99105
100-
``lowStrengthMessage``
106+
``message``
101107
~~~~~~~~~~~~~~~~~~~~~~
102108

103109
**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
114120
class User
115121
{
116122
#[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.'
141124
])]
142125
protected $rawPassword;
143126
}
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

Comments
 (0)