Exemple #1
0
 /**
  * @inheritdoc
  */
 public function validate($value, Context $context)
 {
     $pattern = $context->param(self::PARAM_PATTERN);
     $not_match = $context->option(self::OPTION_NOT_MATCH);
     $context->message_args[self::MESSAGE_ARG_PATTERN] = $pattern;
     $result = preg_match($pattern, $value);
     return $not_match ? $result !== 1 : $result === 1;
 }
Exemple #2
0
 /**
  * Adds an error to the collection.
  *
  * @param Context $context
  */
 protected function error(Context $context)
 {
     $context->errors[$context->attribute][] = $this->create_message($context->option(self::OPTION_MESSAGE) ?: $context->message, $context->message_args);
 }