/** * Indicates whether the constraint is valid * * @param object $value * @param Constraint $constraint */ public function isValid($value, Constraint $constraint) { if ($this->spamDetector->isSpam($value)) { $this->setMessage($constraint->message); return false; } return true; }
/** * Indicates whether the constraint is valid * * @param object $value * @param Constraint $constraint */ public function validate($value, Constraint $constraint) { if ($this->spamDetector->isSpam($value)) { $this->context->addViolation($constraint->message); } }