perillScore.js 687 B

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