produck / svg-captcha

generate svg captcha in node
MIT License
1.86k stars 174 forks source link

Math Expression result are not between min and max config options #34

Open jmaguirrei opened 5 years ago

jmaguirrei commented 5 years ago

Bug: Math Expression result are not between min and max config options Version: 1.4.0

Current behavior:

svgCaptcha.createMathExpr({
   noise: 1,
   mathMin: 1,
   mathMax: 9,
   background: 'black',
});

outputs: 6 + 5, 5 + 6, 3 + 4, ...

Expected behavior: According to the docs, the result of the expression must be between 1 and 9

It seems each element in the expression is between mathMin and mathMax but not the result.

May be a bug either in the implementation or in the docs.

Thanks

amit10may commented 4 years ago

I am also facing same issue. UPDATE: Seems I was using an older version - the recent version has fixes in lib/random.js and lib/index.js It may still be confusing as to what is real contract of the range. Simpler option could be to set a min and max range for each operand instead of final result.