/** * {@inheritdoc} */ public function validate($value, Constraint $constraint) { if ($value instanceof \Model && !$value->isValid()) { // Let the parent class handle the invalid model $value = null; } parent::validate($value, $constraint); }
/** * @param string $value * @param \Symfony\Component\Validator\Constraint $constraint * * @throws \Symfony\Component\Validator\Exception\UnexpectedTypeException * * @return void */ public function validate($value, Constraint $constraint) { if (!$constraint instanceof CategoryFieldNotBlank) { throw new UnexpectedTypeException($constraint, __NAMESPACE__ . '\\Category'); } if ($this->shouldValidateCategory($constraint)) { parent::validate($value, $constraint); } }
/** * Trim value before passing to NotBlankValidator * * {@inheritdoc} * * @param string $value Value to validate * @param Constraint $constraint Constraint object */ public function validate($value, Constraint $constraint) { $value = trim($value); parent::validate($value, $constraint); }
/** * Perform NotBlank validation only if the 'active' property has been set to true. * * @param mixed $value * @param Constraint $constraint */ public function validate($value, Constraint $constraint) { if ($this->context->getObject()->isActive()) { parent::validate($value, $constraint); } }
/** * @param HtmlNotBlank $constraint * * {@inheritdoc} */ public function validate($value, Constraint $constraint) { parent::validate(strip_tags($value), $constraint); }