Closed KgTeKoN closed 10 months ago
Here is a link to the code snippet that does the multiple calculation: https://github.com/hapijs/joi/blob/7ead57a9f8180895e110f010b425ae411451bd08/lib/types/number.js#L175C31-L175C31
Here is a screenshot of the output using your example using the Node v16 REPL: The first example gives 0 when I remove a trailing 0 from both numbers, however when I add it back I get just under 0.
This seems like a floating point discrepancy with 1/3600000
. Looks like doing (value/base) % 1
gives the correct answer though.
You would probably want to write your own custom validation function in meantime to get around this
When I try to validate 14400000 as a multiple of 3600000 (14400000 / 3600000 = 4) I get an error. But this validation Joi.number().min(14400000).multiple(3600).multiple(1000).required() works correct.