/** * Validates this form * @return null * @throws zibo\library\validation\exception\ValidationException when one of the fields or the form itself is not validated */ public function validate() { try { parent::validate(); $validationException = new ValidationException(); } catch (ValidationException $exception) { $validationException = $exception; } foreach ($this->hooks as $hook) { try { $hook->onProfileFormValidate(); } catch (ValidationException $exception) { $allErrors = $exception->getAllErrors(); foreach ($allErrors as $field => $errors) { $validationException->addErrors($field, $errors); } } } if ($validationException->hasErrors()) { throw $validationException; } }