MCPcopy Create free account
hub / github.com/pboettch/json-schema-validator / array

Method array

src/json-validator.cpp:1268–1315  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1266
1267public:
1268 array(json &sch, root_schema *root, const std::vector<nlohmann::json_uri> &uris)
1269 : schema(root)
1270 {
1271 auto attr = sch.find("maxItems");
1272 if (attr != sch.end()) {
1273 maxItems_ = {true, attr.value().get<size_t>()};
1274 sch.erase(attr);
1275 }
1276
1277 attr = sch.find("minItems");
1278 if (attr != sch.end()) {
1279 minItems_ = {true, attr.value().get<size_t>()};
1280 sch.erase(attr);
1281 }
1282
1283 attr = sch.find("uniqueItems");
1284 if (attr != sch.end()) {
1285 uniqueItems_ = attr.value().get<bool>();
1286 sch.erase(attr);
1287 }
1288
1289 attr = sch.find("items");
1290 if (attr != sch.end()) {
1291
1292 if (attr.value().type() == json::value_t::array) {
1293 size_t c = 0;
1294 for (auto &subsch : attr.value())
1295 items_.push_back(schema::make(subsch, root, {"items", std::to_string(c++)}, uris));
1296
1297 auto attr_add = sch.find("additionalItems");
1298 if (attr_add != sch.end()) {
1299 additionalItems_ = schema::make(attr_add.value(), root, {"additionalItems"}, uris);
1300 sch.erase(attr_add);
1301 }
1302
1303 } else if (attr.value().type() == json::value_t::object ||
1304 attr.value().type() == json::value_t::boolean)
1305 items_schema_ = schema::make(attr.value(), root, {"items"}, uris);
1306
1307 sch.erase(attr);
1308 }
1309
1310 attr = sch.find("contains");
1311 if (attr != sch.end()) {
1312 contains_ = schema::make(attr.value(), root, {"contains"}, uris);
1313 sch.erase(attr);
1314 }
1315 }
1316};
1317
1318std::shared_ptr<schema> type_schema::make(json &schema,

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected