/**
  * @inheritdoc
  */
 public function validate($value, Context $context)
 {
     $reference = $context->param(self::PARAM_REFERENCE);
     $context->message_args[self::MESSAGE_ARG_REFERENCE] = $reference;
     $context->message_args[self::MESSAGE_ARG_VALUE_TYPE] = Render::render_type($reference);
     return $this->compare($value, $reference);
 }
Esempio n. 2
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;
 }
 /**
  * @inheritdoc
  */
 public function validate($value, Context $context)
 {
     $min = $context->param(self::PARAM_MIN);
     $max = $context->param(self::PARAM_MAX);
     $context->message_args[self::MESSAGE_ARG_MIN] = $min;
     $context->message_args[self::MESSAGE_ARG_MAX] = $max;
     $context->message_args[self::MESSAGE_ARG_VALUE_TYPE] = Render::render_type($min);
     return $this->compare($value, $min, $max);
 }
Esempio n. 4
0
 /**
  * @inheritdoc
  */
 public function validate($value, Context $context)
 {
     $context->message_args[self::PARAM_TYPE] = $type = $context->param(self::PARAM_TYPE);
     $callable = $this->resolve_callable($this->normalize_type($type));
     if ($callable) {
         return $callable($value);
     }
     return $value instanceof $type;
 }
Esempio n. 5
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);
 }