@@ -69,6 +69,7 @@ public function answerMaxLength($model, $data, $question, $max) {
6969 * @param array $question 回答データに対応する質問
7070 * @param array $allAnswers 入力された回答すべて
7171 * @return bool
72+ * @SuppressWarnings(PHPMD.CyclomaticComplexity)
7273 */
7374 public function answerTextValidation ($ model , $ data , $ question , $ allAnswers ) {
7475 if (! in_array ($ question ['question_type ' ], $ this ->_textValidateType )) {
@@ -77,7 +78,7 @@ public function answerTextValidation($model, $data, $question, $allAnswers) {
7778 $ ret = true ;
7879 // 数値型回答を望まれている場合
7980 if ($ question ['question_type_option ' ] == QuestionnairesComponent::TYPE_OPTION_NUMERIC ) {
80- if (!Validation::numeric ($ data ['answer_value ' ])) {
81+ if (mb_strlen ( $ data [ ' answer_value ' ]) !== 0 && !Validation::numeric ($ data ['answer_value ' ])) {
8182 $ ret = false ;
8283 $ model ->validationErrors ['answer_value ' ][] = __d ('questionnaires ' , 'Number required ' );
8384 }
@@ -86,7 +87,7 @@ public function answerTextValidation($model, $data, $question, $allAnswers) {
8687 $ data ['answer_value ' ],
8788 intval ($ question ['min ' ]),
8889 intval ($ question ['max ' ]));
89- if (!$ rangeRes ) {
90+ if (mb_strlen ( $ data [ ' answer_value ' ]) !== 0 && !$ rangeRes ) {
9091 $ ret = false ;
9192 $ model ->validationErrors ['answer_value ' ][] = __d ('questionnaires ' ,
9293 'Please enter the answer between %s and %s. ' ,
0 commit comments