Skip to content

Commit 7940826

Browse files
committed
minor #17245 [Validator] Tweak validator configuration for attributes/annotations (l-vo)
This PR was merged into the 6.0 branch. Discussion ---------- [Validator] Tweak validator configuration for attributes/annotations <!-- If your pull request fixes a BUG, use the oldest maintained branch that contains the bug (see https://symfony.com/releases for the list of maintained branches). If your pull request documents a NEW FEATURE, use the same Symfony branch where the feature was introduced (and `6.x` for features of unreleased versions). --> Commits ------- 0cc3844 Tweak validator configuration for attributes/annotations
2 parents f91112f + 0cc3844 commit 7940826

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

components/validator/resources.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,15 +106,15 @@ prefixed classes included in doc block comments (``/** ... */``). For example::
106106
}
107107

108108
To enable the annotation loader, call the
109-
:method:`Symfony\\Component\\Validator\\ValidatorBuilder::enableAnnotationMapping` method
110-
and then call ``addDefaultDoctrineAnnotationReader()`` to use Doctrine's
111-
annotation reader::
109+
:method:`Symfony\\Component\\Validator\\ValidatorBuilder::enableAnnotationMapping` method.
110+
If you use annotations instead of attributes, it's also required to call
111+
``addDefaultDoctrineAnnotationReader()`` to use Doctrine's annotation reader::
112112

113113
use Symfony\Component\Validator\Validation;
114114

115115
$validator = Validation::createValidatorBuilder()
116-
->enableAnnotationMapping(true)
117-
->addDefaultDoctrineAnnotationReader()
116+
->enableAnnotationMapping()
117+
->addDefaultDoctrineAnnotationReader() // Only if annotations are used
118118
->getValidator();
119119

120120
To disable the annotation loader after it was enabled, call

0 commit comments

Comments
 (0)