Skip to content

Commit 339b707

Browse files
committed
[cookbook][validation] Tweaks for #1583 - showing more formats and tweaking language
1 parent 9a08efe commit 339b707

File tree

1 file changed

+26
-8
lines changed

1 file changed

+26
-8
lines changed

cookbook/validation/custom_constraint.rst

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -228,13 +228,31 @@ With this, the validator ``isValid()`` method gets an object as its first argume
228228
}
229229
}
230230

231-
Note that Class Constraint Validator requires annotation is before class declaration::
231+
Note that a class constraint validator is applied to the class itself, and
232+
not to the property:
232233

233-
/**
234-
* @AcmeAssert\ContainsAlphanumeric
235-
*/
236-
class AcmeEntity
237-
{
238-
// ...
239-
}
234+
.. configuration-block::
235+
236+
.. code-block:: yaml
237+
238+
# src/Acme/BlogBundle/Resources/config/validation.yml
239+
Acme\DemoBundle\Entity\AcmeEntity:
240+
constraints:
241+
- ContainsAlphanumeric
242+
243+
.. code-block:: php-annotations
244+
245+
/**
246+
* @AcmeAssert\ContainsAlphanumeric
247+
*/
248+
class AcmeEntity
249+
{
250+
// ...
251+
}
252+
253+
.. code-block:: xml
240254
255+
<!-- src/Acme/BlogBundle/Resources/config/validation.xml -->
256+
<class name="Acme\DemoBundle\Entity\AcmeEntity">
257+
<constraint name="ContainsAlphanumeric" />
258+
</class>

0 commit comments

Comments
 (0)