Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions reference/constraints/Callback.rst
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ can set "violations" directly on this object and determine to which field
those errors should be attributed::

// ...
use Symfony\Component\Validator\ExecutionContextInterface;
use Symfony\Component\Validator\Context\ExecutionContextInterface;

class Author
{
Expand All @@ -114,12 +114,11 @@ those errors should be attributed::

// check if the name is actually a fake name
if (in_array($this->getFirstName(), $fakeNames)) {
$context->addViolationAt(
'firstName',
'This name sounds totally fake!',
array(),
null
);
$context
->buildViolation('This name sounds totally fake!', array())
->atPath('firstName')
->addViolation()
;
}
}
}
Expand Down