public function hasErrors(Result $errors) { if ($errors->isValid()) { return FALSE; } foreach ($this->fields as $field) { if ($errors->hasErrors($field->getName())) { return TRUE; } } return FALSE; }
/** * Takes a model validation result object and checks for errors on the * posted 'ee_fv_field' and returns an error message, or success message * but only if the request was an AJAX request. * * @param EllisLab\ExpressionEngine\Service\Validation\Result $result A model validation result * @return array|NULL NULL if the request was not via AJAX, otherwise an * an array with an error message or a success notification. */ protected function ajaxValidation(ValidationResult $result) { if (ee()->input->is_ajax_request()) { $field = ee()->input->post('ee_fv_field'); if ($result->hasErrors($field)) { return array('error' => $result->renderError($field)); } else { return array('success'); } } return NULL; }