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"] + } + ] } ] }