For root value, use empty pointer

This commit is contained in:
Sven Fink 2023-01-13 09:15:42 +01:00
parent c6cb3d4c2d
commit aad17ab1c8

View File

@ -499,6 +499,9 @@ class type_schema : public schema
else_->validate(ptr, instance, patch, e); else_->validate(ptr, instance, patch, e);
} }
} }
if (instance.is_null()) {
patch.add(nlohmann::json::json_pointer{}, default_value_);
}
} }
public: public:
@ -884,8 +887,8 @@ class boolean : public schema
{ {
if (!true_) { // false schema if (!true_) { // false schema
// empty array // empty array
//switch (instance.type()) { // switch (instance.type()) {
//case json::value_t::array: // case json::value_t::array:
// if (instance.size() != 0) // valid false-schema // if (instance.size() != 0) // valid false-schema
// e.error(ptr, instance, "false-schema required empty array"); // e.error(ptr, instance, "false-schema required empty array");
// return; // return;
@ -1068,6 +1071,11 @@ public:
propertyNames_ = schema::make(attr.value(), root, {"propertyNames"}, uris); propertyNames_ = schema::make(attr.value(), root, {"propertyNames"}, uris);
sch.erase(attr); sch.erase(attr);
} }
attr = sch.find("default");
if (attr != sch.end()) {
set_default_value(*attr);
}
} }
}; };