/** * Sets the options for this validator * * @param array|Traversable $options * @throws Exception\InvalidArgumentException If there is any kind of IP allowed or $options is not an array or Traversable. * @return AbstractValidator */ public function setOptions($options = []) { parent::setOptions($options); if (!$this->options['allowipv4'] && !$this->options['allowipv6'] && !$this->options['allowipvfuture']) { throw new Exception\InvalidArgumentException('Nothing to validate. Check your options'); } return $this; }
/** * {@inheritdoc} */ public function setOptions($options = []) { // Prepare options if ($options instanceof \Traversable) { $options = ArrayUtils::iteratorToArray($options); } $options = array_combine(array_map(function ($key) { return str_replace(' ', '', ucwords(str_replace('_', ' ', $key))); }, array_keys($options)), array_values($options)); // parent::setOptions($options); }
/** * Sets the options for this validator * * @param array|Traversable $options * @return \Zend\Validator\Ip */ public function setOptions($options = array()) { if (!is_array($options) && !$options instanceof Traversable) { throw new Exception\InvalidArgumentException(__METHOD__ . ' expects an array or Traversable'); } if (array_key_exists('allowipv6', $options)) { $this->_options['allowipv6'] = (bool) $options['allowipv6']; } if (array_key_exists('allowipv4', $options)) { $this->_options['allowipv4'] = (bool) $options['allowipv4']; } if (!$this->_options['allowipv4'] && !$this->_options['allowipv6']) { throw new Exception\InvalidArgumentException('Nothing to validate. Check your options'); } return parent::setOptions($options); }