ajv-validator/ajv

Error using multipleOf with decimals

Kaspanoombro opened this issue · 1 comments

What version of Ajv are you using? Does the issue happen if you use the latest version?
8.12.0
Ajv options object

const Ajv = require("ajv");
const ajv = new Ajv();
const schema = {
   type: "number",
   multipleOf: 0.01
 };
const validate = ajv.compile(schema);
validate(8.69);;
// results: false

What results did you expect?
true
Are you going to resolve the issue?
No.

I think you are looking for multipleOfPrecision option in AJV. For your example I think you can set this option to 2 and it should work, but have a look at the docs and see how you go.

ajv = new Ajv({
    multipleOfPrecision: 2
});