Permalink
Browse files

feature #4456 New validation API usage in Class Constraint Validator …

…(skwi)

This PR was squashed before being merged into the 2.5 branch (closes #4456).

Discussion
----------

New validation API usage in Class Constraint Validator

| Q             | A
| ------------- | ---
| Doc fix?      | yes
| New docs?     | no
| Applies to    | 2.5
| Fixed tickets |

The code in the documentation about Class Constraint Validator was still using the deprecated validation API

Commits
-------

e431fdb New validation API usage in Class Constraint Validator
  • Loading branch information...
wouterj committed Nov 28, 2014
2 parents e96ebd3 + e431fdb commit 33554fcbb06408b222cb0c36af606f113c35afb0
Showing with 8 additions and 0 deletions.
  1. +8 −0 cookbook/validation/custom_constraint.rst
@@ -230,12 +230,20 @@ With this, the validator ``validate()`` method gets an object as its first argum
public function validate($protocol, Constraint $constraint)
{
if ($protocol->getFoo() != $protocol->getBar()) {
// If you're using the new 2.5 validation API (you probably are!)
$this->context->buildViolation($constraint->message)
->atPath('foo')
->addViolation();
// If you're using the old 2.4 validation API
/*
$this->context->addViolationAt(
'foo',
$constraint->message,
array(),
null
);
*/
}
}
}

0 comments on commit 33554fc

Please sign in to comment.