PasswordMD5HashValidator.php (599B)
1 <?php 2 3 namespace PartKeepr\AuthBundle\Validator\Constraints; 4 5 use Symfony\Component\Validator\Constraint; 6 use Symfony\Component\Validator\ConstraintValidator; 7 8 class PasswordMD5HashValidator extends ConstraintValidator 9 { 10 public function validate($value, Constraint $constraint) 11 { 12 if (!preg_match('/^[a-f0-9]{32}$/', $value, $matches)) { 13 // If you're using the new 2.5 validation API (you probably are!) 14 $this->context->buildViolation($constraint->message) 15 ->setParameter('%string%', $value) 16 ->addViolation(); 17 } 18 } 19 }