Beispiel #1
0
 /**
  * Constructs the validator, initializing the filter.
  *
  * @param ContainerInterface $serviceManager The current service manager instance.
  * @param const $filter The ID of the filter to apply.
  * @param const|array $options Associative array of options or bitwise disjunction of flags. If filter accepts options, flags can be provided in "flags" field of array. For the "callback" filter, callable type should be passed. The callback must accept one argument, the value to be filtered, and return the value after filtering/sanitizing it.
  * @param string $errorMessage The error message to return if the data does not match the expression.
  *
  * @throws \InvalidArgumentException Thrown if the filter is not valid.
  */
 public function __construct(ContainerInterface $serviceManager, $filter = FILTER_DEFAULT, $options = null, $allow_empty_value = false, $errorMessage = null)
 {
     parent::__construct($serviceManager, $errorMessage);
     if (!isset($filter) || !is_int($filter) || empty($filter)) {
         throw new \InvalidArgumentException($this->__('Error! An invalid filter was received.'));
     }
     $this->filter = $filter;
     $this->options = $options;
     $this->allow_empty_value = (bool) $allow_empty_value;
 }