Fix conditional logic
This commit is contained in:
parent
964db74108
commit
7c9fe2c6cf
@ -199,17 +199,19 @@ class JsonSchemaProxyHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static validateConditional(value, schema) {
|
static validateConditional(value, schema) {
|
||||||
const ifCondition = schema.if;
|
const ifSchema = schema.if;
|
||||||
if (!JsonSchemaProxyHandler.isObject(ifCondition)) { return; }
|
if (!JsonSchemaProxyHandler.isObject(ifSchema)) { return; }
|
||||||
|
|
||||||
const thenSchema = schema.then;
|
let okay = true;
|
||||||
if (JsonSchemaProxyHandler.isObject(thenSchema)) {
|
try {
|
||||||
JsonSchemaProxyHandler.validate(value, thenSchema);
|
JsonSchemaProxyHandler.validate(value, thenSchema);
|
||||||
|
} catch (e) {
|
||||||
|
okay = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const elseSchema = schema.else;
|
const nextSchema = okay ? schema.then : schema.else;
|
||||||
if (JsonSchemaProxyHandler.isObject(elseSchema)) {
|
if (JsonSchemaProxyHandler.isObject(nextSchema)) {
|
||||||
JsonSchemaProxyHandler.validate(value, thenSchema);
|
JsonSchemaProxyHandler.validate(value, nextSchema);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user