json/schema: additionalProperties, patternProperties

This commit is contained in:
Danny Robson 2015-03-23 18:42:17 +11:00
parent 90552732d7
commit 0318c70709

View File

@ -63,15 +63,27 @@ validate (json::tree::object &node,
continue; continue;
} catch (const json::key_error&) } catch (const json::key_error&)
{ ; } { ; }
if (additional != schema.cend ()) {
if (additional->second->is_boolean () && !additional->second->as_bool ())
throw json::schema_error ("additionalProperties");
validate (*p->second, additional->second->as_object ());
}
} }
} }
} }
if (pattern != schema.cend ()) if (pattern != schema.cend ()) {
not_implemented (); for (auto &cond: pattern->second->as_object ()) {
std::regex expr (cond.first, std::regex_constants::ECMAScript);
if (additional != schema.cend ()) for (auto &props: node) {
not_implemented (); if (std::regex_search (props.first, expr))
validate (*props.second, cond.second->as_object ());
}
}
}
if (schema.has ("dependencies")) if (schema.has ("dependencies"))
not_implemented (); not_implemented ();