@@ -21,7 +21,7 @@ the ``message`` and ``protocols`` properties:
21
21
*/
22
22
class Protocol extends Constraint
23
23
{
24
- public $message = 'This value is not a valid protocol';
24
+ public $message = 'The value "%protocol%" is not a valid protocol';
25
25
public $protocols = array('http', 'https', 'ftp', 'ftps');
26
26
}
27
27
@@ -62,7 +62,7 @@ Furthering our example, take a look at the ``ProtocolValidator`` as an example:
62
62
public function isValid($value, Constraint $constraint)
63
63
{
64
64
if (!in_array($value, $constraint->protocols)) {
65
- $this->setMessage($constraint->message, array('%protocols %' => $constraint->protocols ));
65
+ $this->setMessage($constraint->message, array('%protocol %' => $value ));
66
66
67
67
return false;
68
68
}
@@ -142,8 +142,9 @@ With this, the validator ``isValid()`` method gets an object as its first argume
142
142
{
143
143
if ($protocol->getFoo() != $protocol->getBar()) {
144
144
145
- // bind error message on foo property
146
- $this->context->addViolationAtSubPath('foo', $constraint->getMessage(), array(), null);
145
+ $propertyPath = $this->context->getPropertyPath() . 'foo';
146
+ $this->context->setPropertyPath($propertyPath);
147
+ $this->context->addViolation($constraint->getMessage(), array(), null);
147
148
148
149
return false;
149
150
}
0 commit comments