Skip to content

Update Callback.rst #4107

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
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