diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 36cd2b9..f46fc05 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -30,8 +30,8 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - php: [ '7.2', '7.3', '7.4' ] - mysql: [ '5.7', '8.0' ] + php: [ '7.4' ] + mysql: [ '8.0' ] env: NC3_BUILD_DIR: "/opt/nc3" diff --git a/Model/Behavior/QuestionnaireAnswerTextBehavior.php b/Model/Behavior/QuestionnaireAnswerTextBehavior.php index 996013f..d7d57ab 100644 --- a/Model/Behavior/QuestionnaireAnswerTextBehavior.php +++ b/Model/Behavior/QuestionnaireAnswerTextBehavior.php @@ -69,6 +69,7 @@ public function answerMaxLength($model, $data, $question, $max) { * @param array $question 回答データに対応する質問 * @param array $allAnswers 入力された回答すべて * @return bool + * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ public function answerTextValidation($model, $data, $question, $allAnswers) { if (! in_array($question['question_type'], $this->_textValidateType)) { @@ -77,7 +78,7 @@ public function answerTextValidation($model, $data, $question, $allAnswers) { $ret = true; // 数値型回答を望まれている場合 if ($question['question_type_option'] == QuestionnairesComponent::TYPE_OPTION_NUMERIC) { - if (!Validation::numeric($data['answer_value'])) { + if (mb_strlen($data['answer_value']) !== 0 && !Validation::numeric($data['answer_value'])) { $ret = false; $model->validationErrors['answer_value'][] = __d('questionnaires', 'Number required'); } @@ -86,7 +87,7 @@ public function answerTextValidation($model, $data, $question, $allAnswers) { $data['answer_value'], intval($question['min']), intval($question['max'])); - if (!$rangeRes) { + if (mb_strlen($data['answer_value']) !== 0 && !$rangeRes) { $ret = false; $model->validationErrors['answer_value'][] = __d('questionnaires', 'Please enter the answer between %s and %s.',