Skip to content

Commit 998c26c

Browse files
committed
minor #18760 [Validator] clean up more legacy annotation config (xabbuh)
This PR was merged into the 7.0 branch. Discussion ---------- [Validator] clean up more legacy annotation config Commits ------- bae9602 clean up more legacy annotation config
2 parents d69e7c1 + bae9602 commit 998c26c

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

components/validator/resources.rst

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -88,30 +88,24 @@ The AnnotationLoader
8888

8989
At last, the component provides an
9090
:class:`Symfony\\Component\\Validator\\Mapping\\Loader\\AnnotationLoader` to get
91-
the metadata from the annotations of the class. Annotations are defined as ``@``
92-
prefixed classes included in doc block comments (``/** ... */``). For example::
91+
the metadata from the attributes of the class::
9392

9493
use Symfony\Component\Validator\Constraints as Assert;
9594
// ...
9695

9796
class User
9897
{
99-
/**
100-
* @Assert\NotBlank
101-
*/
98+
#[Assert\NotBlank]
10299
protected string $name;
103100
}
104101

105102
To enable the annotation loader, call the
106-
:method:`Symfony\\Component\\Validator\\ValidatorBuilder::enableAnnotationMapping` method.
107-
If you use annotations instead of attributes, it's also required to call
108-
``addDefaultDoctrineAnnotationReader()`` to use Doctrine's annotation reader::
103+
:method:`Symfony\\Component\\Validator\\ValidatorBuilder::enableAnnotationMapping` method::
109104

110105
use Symfony\Component\Validator\Validation;
111106

112107
$validator = Validation::createValidatorBuilder()
113108
->enableAnnotationMapping()
114-
->addDefaultDoctrineAnnotationReader() // add this only when using annotations
115109
->getValidator();
116110

117111
To disable the annotation loader after it was enabled, call
@@ -133,7 +127,6 @@ multiple mappings::
133127

134128
$validator = Validation::createValidatorBuilder()
135129
->enableAnnotationMapping(true)
136-
->addDefaultDoctrineAnnotationReader()
137130
->addMethodMapping('loadValidatorMetadata')
138131
->addXmlMapping('validator/validation.xml')
139132
->getValidator();

0 commit comments

Comments
 (0)