/** * {@inheritdoc} */ public function assert($items) { if (!isset($items)) { $items = []; } /** @var \Wandu\Validator\Exception\InvalidValueException[] $exceptions */ $exceptions = []; if (!$this->test($items)) { throw $this->createException(); } if ($this->validator) { foreach ($items as $key => $item) { if (!is_int($key)) { $exceptions['.'] = $this->createException(); continue; } try { $this->validator->assert($item); } catch (InvalidValueException $e) { $exceptions[$key] = $e; } } } else { foreach ($items as $key => $item) { if (!is_int($key)) { $exceptions['.'] = $this->createException(); } } } if (count($exceptions)) { throw InvalidValueException::merge($exceptions); } }
/** * {@inheritdoc} */ public function assert($item) { if (!isset($item)) { return; } try { $this->next->assert($item); } catch (InvalidValueException $exception) { return; } $errorType = ValidatorAbstract::ERROR_TYPE; if ($this->next instanceof ValidatorAbstract) { $errorType = $this->next->getErrorType(); } $suffix = isset($this->name) ? '@' . $this->name : ''; throw new InvalidValueException('not.' . $errorType . $suffix); }