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) { if (!is_callable($arguments)) { throw new \InvalidArgumentException('The argument passed to [callable] must be callable'); } parent::__construct($property, $arguments, $validator); $this->cleaned = $this->data; }
protected function getViolationMessage($context = 'This value') { if (isset($this->message)) { return sprintf($this->message, $context); } else { return parent::getViolationMessage($context); } }
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) { 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; } }
public function getViolationPayload() { return array_merge(parent::getViolationPayload(), array('type' => is_callable($this->arguments) ? 'custom' : $this->arguments)); }