From d23f4047ed9ab80d7c64ff1f0538975b1224e1e1 Mon Sep 17 00:00:00 2001 From: Daniel D'Avella Date: Tue, 28 Aug 2018 14:46:36 -0400 Subject: [PATCH 1/2] Fix instances in schema_parser.hpp that should use maybe* --- include/valijson/schema_parser.hpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/include/valijson/schema_parser.hpp b/include/valijson/schema_parser.hpp index f526168..92f4319 100644 --- a/include/valijson/schema_parser.hpp +++ b/include/valijson/schema_parser.hpp @@ -1985,7 +1985,7 @@ private: constraints::RequiredConstraint constraint; for (const AdapterType v : node.getArray()) { - if (!v.isString()) { + if (!v.maybeString()) { throw std::runtime_error("Expected required property name to " "be a string value"); } @@ -2028,7 +2028,7 @@ private: TypeConstraint constraint; - if (node.isString()) { + if (node.maybeString()) { const TypeConstraint::JsonType type = TypeConstraint::jsonTypeFromString(node.getString()); @@ -2039,10 +2039,10 @@ private: constraint.addNamedType(type); - } else if (node.isArray()) { + } else if (node.maybeArray()) { int index = 0; for (const AdapterType v : node.getArray()) { - if (v.isString()) { + if (v.maybeString()) { const TypeConstraint::JsonType type = TypeConstraint::jsonTypeFromString(v.getString()); @@ -2054,7 +2054,7 @@ private: constraint.addNamedType(type); - } else if (v.isObject() && version == kDraft3) { + } else if (v.maybeObject() && version == kDraft3) { const std::string childPath = nodePath + "/" + std::to_string(index); const Subschema *subschema = makeOrReuseSchema( @@ -2069,7 +2069,7 @@ private: index++; } - } else if (node.isObject() && version == kDraft3) { + } else if (node.maybeObject() && version == kDraft3) { const Subschema *subschema = makeOrReuseSchema( rootSchema, rootNode, node, currentScope, nodePath, fetchDoc, NULL, NULL, docCache, schemaCache); From 25c5a5df5159f7e89ed0dca238718ffcaf092b0f Mon Sep 17 00:00:00 2001 From: Daniel D'Avella Date: Tue, 4 Sep 2018 14:32:46 -0400 Subject: [PATCH 2/2] Fix instances in basic_adapter that should use maybe --- include/valijson/adapters/basic_adapter.hpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/include/valijson/adapters/basic_adapter.hpp b/include/valijson/adapters/basic_adapter.hpp index 28b188c..efbe8f7 100644 --- a/include/valijson/adapters/basic_adapter.hpp +++ b/include/valijson/adapters/basic_adapter.hpp @@ -757,7 +757,7 @@ public: { if (value.isBool()) { return true; - } else if (value.isString()) { + } else if (maybeString()) { std::string stringValue; if (value.getString(stringValue)) { if (stringValue.compare("true") == 0 || stringValue.compare("false") == 0) { @@ -773,7 +773,7 @@ public: { if (value.isNumber()) { return true; - } else if (value.isString()) { + } else if (maybeString()) { std::string s; if (value.getString(s)) { const char *b = s.c_str(); @@ -790,7 +790,7 @@ public: { if (value.isInteger()) { return true; - } else if (value.isString()) { + } else if (maybeString()) { std::string s; if (value.getString(s)) { std::istringstream i(s); @@ -810,7 +810,7 @@ public: { if (value.isNull()) { return true; - } else if (value.isString()) { + } else if (maybeString()) { std::string stringValue; if (value.getString(stringValue)) { if (stringValue.empty()) { @@ -826,7 +826,7 @@ public: { if (value.isObject()) { return true; - } else if (value.isArray()) { + } else if (maybeArray()) { size_t arraySize; if (value.getArraySize(arraySize) && arraySize == 0) { return true;