Skip to content

Commit 0b6c6f9

Browse files
Fixing error at Class Constraint Validator
The correct annotation is `@AcmeAssert\ProtocolClass`, not `@AcmeAssert\ProtocolClassValidator`. The other changes are just minor rewordings.
1 parent 4b5ffd4 commit 0b6c6f9

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

validation/custom_constraint.rst

+7-7
Original file line numberDiff line numberDiff line change
@@ -178,15 +178,15 @@ with the necessary ``validator.constraint_validator``. This means you can
178178
Class Constraint Validator
179179
~~~~~~~~~~~~~~~~~~~~~~~~~~
180180

181-
Beside validating a class property, a constraint can have a class scope by
182-
providing a target in its ``Constraint`` class::
181+
Besides validating a single property, a constraint can have an entire class
182+
as its scope. Just add this to the ``Constraint`` class::
183183

184184
public function getTargets()
185185
{
186186
return self::CLASS_CONSTRAINT;
187187
}
188188

189-
With this, the validator ``validate()`` method gets an object as its first argument::
189+
With this, the validator's ``validate()`` method gets an object as its first argument::
190190

191191
class ProtocolClassValidator extends ConstraintValidator
192192
{
@@ -206,15 +206,15 @@ With this, the validator ``validate()`` method gets an object as its first argum
206206
associated to. Use any :doc:`valid PropertyAccess syntax </components/property_access>`
207207
to define that property.
208208

209-
Note that a class constraint validator is applied to the class itself, and
209+
A class constraint validator is applied to the class itself, and
210210
not to the property:
211211

212212
.. configuration-block::
213213

214214
.. code-block:: php-annotations
215215
216216
/**
217-
* @AcmeAssert\ProtocolClassValidator
217+
* @AcmeAssert\ProtocolClass
218218
*/
219219
class AcmeEntity
220220
{
@@ -226,11 +226,11 @@ not to the property:
226226
# src/AppBundle/Resources/config/validation.yml
227227
AppBundle\Entity\AcmeEntity:
228228
constraints:
229-
- AppBundle\Validator\Constraints\ProtocolClassValidator: ~
229+
- AppBundle\Validator\Constraints\ProtocolClass: ~
230230
231231
.. code-block:: xml
232232
233233
<!-- src/AppBundle/Resources/config/validation.xml -->
234234
<class name="AppBundle\Entity\AcmeEntity">
235-
<constraint name="AppBundle\Validator\Constraints\ProtocolClassValidator"/>
235+
<constraint name="AppBundle\Validator\Constraints\ProtocolClass"/>
236236
</class>

0 commit comments

Comments
 (0)