aboutsummaryrefslogtreecommitdiff
path: root/ext/js/data
diff options
context:
space:
mode:
Diffstat (limited to 'ext/js/data')
-rw-r--r--ext/js/data/json-schema.js13
1 files changed, 11 insertions, 2 deletions
diff --git a/ext/js/data/json-schema.js b/ext/js/data/json-schema.js
index 7b6b9c53..6a590911 100644
--- a/ext/js/data/json-schema.js
+++ b/ext/js/data/json-schema.js
@@ -103,8 +103,12 @@ class JsonSchemaProxyHandler {
}
deleteProperty(target, property) {
- const required = this._schema.required;
- if (Array.isArray(required) && required.includes(property)) {
+ const required = (
+ (typeof target === 'object' && target !== null) ?
+ (Array.isArray(target) || this._jsonSchemaValidator.isObjectPropertyRequired(this._schema, property)) :
+ true
+ );
+ if (required) {
throw new Error(`${property} cannot be deleted`);
}
return Reflect.deleteProperty(target, property);
@@ -159,6 +163,11 @@ class JsonSchemaValidator {
this._regexCache.clear();
}
+ isObjectPropertyRequired(schema, property) {
+ const {required} = schema;
+ return Array.isArray(required) && required.includes(property);
+ }
+
// Private
_getPropertySchema(schema, property, value, path) {