diff --git a/lib/JsonDetail.cpp b/lib/JsonDetail.cpp index c788c4cd4..cb020c2f0 100644 --- a/lib/JsonDetail.cpp +++ b/lib/JsonDetail.cpp @@ -594,8 +594,15 @@ namespace } std::string typeCheck(Validation::ValidationData & validator, const JsonNode & baseSchema, const JsonNode & schema, const JsonNode & data) - { - JsonNode::JsonType type = stringToType.find(schema.String())->second; + { + const auto typeName = schema.String(); + auto it = stringToType.find(typeName); + if(it == stringToType.end()) + { + return validator.makeErrorMessage("Unknown type in schema:" + typeName); + } + + JsonNode::JsonType type = it->second; if(type != data.getType() && data.getType() != JsonNode::DATA_NULL) return validator.makeErrorMessage("Type mismatch! Expected " + schema.String()); return "";