function score(value) { const match = String(value || '').trim().match(/^(\d+)/) return match ? Number(match[1]) : null } function validateFutureExpectation(answerMethods) { const methods = answerMethods || [] const current = methods.find(item => String(item.assessmentMethod) === '1') const future = methods.find(item => String(item.assessmentMethod) === '2') const currentScore = score(current && current.value) const futureScore = score(future && future.value) if (currentScore === null || futureScore === null || futureScore <= currentScore) { return '一年后期待分应高于现状评分,请注意!' } return '' } module.exports = { validateFutureExpectation }