Skip to content

Instantly share code, notes, and snippets.

@raulfraile
Last active December 18, 2015 18:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save raulfraile/5827468 to your computer and use it in GitHub Desktop.
Save raulfraile/5827468 to your computer and use it in GitHub Desktop.
<?php
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\ConstraintValidator;
class ContainsJavaValidator extends ConstraintValidator
{
public function validate($value, Constraint $constraint)
{
if (stripos($value, 'java') !== false) {
$this->context->addViolation($constraint->message, array('%string%' => $value));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment