/**
  * @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);
 }
Ejemplo 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;
 }
Ejemplo n.º 3
0
 /**
  * @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);
 }
Ejemplo 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;
 }
Ejemplo 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);
 }