We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 563552a commit 55a85b9Copy full SHA for 55a85b9
lib/validator.js
@@ -58,6 +58,24 @@ function createValidator(subprotocol, json) {
58
const ajv = new Ajv({strictSchema: false});
59
addFormats(ajv);
60
ajv.addSchema(json);
61
+
62
+ ajv.removeKeyword("multipleOf");
63
+ ajv.addKeyword({
64
+ keyword: "multipleOf",
65
+ type: "number",
66
+ compile(schema) {
67
+ return data => {
68
+ const result = data / schema;
69
+ const epsilon = 1e-6; // small value to account for floating point precision errors
70
+ return Math.abs(Math.round(result) - result) < epsilon;
71
+ };
72
+ },
73
+ errors: false,
74
+ metaSchema: {
75
76
77
+ });
78
79
return new Validator(subprotocol, ajv);
80
}
81
0 commit comments