public function __construct($property, $arguments, Validator $validator) { parent::__construct($property, $arguments, $validator); if ($arguments !== '*') { $this->format = $arguments; } }
public function __construct($property, $arguments, Validator &$validator) { if (!is_string($arguments)) { throw new \InvalidArgumentException('The argument passed to [rename] must be a string'); } parent::__construct($property, $arguments, $validator); }
public function __construct($property, $arguments, &$validator) { parent::__construct($property, $arguments, $validator); if (!is_array($this->data)) { throw new \InvalidArgumentException("[map] constraint requires an array of input data"); } }
public function __construct($property, $arguments, Validator &$validator) { if (!is_callable($arguments)) { throw new \InvalidArgumentException('The argument passed to [transform] must be callable'); } parent::__construct($property, $arguments, $validator); }
public function __construct($property, $arguments, Validator &$validator) { parent::__construct($property, $arguments, $validator); $this->message = '%s is not a valid %s'; if (is_array($arguments) && !is_callable($arguments)) { if (isset($arguments['message'], $arguments['datatype'])) { $this->message = $arguments['message']; $this->arguments = $arguments = $arguments['datatype']; } else { throw new \InvalidArgumentException("Invalid format for type constraint, must contain a [message] and [datatype]"); } } if (is_callable($arguments)) { $this->handler = $arguments; } else { if (is_string($arguments)) { $handler_class = sprintf(self::DATATYPE_CLASS_MASK, ucfirst($arguments)); if (!class_exists($handler_class)) { throw new \InvalidArgumentException("'type' handler '{$arguments}' is not valid for '{$property}'"); } $this->handler = new $handler_class($this->data); } else { throw new \InvalidArgumentException("Invalid 'type' specified for {$property}"); } } }
public function __construct($property, $arguments, Validator &$validator) { if (!is_callable($arguments)) { throw new \InvalidArgumentException('The argument passed to [callable] must be callable'); } parent::__construct($property, $arguments, $validator); $this->cleaned = $this->data; }
public function __construct($property, $arguments, Validator &$validator) { parent::__construct($property, $arguments, $validator); // inherit the default value from the parent instance of $schema = $validator->getSchemaKey($property); if (array_key_exists('default', $schema)) { $this->inherit_schema['default'] = $schema['default']; } }
public function __construct($property, $arguments, Validator &$validator) { parent::__construct($property, $arguments, $validator); if (is_array($arguments) && !is_callable($arguments)) { if (isset($arguments['message'], $arguments['pattern'])) { $this->message = $arguments['message']; $this->arguments = $arguments['pattern']; } else { throw new \InvalidArgumentException("Invalid format for regex constraint, must contain a [message] and [pattern]"); } } }
public function __construct($property, $arguments, Validator &$validator) { if (!is_array($arguments) || !isset($arguments['property']) || !isset($arguments['value'])) { throw new \InvalidArgumentException("[property_equals] constraint must have a property and value declared"); } if (!isset($arguments['message'])) { $arguments['message'] = '%s failed a property comparison'; } parent::__construct($property, $arguments, $validator); if (!is_object($this->data)) { throw new \InvalidArgumentException("[property_equals] constraint requires an object parameter"); } }
public function __construct($property, $arguments, Validator &$validator) { if (!is_array($arguments) || !isset($arguments['model']) || !isset($arguments['property'])) { throw new \InvalidArgumentException("[{$this->type}] constraint requires a model and property to be declared"); } parent::__construct($property, $arguments, $validator); $this->match_fields = $arguments['property']; if (!is_array($arguments['property'])) { $this->match_fields = array($arguments['property'] => $property); } if (empty($this->match_fields)) { throw new \InvalidArgumentException("[{$this->type}] constraint requires at least one property to match"); } $this->message = isset($arguments['message']) ? $arguments['message'] : null; }
public function __construct($property, $arguments, Validator $validator) { parent::__construct($property, $arguments, $validator); if (is_array($arguments)) { $this->limit = isset($arguments['limit']) ? $arguments['limit'] : null; $comparators = array(self::COMPARATOR_ARRAY, self::COMPARATOR_INT, self::COMPARATOR_STRING, self::COMPARATOR_DATETIME); $this->comparator = isset($arguments['comparator']) && in_array($arguments['comparator'], $comparators) ? $arguments['comparator'] : null; $this->message = isset($arguments['message']) ? $arguments['message'] : null; } else { $this->limit = $arguments; } if ($this->comparator === null) { if (is_array($this->data)) { $this->count = self::COMPARATOR_ARRAY; } elseif (is_numeric($this->data)) { $this->comparator = self::COMPARATOR_INT; } elseif (is_string($this->data)) { $this->comparator = self::COMPARATOR_STRING; } elseif ($this->data instanceof DateTime) { $this->comparator = self::COMPARATOR_DATETIME; } } switch ($this->comparator) { case self::COMPARATOR_ARRAY: $this->count = count($this->data); break; case self::COMPARATOR_STRING: $this->count = strlen($this->data); break; case self::COMPARATOR_DATETIME: $this->count = $this->data; break; default: $this->count = (double) $this->data; } }