@@ -80,6 +80,8 @@ namespace sjv
8080
8181 bool SJV::verify_json (const string &pointer, const json &input, const json &rules)
8282 {
83+ // if (pointer == "/geometry/*/surface_selection/*")
84+ // std::cout << "gotcha" << std::endl;
8385 // Find all rules that apply for the input node
8486 // TODO: accelerate this
8587 std::vector<json> matching_rules = collect_pointer (pointer, rules);
@@ -97,10 +99,16 @@ namespace sjv
9799
98100 // Test all rules, only one must pass, otherwise throw exception
99101 int count = 0 ;
102+ json single_matched_rule;
100103
101104 for (auto i : matching_rules)
105+ {
102106 if (verify_rule (input, i))
107+ {
103108 count++;
109+ single_matched_rule = i;
110+ }
111+ }
104112
105113 if (count == 0 && !matching_rules.empty ())
106114 {
@@ -141,7 +149,7 @@ namespace sjv
141149 json defaults = collect_default_rules (new_pointer, rules);
142150
143151 // if it is mandatory, make sure there are no defaults
144- if (matching_rules[ 0 ] .contains (" required" ) && contained_in_list (i.key (), matching_rules[ 0 ] [" required" ]))
152+ if (single_matched_rule .contains (" required" ) && contained_in_list (i.key (), single_matched_rule [" required" ]))
145153 {
146154 if (defaults.size () != 0 )
147155 {
@@ -150,7 +158,7 @@ namespace sjv
150158 }
151159 }
152160 // if it is optional, there should be only one default in the specs
153- else if (matching_rules[ 0 ] .contains (" optional" ) && contained_in_list (i.key (), matching_rules[ 0 ] [" optional" ]))
161+ else if (single_matched_rule .contains (" optional" ) && contained_in_list (i.key (), single_matched_rule [" optional" ]))
154162 {
155163 if (defaults.size () != 1 )
156164 {
0 commit comments