File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -98,10 +98,17 @@ tag and an ``alias`` attribute:
98
98
->addTag('validator.constraint_validator', array('alias' => 'alias_name'))
99
99
;
100
100
101
- Your constraint class may now use this alias to reference the appropriate
101
+ Your constraint class should now use this alias to reference the appropriate
102
102
validator::
103
103
104
104
public function validatedBy()
105
105
{
106
106
return 'alias_name';
107
- }
107
+ }
108
+
109
+ As mentioned above, Symfony2 will automatically look for a class named after
110
+ the constraint, with ``Validator `` appended. If your constraint validator
111
+ is defined as a service, it's important that you override the
112
+ ``validatedBy() `` method to return the alias used when defining your service,
113
+ otherwise Symfony2 won't use the constraint validator service, and will
114
+ instantiate the class instead, without any dependencies injected.
You can’t perform that action at this time.
0 commit comments