|
|
@@ -14,6 +14,7 @@
|
|
|
#include <jvalidate/constraint/object_constraint.h>
|
|
|
#include <jvalidate/constraint/string_constraint.h>
|
|
|
|
|
|
+#include <jvalidate/detail/enumerate.h>
|
|
|
#include <jvalidate/detail/expect.h>
|
|
|
#include <jvalidate/detail/parser_context.h>
|
|
|
#include <jvalidate/detail/vocabulary.h>
|
|
|
@@ -190,8 +191,7 @@ public:
|
|
|
std::vector<schema::Node const *> children;
|
|
|
|
|
|
std::set<adapter::Type> types;
|
|
|
- size_t index = 0;
|
|
|
- for (auto subschema : context.schema.as_array()) {
|
|
|
+ for (auto const & [index, subschema] : detail::enumerate(context.schema.as_array())) {
|
|
|
if (subschema.type() != adapter::Type::String) {
|
|
|
children.push_back(context.child(subschema, index).node());
|
|
|
} else if (subschema.as_string() == "any") {
|
|
|
@@ -199,7 +199,6 @@ public:
|
|
|
} else {
|
|
|
types.insert(to_type(subschema.as_string()));
|
|
|
}
|
|
|
- ++index;
|
|
|
}
|
|
|
|
|
|
auto rval = std::make_unique<constraint::AnyOfConstraint>(children);
|
|
|
@@ -218,10 +217,8 @@ public:
|
|
|
children.push_back(context.node());
|
|
|
break;
|
|
|
case adapter::Type::Array: {
|
|
|
- size_t index = 0;
|
|
|
- for (auto const & subschema : context.schema.as_array()) {
|
|
|
+ for (auto const & [index, subschema] : detail::enumerate(context.schema.as_array())) {
|
|
|
children.push_back(context.child(subschema, index).node());
|
|
|
- ++index;
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
|
@@ -265,10 +262,8 @@ public:
|
|
|
EXPECT(context.schema.type() == adapter::Type::Array);
|
|
|
|
|
|
std::vector<schema::Node const *> rval;
|
|
|
- size_t index = 0;
|
|
|
- for (auto subschema : context.schema.as_array()) {
|
|
|
+ for (auto const & [index, subschema] : detail::enumerate(context.schema.as_array())) {
|
|
|
rval.push_back(context.child(subschema, index).node());
|
|
|
- ++index;
|
|
|
}
|
|
|
|
|
|
return std::make_unique<constraint::AllOfConstraint>(rval);
|
|
|
@@ -278,10 +273,8 @@ public:
|
|
|
EXPECT(context.schema.type() == adapter::Type::Array);
|
|
|
|
|
|
std::vector<schema::Node const *> rval;
|
|
|
- size_t index = 0;
|
|
|
- for (auto subschema : context.schema.as_array()) {
|
|
|
+ for (auto const & [index, subschema] : detail::enumerate(context.schema.as_array())) {
|
|
|
rval.push_back(context.child(subschema, index).node());
|
|
|
- ++index;
|
|
|
}
|
|
|
|
|
|
return std::make_unique<constraint::AnyOfConstraint>(rval);
|
|
|
@@ -291,10 +284,8 @@ public:
|
|
|
EXPECT(context.schema.type() == adapter::Type::Array);
|
|
|
|
|
|
std::vector<schema::Node const *> rval;
|
|
|
- size_t index = 0;
|
|
|
- for (auto subschema : context.schema.as_array()) {
|
|
|
+ for (auto const & [index, subschema] : detail::enumerate(context.schema.as_array())) {
|
|
|
rval.push_back(context.child(subschema, index).node());
|
|
|
- ++index;
|
|
|
}
|
|
|
|
|
|
return std::make_unique<constraint::OneOfConstraint>(rval);
|
|
|
@@ -401,10 +392,8 @@ public:
|
|
|
EXPECT(context.schema.type() == adapter::Type::Array);
|
|
|
|
|
|
std::vector<schema::Node const *> rval;
|
|
|
- size_t index = 0;
|
|
|
- for (auto subschema : context.schema.as_array()) {
|
|
|
+ for (auto const & [index, subschema] : detail::enumerate(context.schema.as_array())) {
|
|
|
rval.push_back(context.child(subschema, index).node());
|
|
|
- ++index;
|
|
|
}
|
|
|
|
|
|
return std::make_unique<constraint::TupleConstraint>(rval);
|