Use proposed json_pointer::operator/ from https://github.com/nlohmann/json/pull/1469

This commit is contained in:
garethsb-sony 2019-02-01 08:15:26 +00:00
parent 24768e316d
commit 55b7bebb2f

View File

@ -271,14 +271,14 @@ class logical_combination : public schema
if (err) { if (err) {
//sub_schema_err << " one schema failed because: " << e.what() << "\n"; //sub_schema_err << " one schema failed because: " << e.what() << "\n";
if (combine_logic == allOf) { if (combine_logic == allOf) {
e.error(ptr, instance, "at least one schema has failed, but ALLOF them are required to validate."); e.error(ptr, instance, "at least one schema has failed, but all of them are required to validate.");
return; return;
} }
} else } else
count++; count++;
if (combine_logic == oneOf && count > 1) { if (combine_logic == oneOf && count > 1) {
e.error(ptr, instance, "more than one schema has succeeded, but only ONEOF them is required to validate."); e.error(ptr, instance, "more than one schema has succeeded, but exactly one of them is required to validate.");
return; return;
} }
if (combine_logic == anyOf && count == 1) if (combine_logic == anyOf && count == 1)
@ -286,7 +286,7 @@ class logical_combination : public schema
} }
if ((combine_logic == anyOf || combine_logic == oneOf) && count == 0) if ((combine_logic == anyOf || combine_logic == oneOf) && count == 0)
e.error(ptr, instance, "no validation has succeeded but ANYOF/ONEOF them is required to validate."); e.error(ptr, instance, "no validation has succeeded but one of them is required to validate.");
} }
public: public:
@ -692,7 +692,7 @@ class boolean : public schema
// return; // return;
//} //}
e.error(ptr, instance, "instance invalid as par false-schema"); e.error(ptr, instance, "instance invalid as per false-schema");
} }
} }
@ -755,24 +755,24 @@ class object : public schema
// check if it is in "properties" // check if it is in "properties"
if (schema_p != properties_.end()) { if (schema_p != properties_.end()) {
a_prop_or_pattern_matched = true; a_prop_or_pattern_matched = true;
schema_p->second->validate(ptr + p.key(), p.value(), e); schema_p->second->validate(ptr / p.key(), p.value(), e);
} }
// check all matching patternProperties // check all matching patternProperties
for (auto &schema_pp : patternProperties_) for (auto &schema_pp : patternProperties_)
if (REGEX_NAMESPACE::regex_search(p.key(), schema_pp.first)) { if (REGEX_NAMESPACE::regex_search(p.key(), schema_pp.first)) {
a_prop_or_pattern_matched = true; a_prop_or_pattern_matched = true;
schema_pp.second->validate(ptr + p.key(), p.value(), e); schema_pp.second->validate(ptr / p.key(), p.value(), e);
} }
// check additionalProperties as a last resort // check additionalProperties as a last resort
if (!a_prop_or_pattern_matched && additionalProperties_) if (!a_prop_or_pattern_matched && additionalProperties_)
additionalProperties_->validate(ptr + p.key(), p.value(), e); additionalProperties_->validate(ptr / p.key(), p.value(), e);
} }
for (auto &dep : dependencies_) { for (auto &dep : dependencies_) {
auto prop = instance.find(dep.first); auto prop = instance.find(dep.first);
if (prop != instance.end()) // if dependency-property is present in instance if (prop != instance.end()) // if dependency-property is present in instance
dep.second->validate(ptr + dep.first, instance, e); // validate dep.second->validate(ptr / dep.first, instance, e); // validate
} }
} }
@ -886,7 +886,7 @@ class array : public schema
size_t index = 0; size_t index = 0;
if (items_schema_) if (items_schema_)
for (auto &i : instance) { for (auto &i : instance) {
items_schema_->validate(ptr + index, i, e); items_schema_->validate(ptr / index, i, e);
index++; index++;
} }
else { else {
@ -903,7 +903,7 @@ class array : public schema
if (!item_validator) if (!item_validator)
break; break;
item_validator->validate(ptr + index, i, e); item_validator->validate(ptr / index, i, e);
} }
} }