aboutsummaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
Diffstat (limited to 'ext')
-rw-r--r--ext/bg/js/json-schema.js22
1 files changed, 22 insertions, 0 deletions
diff --git a/ext/bg/js/json-schema.js b/ext/bg/js/json-schema.js
index 8129b6d2..ab4a4817 100644
--- a/ext/bg/js/json-schema.js
+++ b/ext/bg/js/json-schema.js
@@ -154,6 +154,9 @@ class JsonSchemaProxyHandler {
let result = JsonSchemaProxyHandler.validateSingleSchema(value, schema);
if (result !== null) { return result; }
+ result = JsonSchemaProxyHandler.validateConditional(value, schema);
+ if (result !== null) { return result; }
+
result = JsonSchemaProxyHandler.validateAllOf(value, schema);
if (result !== null) { return result; }
@@ -169,6 +172,25 @@ class JsonSchemaProxyHandler {
return null;
}
+ static validateConditional(value, schema) {
+ const ifCondition = schema.if;
+ if (!JsonSchemaProxyHandler.isObject(ifCondition)) { return null; }
+
+ const thenSchema = schema.then;
+ if (JsonSchemaProxyHandler.isObject(thenSchema)) {
+ const result = JsonSchemaProxyHandler.validate(value, thenSchema);
+ if (result !== null) { return `then conditional didn't match: ${result}`; }
+ }
+
+ const elseSchema = schema.else;
+ if (JsonSchemaProxyHandler.isObject(elseSchema)) {
+ const result = JsonSchemaProxyHandler.validate(value, thenSchema);
+ if (result !== null) { return `else conditional didn't match: ${result}`; }
+ }
+
+ return null;
+ }
+
static validateAllOf(value, schema) {
const subSchemas = schema.allOf;
if (!Array.isArray(subSchemas)) { return null; }