diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index eb2068b..577445c 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -32,8 +32,8 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - php: [ '7.1', '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/RegistrationAnswerTextBehavior.php b/Model/Behavior/RegistrationAnswerTextBehavior.php index d2cf5b6..2a47566 100644 --- a/Model/Behavior/RegistrationAnswerTextBehavior.php +++ b/Model/Behavior/RegistrationAnswerTextBehavior.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'] == RegistrationsComponent::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('registrations', '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'][] = sprintf( __d('registrations', 'Please enter the answer between %s and %s.'),