Skip to content

Commit ce6b4b7

Browse files
committed
fixup! Use PHP attributes when creating custom validation constraints
1 parent 2f2736b commit ce6b4b7

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

validation/custom_constraint.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ First you need to create a Constraint class and extend :class:`Symfony\\Componen
3838
3939
use Symfony\Component\Validator\Constraint;
4040
41-
#[\Attribute()]
41+
#[\Attribute]
4242
class ContainsAlphanumeric extends Constraint
4343
{
4444
public $message = 'The string "{{ string }}" contains an illegal character: it can only contain letters or numbers.';
@@ -157,8 +157,8 @@ You can use custom validators like the ones provided by Symfony itself:
157157
{
158158
// ...
159159
160-
#[Assert\NotBlank()]
161-
#[AcmeAssert\ContainsAlphanumeric()]
160+
#[Assert\NotBlank]
161+
#[AcmeAssert\ContainsAlphanumeric]
162162
protected $name;
163163
164164
// ...
@@ -279,7 +279,7 @@ not to the property:
279279
280280
.. code-block:: php-attributes
281281
282-
#[AcmeAssert\ProtocolClass()]
282+
#[AcmeAssert\ProtocolClass]
283283
class AcmeEntity
284284
{
285285
// ...

0 commit comments

Comments
 (0)