1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
| const _ = require('lodash');
let map = new Map([ [2, "验证不通过,原因是xxxx"], [3, "验证不通过,原因是xxxx"], [5, "验证不通过,原因是xxxx"], [7, "验证不通过,原因是xxxx"], [11, "验证不通过,原因是xxxx"], [13, "验证不通过,原因是xxxx"], [17, "验证不通过,原因是xxxx"] ]);
let a = validator_a(args1) ? 1 : 2; let b = validator_b(args2) ? 1 : 3; let c = validator_c(args3) ? 1 : 5; let d = validator_d(args4) ? 1 : 7; let e = validator_e(args5) ? 1 : 11; let f = validator_f(args6) ? 1 : 13; let g = validator_g(args7) ? 1 : 17;
let final = a * b * c * d * e * f * g;
if (final === 1){ return true; }
else { if (map.has(final)){ console.log(map.get(final)); return false; } else { let keys = [ ...map.keys()]; let errorMessage = []; _.forEach(keys, (key)=>{ if (final % key === 0){ errorMessage.push(map.get(final)); } }); console.log(errorMessage); return false; } }
|