コード例 #1
0
 /**
  * @param StringValue\PatternConstraint $constraint
  *
  * @return string
  */
 public function visitPatternConstraint(StringValue\PatternConstraint $constraint)
 {
     return sprintf('The string must match the pattern %s.', var_export($constraint->pattern(), true));
 }
コード例 #2
0
 /**
  * @param StringValue\PatternConstraint $constraint
  *
  * @return Result\ValidationResult
  */
 public function visitPatternConstraint(StringValue\PatternConstraint $constraint)
 {
     $value = $this->currentValue();
     if (!$value instanceof Value\StringValue || preg_match($this->wrapPattern($constraint->pattern()), $value->value())) {
         return $this->createResult();
     }
     return $this->createSingleIssueResult($constraint);
 }