From e9b50162bf7ac114c1afc95264094da9e52e14b9 Mon Sep 17 00:00:00 2001 From: Tristan Penman Date: Wed, 17 Feb 2016 08:47:13 -0800 Subject: [PATCH] Ensure validation state is not discarded after checking for an 'additionalProperties' constraint --- include/valijson/validation_visitor.hpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/include/valijson/validation_visitor.hpp b/include/valijson/validation_visitor.hpp index 411852a..b66bcb3 100644 --- a/include/valijson/validation_visitor.hpp +++ b/include/valijson/validation_visitor.hpp @@ -853,7 +853,17 @@ public: const Subschema *additionalPropertiesSubschema = constraint.getAdditionalPropertiesSubschema(); if (!additionalPropertiesSubschema) { - return propertiesMatched.size() == target.getObjectSize(); + if (propertiesMatched.size() != target.getObjectSize()) { + if (results) { + results->pushError(context, "Object contains properties " + "that could not be validated using 'properties' " + "or 'additionalProperties' constraints"); + } + + return false; + } + + return validated; } BOOST_FOREACH( const typename AdapterType::ObjectMember m, object ) {