Reference validation using contains() result rather than exception handling
This commit is contained in:
parent
8edd521853
commit
40af3ec396
@ -254,15 +254,15 @@ public:
|
|||||||
//
|
//
|
||||||
// an unknown keyword can only be referenced by a json-pointer,
|
// an unknown keyword can only be referenced by a json-pointer,
|
||||||
// not by a plain name fragment
|
// not by a plain name fragment
|
||||||
if (uri.pointer().to_string() != "") {
|
if (!uri.pointer().to_string().empty()) {
|
||||||
try {
|
bool contains_pointer = file.unknown_keywords.contains(uri.pointer());
|
||||||
auto &subschema = file.unknown_keywords.at(uri.pointer()); // null is returned if not existing
|
if (contains_pointer) {
|
||||||
auto s = schema::make(subschema, this, {}, {{uri}}); // A JSON Schema MUST be an object or a boolean.
|
auto &subschema = file.unknown_keywords.at(uri.pointer());
|
||||||
if (s) { // nullptr if invalid schema, e.g. null
|
auto s = schema::make(subschema, this, {}, {{uri}});
|
||||||
|
if (s) { // if schema is valid (non-null)
|
||||||
file.unknown_keywords.erase(uri.fragment());
|
file.unknown_keywords.erase(uri.fragment());
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
} catch (nlohmann::detail::out_of_range &) { // at() did not find it
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user