|
|
@@ -114,21 +114,20 @@ public:
|
|
|
}
|
|
|
|
|
|
Status visit(constraint::AnyOfConstraint const & cons) const {
|
|
|
- Status rval = Status::Reject;
|
|
|
-
|
|
|
+ std::optional<size_t> first_validated;
|
|
|
for (auto const & [index, subschema] : detail::enumerate(cons.children)) {
|
|
|
if (validate_subschema(subschema, index)) {
|
|
|
- rval = Status::Accept;
|
|
|
+ first_validated = index;
|
|
|
}
|
|
|
- if (not visited_ && rval == Status::Accept) {
|
|
|
+ if (not visited_ && first_validated.has_value()) {
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if (rval == Status::Reject) {
|
|
|
- return note(rval, "validates none of the subschemas");
|
|
|
+ if (first_validated.has_value()) {
|
|
|
+ return note(Status::Accept, "validates subschema ", *first_validated);
|
|
|
}
|
|
|
- return note(rval, "validates subschema ", i);
|
|
|
+ return note(Status::Reject, "validates none of the subschemas");
|
|
|
}
|
|
|
|
|
|
Status visit(constraint::OneOfConstraint const & cons) const {
|
|
|
@@ -162,7 +161,7 @@ public:
|
|
|
bool const if_true = [this, &cons]() {
|
|
|
scoped_state(tracking_, StoreResults::ForAnything);
|
|
|
return validate_subschema(cons.if_constraint);
|
|
|
- };
|
|
|
+ }();
|
|
|
if (if_true) {
|
|
|
return validate_subschema(cons.then_constraint, detail::parent, "then");
|
|
|
}
|