@@ -4,6 +4,14 @@ UserPassword
|
4 | 4 | .. versionadded:: 2.1
|
5 | 5 | This constraint is new in version 2.1.
|
6 | 6 |
|
| 7 | +.. note:: |
| 8 | + |
| 9 | +Since Symfony 2.2, the `UserPassword*` classes in the |
| 10 | +`Symfony\Component\Security\Core\Validator\Constraint` namespace are |
| 11 | +deprecated and will be removed in Symfony 2.3. Please use the |
| 12 | +`UserPassword*` classes in the |
| 13 | +`Symfony\Component\Security\Core\Validator\Constraints` namespace instead. |
| 14 | + |
7 | 15 | This validates that an input value is equal to the current authenticated
|
8 | 16 | user's password. This is useful in a form where a user can change his password,
|
9 | 17 | but needs to enter his old password for security.
|
@@ -13,15 +21,15 @@ but needs to enter his old password for security.
|
13 | 21 | This should **not** be used to validate a login form, since this is done
|
14 | 22 | automatically by the security system.
|
15 | 23 |
|
16 |
| -+----------------+-------------------------------------------------------------------------------------------+ |
17 |
| -| Applies to | :ref:`property or method<validation-property-target>` | |
18 |
| -+----------------+-------------------------------------------------------------------------------------------+ |
19 |
| -| Options | - `message`_ | |
20 |
| -+----------------+-------------------------------------------------------------------------------------------+ |
21 |
| -| Class | :class:`Symfony\\Component\\Security\\Core\\Validator\\Constraint\\UserPassword` | |
22 |
| -+----------------+-------------------------------------------------------------------------------------------+ |
23 |
| -| Validator | :class:`Symfony\\Component\\Security\\Core\\Validator\\Constraint\\UserPasswordValidator` | |
24 |
| -+----------------+-------------------------------------------------------------------------------------------+ |
| 24 | ++----------------+--------------------------------------------------------------------------------------------+ |
| 25 | +| Applies to | :ref:`property or method<validation-property-target>` | |
| 26 | ++----------------+--------------------------------------------------------------------------------------------+ |
| 27 | +| Options | - `message`_ | |
| 28 | ++----------------+--------------------------------------------------------------------------------------------+ |
| 29 | +| Class | :class:`Symfony\\Component\\Security\\Core\\Validator\\Constraints\\UserPassword` | |
| 30 | ++----------------+--------------------------------------------------------------------------------------------+ |
| 31 | +| Validator | :class:`Symfony\\Component\\Security\\Core\\Validator\\Constraints\\UserPasswordValidator` | |
| 32 | ++----------------+--------------------------------------------------------------------------------------------+ |
25 | 33 |
|
26 | 34 | Basic Usage
|
27 | 35 | -----------
|
@@ -39,16 +47,16 @@ password:
|
39 | 47 | Acme\UserBundle\Form\Model\ChangePassword:
|
40 | 48 | properties:
|
41 | 49 | oldPassword:
|
42 |
| -- Symfony\Component\Security\Core\Validator\Constraint\UserPassword: |
| 50 | +- Symfony\Component\Security\Core\Validator\Constraints\UserPassword: |
43 | 51 | message: "Wrong value for your current password"
|
44 | 52 |
|
45 | 53 | .. code-block:: php-annotations
|
46 | 54 |
|
47 | 55 | // src/Acme/UserBundle/Form/Model/ChangePassword.php
|
48 | 56 | namespace Acme\UserBundle\Form\Model;
|
49 |
| -
|
50 |
| -use Symfony\Component\Security\Core\Validator\Constraint as SecurityAssert; |
51 |
| -
|
| 57 | +
|
| 58 | +use Symfony\Component\Security\Core\Validator\Constraints as SecurityAssert; |
| 59 | +
|
52 | 60 | class ChangePassword
|
53 | 61 | {
|
54 | 62 | /**
|
@@ -63,7 +71,7 @@ password:
|
63 | 71 |
|
64 | 72 | <!-- src/UserBundle/Resources/config/validation.xml -->
|
65 | 73 | <class name="Acme\UserBundle\Form\Model\ChangePassword">
|
66 |
| -<property name="Symfony\Component\Security\Core\Validator\Constraint\UserPassword"> |
| 74 | +<property name="Symfony\Component\Security\Core\Validator\Constraints\UserPassword"> |
67 | 75 | <option name="message">Wrong value for your current password</option>
|
68 | 76 | </property>
|
69 | 77 | </class>
|
@@ -72,10 +80,10 @@ password:
|
72 | 80 |
|
73 | 81 | // src/Acme/UserBundle/Form/Model/ChangePassword.php
|
74 | 82 | namespace Acme\UserBundle\Form\Model;
|
75 |
| -
|
| 83 | +
|
76 | 84 | use Symfony\Component\Validator\Mapping\ClassMetadata;
|
77 |
| -use Symfony\Component\Security\Core\Validator\Constraint as SecurityAssert; |
78 |
| -
|
| 85 | +use Symfony\Component\Security\Core\Validator\Constraints as SecurityAssert; |
| 86 | +
|
79 | 87 | class ChangePassword
|
80 | 88 | {
|
81 | 89 | public static function loadValidatorData(ClassMetadata $metadata)
|
|
0 commit comments