ModelBundle/Validator/Constraints/CheckPublishingDateValidator.php
public function validate($value, Constraint $constraint)
    {
        if ($value instanceof AutoPublishableInterface &&
            $value->getPublishDate() instanceof \DateTime &&
            $value->getUnpublishDate() instanceof \DateTime &&
            $value->getPublishDate()->getTimestamp() > $value->getUnpublishDate()->getTimestamp()
        ) {
            $this->context->buildViolation($constraint->message)
                ->atPath('unpublishDate')
                ->addViolation();
        }
    }
public function validate($value, Constraint $constraint)
    {
        if ($value instanceof AutoPublishableInterface &&
            $value->getPublishDate() instanceof \DateTime &&
            $value->getUnpublishDate() instanceof \DateTime &&
            $value->getPublishDate()->getTimestamp() > $value->getUnpublishDate()->getTimestamp()
        ) {
            $this->context->buildViolation($constraint->message)
                ->atPath('unpublishDate')
                ->addViolation();
        }
    }
public function validate ( $ value , Constraint $ constraint ) { if ( $ value instanceof AutoPublishableInterface && $ value -> getPublishDate ( ) instanceof \ DateTime && $ value -> getUnpublishDate ( ) instanceof \ DateTime && $ value -> getPublishDate ( ) -> getTimestamp ( ) > $ value -> getUnpublishDate ( ) -> getTimestamp ( ) ) { $ this -> context -> buildViolation ( $ constraint -> message ) -> atPath ( 'unpublishDate' ) -> addViolation ( ) ; } }
Checks if the passed value is valid.

@param AutoPublishableInterface $value The value that should be validated
@param Constraint               $constraint The constraint for the validation
Checks if the passed value is valid .