Skip to content

Commit b1e586b

Browse files
committed
Adding the payload parameter to the callback examples
1 parent 1f1306a commit b1e586b

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

reference/constraints/Callback.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ Configuration
4646
/**
4747
* @Assert\Callback
4848
*/
49-
public function validate(ExecutionContextInterface $context)
49+
public function validate(ExecutionContextInterface $context, $payload)
5050
{
5151
// ...
5252
}
@@ -103,7 +103,7 @@ field those errors should be attributed::
103103
// ...
104104
private $firstName;
105105

106-
public function validate(ExecutionContextInterface $context)
106+
public function validate(ExecutionContextInterface $context, $payload)
107107
{
108108
// somehow you have an array of "fake names"
109109
$fakeNames = array(/* ... */);
@@ -123,7 +123,7 @@ Static Callbacks
123123
You can also use the constraint with static methods. Since static methods don't
124124
have access to the object instance, they receive the object as the first argument::
125125

126-
public static function validate($object, ExecutionContextInterface $context)
126+
public static function validate($object, ExecutionContextInterface $context, $payload)
127127
{
128128
// somehow you have an array of "fake names"
129129
$fakeNames = array(/* ... */);
@@ -151,7 +151,7 @@ Suppose your validation function is ``Vendor\Package\Validator::validate()``::
151151

152152
class Validator
153153
{
154-
public static function validate($object, ExecutionContextInterface $context)
154+
public static function validate($object, ExecutionContextInterface $context, $payload)
155155
{
156156
// ...
157157
}
@@ -240,7 +240,7 @@ constructor of the Callback constraint::
240240
{
241241
public static function loadValidatorMetadata(ClassMetadata $metadata)
242242
{
243-
$callback = function ($object, ExecutionContextInterface $context) {
243+
$callback = function ($object, ExecutionContextInterface $context, $payload) {
244244
// ...
245245
};
246246

0 commit comments

Comments
 (0)