Skip to content

Commit

Permalink
Update schema.js
Browse files Browse the repository at this point in the history
  • Loading branch information
nuxodin committed Mar 22, 2023
1 parent e13a960 commit d640d0e
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -440,14 +440,18 @@ const validators = {
}
},
anyOf(anyOf, value) {
//let any = false;
const collecting = unevaluatedPropertiesFor.has(value);

let any = false;
for (const subSchema of anyOf) {
if (errors(value, subSchema).next().done) return true;
//const ok = [...errors(value, subSchema)].length === 0;
//any = any || ok;
const ok = errors(value, subSchema).next().done;
//const ok = [...errors(value, subSchema)].length === 0; // no need? zzz
if (ok) {
if (!collecting) return true;
any = true;
}
}
//return any;
return false;
return any;
},
oneOf(oneOf, value) {
let pass = 0;
Expand All @@ -469,13 +473,12 @@ const validators = {
return true;
},
*if(ifSchema, value, schema) {
if (!schema.then && !schema.else) return; // ignore if no "then" or "else"
// no if, no else and not collecting unevaluatedProperties
if (!schema.then && !schema.else && !unevaluatedPropertiesFor.has(value)) return;
if (errors(value, ifSchema).next().done) {
if (!schema.then) return; // ignore if no "then"
yield* errors(value, schema.then);
if (schema.then != null) yield* errors(value, schema.then);
} else {
if (!schema.else) return; // ignore if no "else"
yield* errors(value, schema.else);
if (schema.else != null) yield* errors(value, schema.else);
}
},
};
Expand Down

0 comments on commit d640d0e

Please sign in to comment.