/**
  * Checks if the passed value is valid.
  *
  * @param mixed      $value      The value that should be validated
  * @param Constraint $constraint The constraint for the validation
  *
  * @api
  */
 public function validate($value, Constraint $constraint)
 {
     /** @var SocialSecurityNumber $constraint */
     $validator = new Validator();
     try {
         if (!$validator->validate($value, $constraint->countryCode)) {
             $this->context->addViolation($constraint->message, array('%string%' => $value));
         }
     } catch (\Exception $e) {
     }
 }
Beispiel #2
0
 /**
  * @expectedException \Exception
  */
 public function testInvalidCountry()
 {
     $validator = new Validator();
     $validator->validate('whatever', 'us');
 }