Check all models for errors
@return boolean|string - false if all OK, true if error in main model or language code of fail i18n-model
764020
protected function modelsHaveErrors($model, $modelsI18n)
    {
        if ($model->hasErrors()) return true;

        $existsOneLanguageData = false;
        foreach($modelsI18n as $langCode => $modelI18n) {
            if ($modelI18n->hasErrors()) return $langCode;
            if (!empty($modelI18n->title) && !empty($modelI18n->body)) {
                $existsOneLanguageData = true;
            }
        }
        if (!$existsOneLanguageData) {
            Yii::$app->session->setFlash('error', Yii::t($this->tcModule, 'Need texts for at least one language'));
            return true;
        }
        return false;
    }
653387
public function detectLanguage()
    {
        $acceptableLanguages = Yii::$app->getRequest()->getAcceptableLanguages();
        foreach ($acceptableLanguages as $language) {
            if ($this->isValidLanguage($language)) {
                return $language;
            }
        }
        foreach ($acceptableLanguages as $language) {
            $pattern = preg_quote(substr($language, 0, 2), '/');
            foreach ($this->languages as $key => $value) {
                if (preg_match('/^' . $pattern . '/', $value) || preg_match('/^' . $pattern . '/', $key)) {
                    return $this->isValidLanguage($key) ? $key : $value;
                }
            }
        }

        return false;
    }
1282036
public function error()
    {
        if ($this->error) {
            $debug_tpl_vars = [
                '{LANGUAGE}' => $this->language,
                '{PATH}'     => self::LANG_ROOT,
            ];
            $msg = strtr($this->error_messages[$this->error], $debug_tpl_vars);

            return "<br /><strong>GenSynth Error:</strong> $msg (code {$this->error})<br />";
        }

        return false;
    }
369670
protected function validateLanguage()
    {
        $this->setSubmitted('language');
        $this->setSubmittedBool('status');
        $this->setSubmittedBool('default');
        $this->setSubmitted('update', $this->data_language);

        $this->validateComponent('language');

        return !$this->hasErrors();
    }
468409
public static function check()
    {
        $collections = self::getCollection();

        $jsonLastError = json_last_error();

        return isset($jsonLastError) ? $collections[$jsonLastError] : $collections['default'];
    }
932834
public function check(): bool
  {
    if ( $this->current !== null ){
      // if $on_error is set to E_CONTINUE returns true
      if ( $this->on_error === self::E_CONTINUE ){
        return true;
      }
      // If any connection has an error with mode E_STOP_ALL
      if ( self::$has_error_all && ($this->on_error !== self::E_STOP_ALL) ){
        return false;
      }
      // If this connection has an error with mode E_STOP
      if ( $this->has_error && ($this->on_error !== self::E_STOP) ){
        return false;
      }
      return true;
    }
    return false;
  }
453633
public function validateTranslations()
    {
        $valid = !empty($this->_models);
        $activeTranslations = 0;
        foreach ($this->_models as $model) {
            if ($this->isTranslationActive($model)) {
                $activeTranslations++;
                $valid = $valid && $model->validate();
            }
        }
        return $activeTranslations>0 && $valid;
    }
192612
protected function validate()
    {
        $this->data = $this->module->getInfo($this->module_id);

        if (empty($this->data)) {
            $this->error = $this->translation->text('Failed to read module @id', array('@id' => $this->module_id));
            return false;
        }

        try {
            $this->module_model->checkCore($this->data);
            $this->module_model->checkPhpVersion($this->data);
            return true;
        } catch (Exception $ex) {
            $this->error = $ex->getMessage();
            return false;
        }
    }
97431
public static function checkError()
    {
        switch (json_last_error()) {
            case JSON_ERROR_NONE:
                $msg = null;
                break;
            case JSON_ERROR_DEPTH:
                $msg = 'Maximum stack depth exceeded';
                break;
            case JSON_ERROR_STATE_MISMATCH:
                $msg = 'Underflow or the modes mismatch';
                break;
            case JSON_ERROR_CTRL_CHAR:
                $msg = 'Unexpected control character found';
                break;
            case JSON_ERROR_SYNTAX:
                $msg = 'Syntax error, malformed JSON';
                break;
            case JSON_ERROR_UTF8:
                $msg = 'Malformed UTF-8 characters, possibly incorrectly encoded';
                break;
            default:
                $msg = 'Unknown error';
                break;
        }
        return $msg;
    }
2605
@Override
	public boolean validate(final Problems problems, final String compName, final String model) {
		try {
			Integer.parseInt(model);
		} catch (final NumberFormatException e) {
			problems.add(ValidationBundle.getMessage(IsAnIntegerValidator.class, "ERR_NOT_INTEGER", model)); // NOI18N
			return false;
		}
		return true;
	}
1048731
public function hasError(): bool
    {
        return isset($this->decodedBody['error']) || isset($this->decodedBody['errors']) || isset($this->decodedBody['field-errors']);
    }
800438
protected function validateNameLanguage()
    {
        $field = 'name';

        if ($this->isExcluded($field)) {
            return null;
        }

        $value = $this->getSubmitted($field);

        if (!isset($value)) {
            $this->unsetSubmitted($field);
            return true; // If not set, code will be used instead
        }

        if (mb_strlen($value) > 50) {
            $this->setErrorLengthRange($field, $this->translation->text('Name'), 0, 50);
            return false;
        }

        return true;
    }
698851
public function check() {
        $this->_errors = [];

        foreach ($this->_constraints as $constraints) {
            if (!isset($this->_data[$this->_field])) {
                $this->_data[$this->_field] = [];
            }

            if (!is_array($this->_data[$this->_field])) {
                $this->_data[$this->_field] = [$this->_data[$this->_field]];
            }

            foreach ($this->_data[$this->_field] as $value) {
                switch ($constraints['type']) {
                    case self::EQUAL:
                        if ($value != $constraints['value']) {
                            array_push($this->_errors, ['name' => $this->_field, 'field' => $this->_label, 'message' => $constraints['message']]);
                        }
                        break;

                    case self::DIFFERENT:
                        if ($value == $constraints['value']) {
                            array_push($this->_errors, ['name' => $this->_field, 'field' => $this->_label, 'message' => $constraints['message']]);
                        }
                        break;

                    case self::MORETHAN:
                        if ($value <= $constraints['value']) {
                            array_push($this->_errors, ['name' => $this->_field, 'field' => $this->_label, 'message' => $constraints['message']]);
                        }
                        break;

                    case self::LESSTHAN:
                        if ($value >= $constraints['value']) {
                            array_push($this->_errors, ['name' => $this->_field, 'field' => $this->_label, 'message' => $constraints['message']]);
                        }
                        break;

                    case self::BETWEEN:
                        if ($value < $constraints['value'][0] || $value > $constraints['value'][1]) {
                            array_push($this->_errors, ['name' => $this->_field, 'field' => $this->_label, 'message' => $constraints['message']]);
                        }
                        break;

                    case self::IN:
                        if (!in_array($value, $constraints['value'])) {
                            array_push($this->_errors, ['name' => $this->_field, 'field' => $this->_label, 'message' => $constraints['message']]);
                        }
                        break;

                    case self::NOTIN:
                        if (in_array($value, $constraints['value'])) {
                            array_push($this->_errors, ['name' => $this->_field, 'field' => $this->_label, 'message' => $constraints['message']]);
                        }
                        break;

                    case self::LENGTH:
                        if (strlen($value) != $constraints['value']) {
                            array_push($this->_errors, ['name' => $this->_field, 'field' => $this->_label, 'message' => $constraints['message']]);
                        }
                        break;

                    case self::LENGTHMIN:
                        if (strlen($value) < $constraints['value']) {
                            array_push($this->_errors, ['name' => $this->_field, 'field' => $this->_label, 'message' => $constraints['message']]);
                        }
                        break;

                    case self::LENGTHMAX:
                        if (strlen($value) > $constraints['value']) {
                            array_push($this->_errors, ['name' => $this->_field, 'field' => $this->_label, 'message' => $constraints['message']]);
                        }
                        break;

                    case self::LENGTHIN:
                        if (!in_array(strlen($value), $constraints['value'])) {
                            array_push($this->_errors, ['name' => $this->_field, 'field' => $this->_label, 'message' => $constraints['message']]);
                        }
                        break;

                    case self::LENGTHBETWEEN:
                        if (strlen($value) < $constraints['value'][0] || strlen($value) > $constraints['value'][1]) {
                            array_push($this->_errors, ['name' => $this->_field, 'field' => $this->_label, 'message' => $constraints['message']]);
                        }
                        break;

                    case self::REGEX:
                        if (!preg_match($constraints['value'], $value)) {
                            array_push($this->_errors, ['name' => $this->_field, 'field' => $this->_label, 'message' => $constraints['message']]);
                        }
                        break;

                    case self::URL:
                        if (!filter_var($value, FILTER_VALIDATE_URL)) {
                            array_push($this->_errors, ['name' => $this->_field, 'field' => $this->_label, 'message' => $constraints['message']]);
                        }
                        break;

                    case self::MAIL:
                        if (!filter_var($value, FILTER_VALIDATE_EMAIL)) {
                            array_push($this->_errors, ['name' => $this->_field, 'field' => $this->_label, 'message' => $constraints['message']]);
                        }
                        break;

                    case self::INT:
                        if (!filter_var($value, FILTER_VALIDATE_INT)) {
                            array_push($this->_errors, ['name' => $this->_field, 'field' => $this->_label, 'message' => $constraints['message']]);
                        }
                        break;

                    case self::FLOAT:
                        if (!filter_var($value, FILTER_VALIDATE_FLOAT)) {
                            array_push($this->_errors, ['name' => $this->_field, 'field' => $this->_label, 'message' => $constraints['message']]);
                        }
                        break;

                    case self::ALPHA:
                        if (!preg_match('#^([a-zA-Z]+)$#', $value)) {
                            array_push($this->_errors, ['name' => $this->_field, 'field' => $this->_label, 'message' => $constraints['message']]);
                        }
                        break;

                    case self::ALPHANUM:
                        if (!preg_match('#^([a-zA-Z0-9]+)$#', $value)) {
                            array_push($this->_errors, ['name' => $this->_field, 'field' => $this->_label, 'message' => $constraints['message']]);
                        }
                        break;

                    case self::ALPHADASH:
                        if (!preg_match('#^([a-zA-Z0-9_-]+)$#', $value)) {
                            array_push($this->_errors, ['name' => $this->_field, 'field' => $this->_label, 'message' => $constraints['message']]);
                        }
                        break;

                    case self::IP:
                        if (!filter_var($value, FILTER_VALIDATE_IP)) {
                            array_push($this->_errors, ['name' => $this->_field, 'field' => $this->_label, 'message' => $constraints['message']]);
                        }
                        break;

                    case self::SQL:
                        $sql = new Sql();
                        $sql->query('query-form-validation', $constraints['value']['query']);
                        $sql->vars('value', $value);
                        $sql->vars($constraints['value']['vars']);
                        $data = $sql->fetch('query-form-validation', Sql::PARAM_FETCHCOLUMN);

                        $querySuccess = true;

                        switch ($constraints['value']['constraint']) {
                            case '==':
                                if ($data != $constraints['value']['value']) {
                                    $querySuccess = false;
                                }
                                break;

                            case '!=':
                                if ($data == $constraints['value']['value']) {
                                    $querySuccess = false;
                                }
                                break;

                            case '>':
                                if ($data <= $constraints['value']['value']) {
                                    $querySuccess = false;
                                }
                                break;

                            case '<':
                                if ($data >= $constraints['value']['value']) {
                                    $querySuccess = false;
                                }
                                break;
                        }

                        if (!$querySuccess) {
                            array_push($this->_errors, ['name' => $this->_field, 'field' => $this->_label, 'message' => $constraints['message']]);
                        }
                        break;

                    case self::CUSTOM:
                        /** @var object[] $constraints */
                        if ($constraints['value']->filter() == false) {
                            array_push($this->_errors, ['name' => $this->_field, 'field' => $this->_label, 'message' => $constraints['value']->error()]);
                        }
                        break;
                }
            }

            switch ($constraints['type']) {
                case self::COUNT:
                    if (count($this->_data[$this->_field]) != $constraints['value']) {
                        array_push($this->_errors, ['name' => $this->_field, 'field' => $this->_label, 'message' => $constraints['message']]);
                    }
                    break;

                case self::COUNTMIN:
                    if (count($this->_data[$this->_field]) < $constraints['value']) {
                        array_push($this->_errors, ['name' => $this->_field, 'field' => $this->_label, 'message' => $constraints['message']]);
                    }
                    break;

                case self::COUNTMAX:
                    if (count($this->_data[$this->_field]) > $constraints['value']) {
                        array_push($this->_errors, ['name' => $this->_field, 'field' => $this->_label, 'message' => $constraints['message']]);
                    }
                    break;

                case self::COUNTIN:
                    /** @var array $constraints */
                    if (!in_array(count($this->_data[$this->_field]), $constraints['value'])) {
                        array_push($this->_errors, ['name' => $this->_field, 'field' => $this->_label, 'message' => $constraints['message']]);
                    }
                    break;

                case self::EXIST:
                    if (count($this->_data[$this->_field]) == 0) {
                        array_push($this->_errors, ['name' => $this->_field, 'field' => $this->_label, 'message' => $constraints['message']]);
                    }
                    break;

                case self::NOTEXIST:
                    if (count($this->_data[$this->_field]) > 0) {
                        array_push($this->_errors, ['name' => $this->_field, 'field' => $this->_label, 'message' => $constraints['message']]);
                    }
                    break;
            }
        }
    }
369629
protected function interpretError() {
        switch (get_class($this->exception)) {
            case UserErrorException::class:
            case tao_models_classes_MissingRequestParameterException::class:
            case common_exception_MissingParameter::class:
            case common_exception_BadRequest::class:
                $this->returnHttpCode = 400;
                $this->responseClassName = 'MainResponse';
            break;
            case 'tao_models_classes_AccessDeniedException':
            case 'ResolverException':
                $this->returnHttpCode    = 403;
                $this->responseClassName = 'RedirectResponse';
            break;
            case 'tao_models_classes_UserException':
                $this->returnHttpCode    = 403;
                $this->responseClassName = 'MainResponse';
            break;
            case 'ActionEnforcingException':
            case 'tao_models_classes_FileNotFoundException':
                $this->returnHttpCode    = 404;
                $this->responseClassName = 'MainResponse';
            break;
            default :
                $this->responseClassName = 'MainResponse';
                $this->returnHttpCode    = 500;
            break;
            
        }
        return $this;
    }
1146248
protected function findErrors()
    {
        $session = session();
        if (!$session->has('errors') || !$session->get('errors')->hasBag('default')) {
            return;
        }
        /** @var MessageBag $messageBag */
        $messageBag = session()->get('errors')->getBag('default');
        if (isset($messageBag->messages()[$this->name])) {
            foreach ($messageBag->messages()[$this->name] as $error) {
                $this->addError($error);
            }
        }
    }
151390
public function any_error_messages() {
        $errors = array();
        foreach ($this->get_all_slots() as $slot) {
            foreach ($this->for_slot($slot)->get_sub_question_ids() as $subqid) {
                if ($this->for_subq($subqid)->differentweights) {
                    $name = $this->for_subq($subqid)->question->name;
                    $errors[] = get_string('erroritemappearsmorethanoncewithdifferentweight', 'question', $name);
                }
            }
        }
        return $errors;
    }
862158
public function errorAction() {
		$validationResults = $this->arguments->getValidationResults()->getFlattenedErrors();
		$result = array();
		/** @var \Neos\Error\Messages\Error  $validationResult */
		foreach ($validationResults as $key => $validationResult) {
			/** @var \Neos\Flow\Validation\Error $error */
			foreach ($validationResult as $error) {
				// Check Current Package Validation Errors
				$translatedMessage = $this->translator->translateById($error->getCode(), $error->getArguments(), NULL, NULL, 'ValidationErrors', $this->request->getControllerPackageKey());

				// Check Flow Validation Errors
				if ($translatedMessage === $error->getCode()) {
					$translatedMessage = $this->translator->translateById($error->getCode(), $error->getArguments(), NULL, NULL, 'ValidationErrors', 'Neos.Flow');
				}

				// Use default error message
				if ($translatedMessage === $error->getCode()) {
					$translatedMessage = $error->render();
				}

				$result['errors'][$key][] = array(
					'code' => $error->getCode(),
					'message' => $translatedMessage
				);
			}
		}
		$result['success'] = FALSE;
		$this->view->assign('value', $result);
		$this->response->setStatus(400);
	}