Ejemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 public function guessConstraints(AttributeInterface $attribute)
 {
     $constraints = [];
     if ('regexp' === $attribute->getValidationRule() && ($pattern = $attribute->getValidationRegexp())) {
         $constraints[] = new Assert\Regex(['pattern' => $pattern]);
     }
     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([]);
 }