@@ -86,7 +86,14 @@ configure the locations of these files::
8686The AnnotationLoader
8787--------------------
8888
89- At last, the component provides an
89+ .. deprecated :: 6.4
90+
91+ The :class: `Symfony\\ Component\\ Validator\\ Mapping\\ Loader\\ AnnotationLoader `
92+ is deprecated since Symfony 6.4, use the
93+ :class: `Symfony\\ Component\\ Validator\\ Mapping\\ Loader\\ AttributeLoader `
94+ instead.
95+
96+ The component provides an
9097:class: `Symfony\\ Component\\ Validator\\ Mapping\\ Loader\\ AnnotationLoader ` to get
9198the metadata from the annotations of the class. Annotations are defined as ``@ ``
9299prefixed classes included in doc block comments (``/** ... */ ``). For example::
@@ -121,8 +128,44 @@ If you use annotations instead of attributes, it's also required to call
121128To disable the annotation loader after it was enabled, call
122129:method: `Symfony\\ Component\\ Validator\\ ValidatorBuilder::disableAnnotationMapping `.
123130
131+ .. deprecated :: 6.4
132+
133+ The :method: `Symfony\\ Component\\ Validator\\ ValidatorBuilder::enableAnnotationMapping `
134+ and :method: `Symfony\\ Component\\ Validator\\ ValidatorBuilder::disableAnnotationMapping `
135+ methods are deprecated since Symfony 6.4, use the
136+ :method: `Symfony\\ Component\\ Validator\\ ValidatorBuilder::enableAttributeMapping `
137+ and :method: `Symfony\\ Component\\ Validator\\ ValidatorBuilder::disableAttributeMapping `
138+ methods instead.
139+
124140.. include :: /_includes/_annotation_loader_tip.rst.inc
125141
142+ The AttributeLoader
143+ -------------------
144+
145+ .. versionadded :: 6.4
146+
147+ The :class: `Symfony\\ Component\\ Validator\\ Mapping\\ Loader\\ AttributeLoader `
148+ was introduced in Symfony 6.4.
149+
150+ The component provides an
151+ :class: `Symfony\\ Component\\ Validator\\ Mapping\\ Loader\\ AttributeLoader ` to get
152+ the metadata from the attributes of the class. For example::
153+
154+ use Symfony\Component\Validator\Constraints as Assert;
155+ // ...
156+
157+ class User
158+ {
159+ #[Assert\NotBlank]
160+ protected string $name;
161+ }
162+
163+ To enable the attribute loader, call the
164+ :method: `Symfony\\ Component\\ Validator\\ ValidatorBuilder::enableAttributeMapping ` method.
165+
166+ To disable the annotation loader after it was enabled, call
167+ :method: `Symfony\\ Component\\ Validator\\ ValidatorBuilder::disableAttributeMapping `.
168+
126169Using Multiple Loaders
127170----------------------
128171
@@ -136,8 +179,7 @@ multiple mappings::
136179 use Symfony\Component\Validator\Validation;
137180
138181 $validator = Validation::createValidatorBuilder()
139- ->enableAnnotationMapping(true)
140- ->addDefaultDoctrineAnnotationReader()
182+ ->enableAttributeMapping()
141183 ->addMethodMapping('loadValidatorMetadata')
142184 ->addXmlMapping('validator/validation.xml')
143185 ->getValidator();
0 commit comments