aboutsummaryrefslogtreecommitdiff
path: root/ext/bg/js/json-schema.js
diff options
context:
space:
mode:
Diffstat (limited to 'ext/bg/js/json-schema.js')
-rw-r--r--ext/bg/js/json-schema.js15
1 files changed, 15 insertions, 0 deletions
diff --git a/ext/bg/js/json-schema.js b/ext/bg/js/json-schema.js
index cdfd339f..357432e5 100644
--- a/ext/bg/js/json-schema.js
+++ b/ext/bg/js/json-schema.js
@@ -653,6 +653,21 @@ class JsonSchemaValidator {
value[i] = this.getValidValueOrDefault(propertySchema, value[i]);
}
+ const minItems = schema.minItems;
+ if (typeof minItems === 'number' && value.length < minItems) {
+ for (let i = value.length; i < minItems; ++i) {
+ const propertySchema = this._getPropertySchema(schema, i, value, null);
+ if (propertySchema === null) { break; }
+ const item = this.getValidValueOrDefault(propertySchema);
+ value.push(item);
+ }
+ }
+
+ const maxItems = schema.maxItems;
+ if (typeof maxItems === 'number' && value.length > maxItems) {
+ value.splice(maxItems, value.length - maxItems);
+ }
+
return value;
}