diff --git a/reference/constraints/Callback.rst b/reference/constraints/Callback.rst
index 6e419b512d3..7a11cc206de 100644
--- a/reference/constraints/Callback.rst
+++ b/reference/constraints/Callback.rst
@@ -193,7 +193,7 @@ You can then use the following configuration to invoke this validator:
use Symfony\Component\Validator\Constraints as Assert;
/**
- * @Assert\Callback({"AppBundle\MyStaticValidatorClass", "isAuthorValid"})
+ * @Assert\Callback({"Vendor\Package\Validator", "validate"})
*/
class Author
{
@@ -201,36 +201,30 @@ You can then use the following configuration to invoke this validator:
.. code-block:: yaml
- # src/AppBundle/Resources/config/validation.yml
- AppBundle\Entity\Author:
- constraints:
- - Callback:
- methods:
- - [AppBundle\MyStaticValidatorClass, isAuthorValid]
+ # src/AppBundle/Resources/config/validation.yml
+ AppBundle\Entity\Author:
+ constraints:
+ - Callback: [Vendor\Package\Validator, validate]
.. code-block:: xml
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+ Vendor\Package\Validator
+ validate
+
+
+
.. code-block:: php
- // src/AppBundle/Entity/Author.php
+ // src/AppBundle/Entity/Author.php
namespace AppBundle\Entity;
use Symfony\Component\Validator\Mapping\ClassMetadata;
@@ -238,18 +232,12 @@ You can then use the following configuration to invoke this validator:
class Author
{
- public $name;
-
public static function loadValidatorMetadata(ClassMetadata $metadata)
{
- $metadata->addConstraint(new Callback(array(
- 'methods' => array(
- array(
- 'AppBundle\MyStaticValidatorClass',
- 'isAuthorValid',
- ),
- ),
- )));
+ $metadata->addConstraint(new Assert\Callback(array(
+ 'Vendor\Package\Validator',
+ 'validate',
+ )));
}
}
@@ -267,8 +255,9 @@ constructor of the Callback constraint::
// src/AppBundle/Entity/Author.php
namespace AppBundle\Entity;
- use Symfony\Component\Validator\ExecutionContextInterface;
- use AppBundle\Entity\Author;
+ use Symfony\Component\Validator\Context\ExecutionContextInterface;
+ // if you're using the older 2.4 validation API, you'll need this instead
+ // use Symfony\Component\Validator\ExecutionContextInterface;
use Symfony\Component\Validator\Mapping\ClassMetadata;
use Symfony\Component\Validator\Constraints as Assert;