/** * Constructor * * @param array|callable $options */ public function __construct($options = null) { if (is_callable($options)) { $options = ['callback' => $options]; } parent::__construct($options); }
/** * Do our own constructor so we can check for the php-clamav library * @param \Foundation\Form\Element $e the element we are validating * @param integer $sizeInBytes */ public function __construct(\Foundation\Form\Element $element) { if (!extension_loaded('clamav') or !function_exists('cl_scanfile')) { throw new \Foundation\Exception("Virusscan validator requires the php-clamav extension."); } parent::__construct($element); }
/** * Construct * Check the ruleSet * * @param \Foundation\Form\Element $e * @param mixed $ruleSet */ public function __construct(\Foundation\Form\Element $e, $ruleSet) { if (\is_null($ruleSet)) { throw new \Foundation\Exception("The ruleset for SpeicifcString must be set."); } parent::__construct($e, $ruleSet); }
/** * Construct * Check the ruleSet * * @param \Foundation\Form\Element $e * @param mixed $ruleSet */ public function __construct(\Foundation\Form\Element $e, $ruleSet) { if (!\strtotime($ruleSet)) { throw new \Foundation\Exception("The ruleset for DateBefore must be a valid PHP date string"); } parent::__construct($e, $ruleSet); }
/** * Construct * Check the ruleSet * @param \Foundation\Form\Element $e * @param mixed $ruleSet */ public function __construct(\Foundation\Form\Element $e, $ruleSet) { if (!\is_array($ruleSet) or !isset($ruleSet[0]) or !isset($ruleSet[1])) { throw new \Foundation\Exception("The ruleset for NumberRange must be an array with two elements."); } parent::__construct($e, $ruleSet); }
/** * Construct * Check the ruleSet * @param \Foundation\Form\Element $e * @param mixed $ruleSet */ public function __construct(\Foundation\Form\Element $e, $ruleSet) { if (!\is_int($ruleSet)) { throw new \Foundation\Exception("The ruleset for MaximumLength must be an integer"); } parent::__construct($e, $ruleSet); }
/** * @param null $options - expects to find a ['token'] entry in * options, with the token in it */ public function __construct($options = null) { parent::__construct($options); $this->setMessage(self::MsgInvalidToken, 'Unable to authenticate form data. Please refresh and try again.'); $this->token = isset($options['token']) ? $options['token'] : 'missing token'; $this->logger = isset($options['logger']) ? $options['logger'] : null; }
/** * Do our own constructor so we can set the maxfilesize and check the ruleSet * @param \Foundation\Form\Element $e the element we are validating * @param integer $sizeInBytes */ public function __construct(\Foundation\Form\Element $element, $sizeInBytes) { if (!($integer = \intval($sizeInBytes))) { throw new \Foundation\Exception("The ruleset for MaximumFileSize must be an integer. Value: '{$sizeInBytes}'"); } parent::__construct($element, $integer); $this->e->setMaxSize($this->ruleSet); }
/** * Constructs the validator, initializing the regular expression. * * @param \Zikula_ServiceManager $serviceManager The current service manager instance. * @param string $regularExpression The PCRE regular expression against which to validate the data. * @param string $errorMessage The error message to return if the data does not match the expression. * * @throws \InvalidArgumentException Thrown if the regular expression is not valid. */ public function __construct(\Zikula_ServiceManager $serviceManager, $regularExpression, $errorMessage = null) { parent::__construct($serviceManager, $errorMessage); if (!isset($regularExpression) || !is_string($regularExpression) || empty($regularExpression)) { throw new \InvalidArgumentException($this->__('An invalid regular expression was received.')); } $this->regularExpression = $regularExpression; }
/** * Constructs a new validator, initializing the minimum valid value. * * @param \Zikula_ServiceManager $serviceManager The current service manager instance. * @param integer $value The minimum valid value for the field data. * @param string $errorMessage The error message to return if the field data is not valid. * * @throws \InvalidArgumentException If the minimum value specified is not an integer. */ public function __construct(\Zikula_ServiceManager $serviceManager, $value, $errorMessage = null) { parent::__construct($serviceManager, $errorMessage); if (!isset($value) || !is_int($value) || $value < 0) { throw new \InvalidArgumentException($this->__('An invalid integer value was received.')); } $this->value = $value; }
/** * Constructs a new validator, initializing the maximum valid string length value. * * @param \Zikula_ServiceManager $serviceManager The current service manager instance. * @param integer $length The maximum valid length for the string value. * @param string $errorMessage The error message to return if the string data exceeds the maximum length. * * @throws \InvalidArgumentException Thrown if the maximum string length value is not an integer or is less than zero. */ public function __construct(\Zikula_ServiceManager $serviceManager, $length, $errorMessage = null) { parent::__construct($serviceManager, $errorMessage); if (!isset($length) || !is_int($length) || $length < 0) { throw new \InvalidArgumentException($this->__('An invalid string length was received.')); } $this->length = $length; }
/** * @param string $allowedTags */ public function __construct(...$allowedValues) { parent::__construct(); if (!$allowedValues) { throw new \InvalidArgumentException('__construct() expects at least 1 parameter'); } $this->allowedValues = $allowedValues; }
public function __construct($pattern) { if (is_string($pattern)) { $this->setPattern($pattern); parent::__construct(array()); return; } parent::__construct($pattern); }
/** * Constructor for barcodes * * @param array|string $options Options to use */ public function __construct($options = null) { if (!is_array($options) && !$options instanceof \Zend\Config\Config) { $options = array('adapter' => $options); } if (array_key_exists('options', $options)) { $options['options'] = array('options' => $options['options']); } parent::__construct($options); }
/** * @param int|float|string $min * @param int|float|string $max */ public function __construct($min, $max) { parent::__construct(); $this->min = $min; $this->max = $max; if (is_string($min) && !is_numeric($min) && is_string($max) && !is_numeric($max)) { $this->isStringComparison = true; } else { $this->min = (double) $this->min; $this->max = (double) $this->max; } }
/** * Construct * Check the ruleSet * * @param \Foundation\Form\Element $e * @param array $ruleSet */ public function __construct(\Foundation\Form\Element $e, $ruleSet) { if (!\is_array($ruleSet)) { throw new \Foundation\Exception("The ruleset for SpecialObject must be an array"); } if (!\array_key_exists('object', $ruleSet) or !\array_key_exists('method', $ruleSet) or !\array_key_exists('errorMessage', $ruleSet)) { throw new \Foundation\Exception("The ruleset for SpecialObject must be an array with keys 'object', 'method', and 'errorMessage'"); } if (!\method_exists($ruleSet['object'], $ruleSet['method'])) { throw new \Foundation\Exception("The " . get_class($ruleSet['object']) . " object has no method {$ruleSet['method']} as specified in SpecialObject ruleset"); } parent::__construct($e, $ruleSet); }
/** * @param int $min * @param int $max */ public function __construct($min, $max = null) { parent::__construct(); $this->min = (int) $min; if ($this->min < 0) { throw new \InvalidArgumentException('$min must be a positive integer'); } if ($max !== null) { $this->max = (int) $max; if ($this->max < 0) { throw new \InvalidArgumentException('$max must be a positive integer'); } } }
/** * Creates a new validator, initializing the set of valid string values. * * @param \Zikula_ServiceManager $serviceManager The current service manager instance. * @param array $validStrings An array containing valid string values. * @param string $errorMessage The error message to return if the data is not valid. * * @throws \InvalidArgumentException Thrown if the list of valid string values is not valid, or if it contains an invalid value. */ public function __construct(\Zikula_ServiceManager $serviceManager, array $validStrings, $errorMessage = null) { parent::__construct($serviceManager, $errorMessage); if (empty($validStrings)) { throw new \InvalidArgumentException($this->__('An invalid list of valid strings was received.')); } foreach ($validStrings as $validString) { if (isset($validString) && is_string($validString)) { $this->validStrings[$validString] = $validString; } else { throw new \InvalidArgumentException($this->__('An invalid value was received in the list of valid strings.')); } } }
/** * Sets validator options * * @param integer|array|\Zend\Config\Config $options * @return void */ public function __construct($options = array()) { if (!is_array($options)) { $options = func_get_args(); $temp['min'] = array_shift($options); if (!empty($options)) { $temp['max'] = array_shift($options); } if (!empty($options)) { $temp['encoding'] = array_shift($options); } $options = $temp; } parent::__construct($options); }
/** * Instantiates hostname validator for local use * * The following additional option keys are supported: * 'hostnameValidator' => A hostname validator, see Zend\Validator\Hostname * 'allow' => Options for the hostname validator, see Zend\Validator\Hostname::ALLOW_* * 'useMxCheck' => If MX check should be enabled, boolean * 'useDeepMxCheck' => If a deep MX check should be done, boolean * * @param array|\Traversable $options OPTIONAL */ public function __construct($options = array()) { if (!is_array($options)) { $options = func_get_args(); $temp['allow'] = array_shift($options); if (!empty($options)) { $temp['useMxCheck'] = array_shift($options); } if (!empty($options)) { $temp['hostnameValidator'] = array_shift($options); } $options = $temp; } parent::__construct($options); }
/** * Sets validator options * * @param array $options OPTIONAL Options to set, see the manual for all available options * @return void */ public function __construct($options = array()) { if ($options instanceof \Zend\Config\Config) { $options = $options->toArray(); } else { if (!is_array($options)) { $options = func_get_args(); $temp['allowipv6'] = array_shift($options); if (!empty($options)) { $temp['allowipv4'] = array_shift($options); } $options = $temp; } } $options += $this->_options; $this->setOptions($options); parent::__construct(); }
/** * Sets validator options * Accepts the following option keys: * 'min' => scalar, minimum border * 'max' => scalar, maximum border * 'inclusive' => boolean, inclusive border values * * @param array|\Zend\Config\Config $options * @return void */ public function __construct($options = null) { if ($options instanceof \Zend\Config\Config) { $options = $options->toArray(); } else { if (!is_array($options)) { $options = func_get_args(); $temp['min'] = array_shift($options); if (!empty($options)) { $temp['max'] = array_shift($options); } if (!empty($options)) { $temp['inclusive'] = array_shift($options); } $options = $temp; } } if (!array_key_exists('min', $options) || !array_key_exists('max', $options)) { // throw new Exception\InvalidArgumentException("Missing option. 'min' and 'max' has to be given"); } parent::__construct($options); }
/** * @param int|float $max */ public function __construct($max) { parent::__construct(); $this->max = (double) $max; }
/** * Constructor * * @param string|array $type OPTIONAL Type of CCI to allow */ public function __construct($options = array()) { if ($options instanceof \Zend\Config\Config) { $options = $options->toArray(); } else { if (!is_array($options)) { $options = func_get_args(); $temp['type'] = array_shift($options); if (!empty($options)) { $temp['service'] = array_shift($options); } $options = $temp; } } if (!array_key_exists('type', $options)) { $options['type'] = self::ALL; } $this->setType($options['type']); if (array_key_exists('service', $options)) { $this->setService($options['service']); } parent::__construct(); }
/** * @param callable $callback */ public function __construct(callable $callback) { parent::__construct(); $this->callback = $callback; }
public function __construct() { parent::__construct(); }
/** * Constructor * * @param string|array|\Zend\Config\Config $options OPTIONAL */ public function __construct($options = null) { if ($options instanceof \Zend\Config\Config) { $options = $options->toArray(); } if (!is_array($options)) { $options = func_get_args(); $temp = array(); if (!empty($options)) { $temp['type'] = array_shift($options); } $options = $temp; } if (is_array($options)) { if (!array_key_exists('type', $options)) { $detected = 0; $found = false; foreach ($options as $option) { if (in_array($option, $this->_constants)) { $found = true; $detected += array_search($option, $this->_constants); } } if ($found) { $options['type'] = $detected; } } } parent::__construct($options); }
/** * @param string $pattern */ public function __construct($pattern) { parent::__construct(); $this->pattern = (string) $pattern; }
/** * @param bool $allowNegative */ public function __construct($allowNegative = false) { parent::__construct(); $this->allowNegative = (bool) $allowNegative; }
/** * Sets validator options * * @param integer $allow OPTIONAL Set what types of hostname to allow (default ALLOW_DNS) * @param boolean $validateIdn OPTIONAL Set whether IDN domains are validated (default true) * @param boolean $validateTld OPTIONAL Set whether the TLD element of a hostname is validated (default true) * @param \Zend\Validator\Ip $ipValidator OPTIONAL * @return void * @see http://www.iana.org/cctld/specifications-policies-cctlds-01apr02.htm Technical Specifications for ccTLDs */ public function __construct($options = array()) { if (!is_array($options)) { $options = func_get_args(); $temp['allow'] = array_shift($options); if (!empty($options)) { $temp['useIdnCheck'] = array_shift($options); } if (!empty($options)) { $temp['useTldCheck'] = array_shift($options); } if (!empty($options)) { $temp['ipValidator'] = array_shift($options); } $options = $temp; } if (!array_key_exists('ipValidator', $options)) { $options['ipValidator'] = null; } parent::__construct($options); }