From 23dc3a57ee203cbf7a507af5e40c7e8bc1ed74f8 Mon Sep 17 00:00:00 2001 From: Diya Date: Tue, 3 Feb 2026 03:56:29 +0530 Subject: [PATCH] fix multipleOf only considers case that fail in allOf --- src/error-handlers/multipleOf.js | 7 ++++--- src/test-suite/tests/multipleOf.json | 20 ++++++++++++++++++++ 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/src/error-handlers/multipleOf.js b/src/error-handlers/multipleOf.js index 04980d0..3cba32b 100644 --- a/src/error-handlers/multipleOf.js +++ b/src/error-handlers/multipleOf.js @@ -15,10 +15,11 @@ const multipleOfErrorHandler = async (normalizedErrors, instance, localization) let combinedMultipleOf = null; /** @type string[] */ const schemaLocations = []; + let hasError = false; for (const schemaLocation in normalizedErrors["https://json-schema.org/keyword/multipleOf"]) { - if (normalizedErrors["https://json-schema.org/keyword/multipleOf"][schemaLocation]) { - continue; + if (!normalizedErrors["https://json-schema.org/keyword/multipleOf"][schemaLocation]) { + hasError = true; } const keyword = await getSchema(schemaLocation); @@ -28,7 +29,7 @@ const multipleOfErrorHandler = async (normalizedErrors, instance, localization) schemaLocations.push(schemaLocation); } - if (combinedMultipleOf !== null) { + if (combinedMultipleOf !== null && hasError) { errors.push({ message: localization.getMultipleOfErrorMessage(combinedMultipleOf), instanceLocation: Instance.uri(instance), diff --git a/src/test-suite/tests/multipleOf.json b/src/test-suite/tests/multipleOf.json index 067638d..ae0372f 100644 --- a/src/test-suite/tests/multipleOf.json +++ b/src/test-suite/tests/multipleOf.json @@ -62,6 +62,26 @@ "schemaLocations": ["#/allOf/0/multipleOf", "#/allOf/1/multipleOf"] } ] + }, + { + "description": "multipleOf constraints within allOf are partially satisfied", + "schema": { + "allOf": [ + { "multipleOf": 2 }, + { "multipleOf": 3 } + ] + }, + "instance": 9, + "errors": [ + { + "messageId": "multipleOf-message", + "messageParams": { + "multipleOf": "6" + }, + "instanceLocation": "#", + "schemaLocations": ["#/allOf/0/multipleOf", "#/allOf/1/multipleOf"] + } + ] } ] }