diff --git a/include/valijson/internal/json_pointer.hpp b/include/valijson/internal/json_pointer.hpp index 79bb04f..ca978bc 100644 --- a/include/valijson/internal/json_pointer.hpp +++ b/include/valijson/internal/json_pointer.hpp @@ -15,13 +15,13 @@ namespace internal { namespace json_pointer { /** - * @brief Replace all occurrences of `search` with `replace`. Modifies `subject` in place + * @brief Replace all occurrences of `search` with `replace`. Modifies `subject` in place. * * @param subject string to operate on * @param search string to search * @param replace replacement string */ -inline void replace_all_inplace(std::string& subject, const char* search, +inline void replaceAllInPlace(std::string& subject, const char* search, const char* replace) { size_t pos = 0; @@ -94,8 +94,8 @@ inline std::string extractReferenceToken(std::string::const_iterator begin, std::string token(begin, end); // Replace JSON Pointer-specific escaped character sequences - replace_all_inplace(token, "~1", "/"); - replace_all_inplace(token, "~0", "~"); + replaceAllInPlace(token, "~1", "/"); + replaceAllInPlace(token, "~0", "~"); // Replace %-encoded character sequences with their actual characters for (size_t n = token.find('%'); n != std::string::npos; diff --git a/include/valijson/validation_visitor.hpp b/include/valijson/validation_visitor.hpp index 4da2657..7b0ee87 100644 --- a/include/valijson/validation_visitor.hpp +++ b/include/valijson/validation_visitor.hpp @@ -967,9 +967,16 @@ public: if (!additionalPropertiesSubschema) { if (propertiesMatched.size() != target.getObjectSize()) { if (results) { - results->pushError(context, "Object contains properties " + std::string unwanted; + for (const typename AdapterType::ObjectMember m : object) { + if (propertiesMatched.find(m.first) == propertiesMatched.end()) { + unwanted = m.first; + break; + } + } + results->pushError(context, "Object contains a property " "that could not be validated using 'properties' " - "or 'additionalProperties' constraints"); + "or 'additionalProperties' constraints: '" + unwanted + "'."); } return false; diff --git a/tests/test_jsoncpp_adapter.cpp b/tests/test_jsoncpp_adapter.cpp index bd088df..aa8b381 100644 --- a/tests/test_jsoncpp_adapter.cpp +++ b/tests/test_jsoncpp_adapter.cpp @@ -12,7 +12,7 @@ TEST_F(TestJsonCppAdapter, BasicArrayIteration) { const unsigned int numElements = 10; - // Create a rapidjson document that consists of an array of numbers + // Create a jsoncpp document that consists of an array of numbers Json::Value document(Json::arrayValue); for (unsigned int i = 0; i < numElements; i++) { document.append(Json::Value(i)); @@ -46,7 +46,7 @@ TEST_F(TestJsonCppAdapter, BasicObjectIteration) { const unsigned int numElements = 10; - // Create a rapidjson document that consists of an object that maps numeric + // Create a jsoncpp document that consists of an object that maps numeric // strings their corresponding numeric values Json::Value document(Json::objectValue); for (unsigned int i = 0; i < numElements; i++) { diff --git a/tests/test_property_tree_adapter.cpp b/tests/test_property_tree_adapter.cpp index eba84b2..43855dc 100644 --- a/tests/test_property_tree_adapter.cpp +++ b/tests/test_property_tree_adapter.cpp @@ -12,7 +12,7 @@ TEST_F(TestPropertyTreeAdapter, BasicArrayIteration) { const unsigned int numElements = 10; - // Create a boost property that is equivalent to a JSON array containing a + // Create a boost property tree that is equivalent to a JSON array containing a // list of numbers. boost::property_tree::ptree document; for (unsigned int i = 0; i < numElements; i++) { @@ -50,7 +50,7 @@ TEST_F(TestPropertyTreeAdapter, BasicObjectIteration) { const unsigned int numElements = 10; - // Create a rapidjson document that consists of an object that maps numeric + // Create a boost property tree that consists of an object that maps numeric // strings their corresponding numeric values boost::property_tree::ptree document; for (unsigned int i = 0; i < numElements; i++) {