@@ -161,7 +161,7 @@ Constraint Validators with Dependencies
161161If your constraint validator has dependencies, such as a database connection,
162162it will need to be configured as a service in the Dependency Injection
163163Container. This service must include the ``validator.constraint_validator ``
164- tag and an ``alias `` attribute:
164+ tag andmay include an ``alias `` attribute:
165165
166166..configuration-block ::
167167
@@ -189,21 +189,14 @@ tag and an ``alias`` attribute:
189189 ->register('validator.unique.your_validator_name', 'Fully\Qualified\Validator\Class\Name')
190190 ->addTag('validator.constraint_validator', array('alias' => 'alias_name'));
191191
192- Your constraint class should now use this alias to reference the appropriate
193- validator ::
192+ As mentioned above, Symfony will automatically look for a class named after
193+ the constraint, with `` Validator `` appended. You can override this in your constraint class ::
194194
195195 public function validatedBy()
196196 {
197- return 'alias_name';
197+ return 'Fully\Qualified\ConstraintValidator\Class\Name'; // or 'alias_name' if provided
198198 }
199199
200- As mentioned above, Symfony will automatically look for a class named after
201- the constraint, with ``Validator `` appended. If your constraint validator
202- is defined as a service, it's important that you override the
203- ``validatedBy() `` method to return the alias used when defining your service,
204- otherwise Symfony won't use the constraint validator service, and will
205- instantiate the class instead, without any dependencies injected.
206-
207200Class Constraint Validator
208201~~~~~~~~~~~~~~~~~~~~~~~~~~
209202