protected function _validate($postArray = [])
{
$emailValidator = new Validator\Email();
$captchaValidator = new Validator\Captcha();
$urlValidator = new Validator\Url();
/* validate post */
$messageArray = [];
if (!$postArray['author']) {
$messageArray[] = $this->_language->get('author_empty');
}
if (!$postArray['email']) {
$messageArray[] = $this->_language->get('email_empty');
} else {
if ($emailValidator->validate($postArray['email']) === Validator\ValidatorInterface::FAILED) {
$messageArray[] = $this->_language->get('email_incorrect');
}
}
if ($postArray['url'] && $urlValidator->validate($postArray['url']) === Validator\ValidatorInterface::FAILED) {
$messageArray[] = $this->_language->get('url_incorrect');
}
if (!$postArray['text']) {
$messageArray[] = $this->_language->get('comment_empty');
}
if (!$postArray['article']) {
$messageArray[] = $this->_language->get('input_incorrect');
}
if (Db::getSetting('captcha') > 0 && $captchaValidator->validate($postArray['task'], $postArray['solution']) === Validator\ValidatorInterface::FAILED) {
$messageArray[] = $this->_language->get('captcha_incorrect');
}
return $messageArray;
}