Skip to content

Commit 14a9f85

Browse files
Benjamin Laugueuxweaverryan
authored andcommitted
Fixed return value in isValid methods.
1 parent 37470d5 commit 14a9f85

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

cookbook/validation/custom_constraint.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,13 @@ Furthering our example, take a look at the ``ProtocolValidator`` as an example:
6161
{
6262
public function isValid($value, Constraint $constraint)
6363
{
64-
if (in_array($value, $constraint->protocols)) {
64+
if (!in_array($value, $constraint->protocols)) {
6565
$this->setMessage($constraint->message, array('%protocols%' => $constraint->protocols));
6666
67-
return true;
67+
return false;
6868
}
6969
70-
return false;
70+
return true;
7171
}
7272
}
7373
@@ -145,10 +145,10 @@ With this, the validator ``isValid()`` method gets an object as its first argume
145145
// bind error message on foo property
146146
$this->context->addViolationAtSubPath('foo', $constraint->getMessage(), array(), null);
147147

148-
return true;
148+
return false;
149149
}
150150

151-
return false;
151+
return true;
152152
}
153153
}
154154

0 commit comments

Comments
 (0)