/**
  * {@inheritdoc}
  */
 public function guessConstraints(AttributeInterface $attribute)
 {
     $constraints = array();
     if ('email' === $attribute->getValidationRule()) {
         $constraints[] = new Assert\Email();
     }
     return $constraints;
 }
 /**
  * {@inheritdoc}
  */
 public function guessConstraints(AttributeInterface $attribute)
 {
     $constraints = [];
     if ('regexp' === $attribute->getValidationRule() && ($pattern = $attribute->getValidationRegexp())) {
         $constraints[] = new Assert\Regex(['pattern' => $pattern]);
     }
     return $constraints;
 }
 /**
  * {@inheritdoc}
  */
 public function guessConstraints(AttributeInterface $attribute)
 {
     $constraints = [];
     if ('url' === $attribute->getValidationRule()) {
         $constraints[] = new Assert\Url();
     }
     return $constraints;
 }
 function it_does_not_guess_empty_regex(AttributeInterface $attribute)
 {
     $attribute->getValidationRule()->willReturn('regexp')->shouldBeCalled();
     $attribute->getValidationRegexp()->willReturn('')->shouldBeCalled();
     $constraints = $this->guessConstraints($attribute);
     $constraints->shouldReturn([]);
     $attribute->getValidationRegexp()->willReturn(null)->shouldBeCalled();
     $constraints = $this->guessConstraints($attribute);
     $constraints->shouldReturn([]);
 }
 public function it_does_not_guess_email(AttributeInterface $attribute)
 {
     $attribute->getValidationRule()->willReturn('not_email')->shouldBeCalled();
     $constraints = $this->guessConstraints($attribute);
     $constraints->shouldReturn([]);
 }