Static helper function that formats form errors

@return string[]
345665
public static function formatValidationErrors($errors)
    {
        $msg = array();
        foreach ($errors as $i) {
            if (!is_array($i)) {
                throw new Kwf_Exception('Form errors must be of type array');
            }
            $name = '';
            if (isset($i['field'])) {
                $name = $i['field']->getFieldLabel();
                if (!$name) $name = $i['field']->getName();
            }
            if (isset($i['message'])) {
                $i['messages'] = array($i['message']);
            }
            foreach ($i['messages'] as $m) {
                $msg[] = ($name ? ($name.': ') : '').Kwf_Util_HtmlSpecialChars::filter($m);
            }
        }
        return $msg;
    }
191967
private function formatDateTimeErrors(array $errors)
    {
        $formattedErrors = [];

        foreach ($errors as $pos => $message) {
            $formattedErrors[] = sprintf('at position %d: %s', $pos, $message);
        }

        return $formattedErrors;
    }
11917
public function getErrors(): array
    {
        if ($this->errors === null) {
            $this->errors = $this->fetchErrors();
        }

        //Making sure that each error point to proper input origin
        return $this->mapper->mapErrors($this, $this->validateNested($this->errors));
    }
319711
public function errorInfo() {
		$error = $this->getError();
		if($error !== false) {
			return array('HY000', $error['code'], $error['message']);
		}
		return array(PDO::ERR_NONE, null, null);
	}
370386
protected function getNonBreakingErrors()
    {
        $errors = [];

        $unknownRelations = $this->unknownRelationsFromRequest();
        if (count($unknownRelations) > 0) {
            $errors[] = [
                'code' => static::ERROR_UNKNOWN_LINKED_RESOURCES,
                'title' => 'Unknown included resource requested',
                'description' => 'These included resources are not available: ' . implode(', ', $unknownRelations)
            ];
        }

        return $errors;
    }
1285359
public function errorsOf($value): array
    {
        if ($this->belowMinBorder($value)) {
            return $this->minBorderViolation();
        }

        if ($this->aboveMaxBorder($value)) {
            return $this->maxBorderViolation();
        }

        return [];
    }
1076658
public function getErrors()
    {
        if (!$this->validator || !$this->validator instanceof Validator) {
            throw new \InvalidArgumentException(
                sprintf(
                    'Form %s was not validated. To validate it, call "isValid" method before retrieving the errors',
                    get_class($this)
                )
            );
        }

        return $this->validator->getMessageBag()->getMessages();
    }
586750
public function get_error(){
    if ( $this->error ){
      return [
        'code' => $this->error,
        'text' => $this->class_cfg['errors'][$this->error]
      ];
    }
    return false;
  }
1137392
public function errorInfo()
    {
        $e = oci_error($this->sth);

        if (is_array($e)) {
            return [
                'HY000',
                $e['code'],
                $e['message'],
            ];
        }

        return ['00000', null, null];
    }
668385
public function getInvalidOrMissingErrors()
    {
        $all = $this->invalidAttribs + $this->missingAttribs;
        return array_combine(
            array_keys($all),
            array_map(function ($ref) {
                return $ref['error'];
            }, array_values($all))
        );
    }
718196
protected function getNormalizedFormFieldErrors()
    {
        $viewBags = session('errors');

        if ( ! ($viewBags instanceof ViewErrorBag) || ! count($viewBags)) {
            return [];
        }

        /** @var MessageBag $errorBag */
        $errorBag = head($viewBags->getBags());

        if ( ! $errorBag->any()) {
            return [];
        }

        $normalized = [];

        foreach ($errorBag->toArray() as $field => $errors) {
            array_set($normalized, $field, $errors);
        }

        return $normalized;
    }
1048407
public function getErrorMessages(FormInterface $form, bool $useLabels = false, array $errors = []):array
    {
        if ($form->count() > 0) {
            foreach ($form->all() as $child) {
                if (!$child->isValid()) {
                    $errors = $this->getErrorMessages($child, $useLabels, $errors);
                }
            }
        }

        foreach ($form->getErrors() as $error) {
            if ($useLabels) {
                $fieldNameData = $this->getErrorFormLabel($form);
            } else {
                $fieldNameData = $this->getErrorFormId($form);
            }

            $fieldName = $fieldNameData;

            if ($useLabels) {
                /**
                 * @ignore
                 */
                $fieldName = $this->translator->trans($fieldNameData['label'], array(), $fieldNameData['domain']);
            }

            $errors[$fieldName] = $error->getMessage();
        }

        return $errors;
    }
752134
protected function errorsToArray(): array
    {
        $errors = [];

        foreach ($this->errors as $error)
        {
            $errors[] = $error->toArray();
        }

        return $errors;
    }
203694
protected function getDefaultErrorMessages()
    {
        $messages = [
            'message' => '{attribute} is invalid.',
            'messageDNS' => 'DNS record corresponding to {attribute} not found.',
            'messageLabelNumberMin' =>
                '{attribute} should consist of at least {labelNumberMin, number} labels separated by ' .
                '{labelNumberMin, plural, =2{dot} other{dots}}.',
            'messageLabelTooShort' => 'Each label of {attribute} should contain at least 1 character.',
            'messageNotString' => '{attribute} must be a string.',
            'messageTooShort' => '{attribute} should contain at least 1 character.',
        ];
        if ($this->enableIDN) {
            $messages['messageLabelStartEnd'] =
                'Each label of {attribute} should start and end with letter or number.' .
                ' The rightmost label of {attribute} should start with letter.';
            $messages['messageLabelTooLong'] = 'Label of {attribute} is too long.';
            $messages['messageTooLong'] = '{attribute} is too long.';
            if ($this->allowUnderscore) {
                $messages['messageInvalidCharacter'] =
                    'Each label of {attribute} can consist of only letters, numbers, hyphens and underscores.';
            } else {
                $messages['messageInvalidCharacter'] =
                    'Each label of {attribute} can consist of only letters, numbers and hyphens.';
            }
        } else {
            $messages['messageLabelStartEnd'] =
                'Each label of {attribute} should start and end with latin letter or number.' .
                ' The rightmost label of {attribute} should start with latin letter.';
            $messages['messageLabelTooLong'] = 'Each label of {attribute} should contain at most 63 characters.';
            $messages['messageTooLong'] = '{attribute} should contain at most 253 characters.';
            if ($this->allowUnderscore) {
                $messages['messageInvalidCharacter'] =
                    'Each label of {attribute} can consist of only latin letters, numbers, hyphens and underscores.';
            } else {
                $messages['messageInvalidCharacter'] =
                    'Each label of {attribute} can consist of only latin letters, numbers and hyphens.';
            }
        }
        return $messages;
    }
524935
public static function getUploadErrorMessages()
    {
        return [
            UPLOAD_ERR_OK => Module::t('upload_err_message_0'),
            UPLOAD_ERR_INI_SIZE => Module::t('upload_err_message_1'),
            UPLOAD_ERR_FORM_SIZE =>  Module::t('upload_err_message_2'),
            UPLOAD_ERR_PARTIAL =>  Module::t('upload_err_message_3'),
            UPLOAD_ERR_NO_FILE =>  Module::t('upload_err_message_4'),
            UPLOAD_ERR_NO_TMP_DIR =>  Module::t('upload_err_message_6'),
            UPLOAD_ERR_CANT_WRITE =>  Module::t('upload_err_message_7'),
            UPLOAD_ERR_EXTENSION =>  Module::t('upload_err_message_8'),
        ];
    }
825782
protected function getErrors()
    {
        $arr = ['error' => $this->getMessage()];

        if (count($this->attrs) > 0) {
            $arr['attrs'] = $this->getAttrs();
        }

        if (count($this->attrsCustom) > 0) {
            $arr['attrscustom'] = $this->getAttrsCustom();
        }

        return $arr;
    }
595317
public function getErrorsByPage(): array
    {
        $result = array();
        $errors = $this->getErrors();

        foreach ($errors as $name => $val) {
            $page = $this->getFieldProperty($name, 'page');

            if ($page) {
                $result[$page][$name] = $val;
            }
        }

        return $result;
    }