"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.validateQuestionnaireQuestions=exports.validateQuestionnaireQuestion=void 0;var _validator=require("../../../../utils/validator"),isEmptyTextValue=function(e){return null==e||""===String(e).trim()},getQuestionErrorMessage=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.value,i=isEmptyTextValue(t),r=Array.isArray(t)&&0===t.length,a="";if(e.isRequired&&("input"===e.type&&i||"single"===e.type&&(null==t||""===t)||"multi"===e.type&&r)&&(a="此项为必填项"),!a&&"input"===e.type&&!i){var n=String(t).trim(),s=String(e.subTag||"");"phone_number"!==s||(0,_validator.isValidPhoneNumber)(n)?"email"!==s||(0,_validator.isValidEmail)(n)||(a="邮箱格式不正确"):a="手机号格式不正确"}return a},validateQuestionnaireQuestion=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=getQuestionErrorMessage(e),r="currentQuestionnaire.questions[".concat(t,"].errorMessage"),a={};return(i||e.errorMessage)&&(a[r]=i),{ok:!i,updates:a,errorMessage:i}};exports.validateQuestionnaireQuestion=validateQuestionnaireQuestion;var validateQuestionnaireQuestions=function(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t={},i=!1,r=0;r<e.length;r++){var a=e[r]||{},n=validateQuestionnaireQuestion(a,r),s=n.errorMessage,o=n.updates;s&&(i=!0),Object.assign(t,o)}return{ok:!i,updates:t}};exports.validateQuestionnaireQuestions=validateQuestionnaireQuestions;